This commit is contained in:
Lucas Verdelho 2024-05-12 21:46:22 +01:00
commit 8a1db028fb
2 changed files with 20 additions and 2 deletions

View file

@ -10,7 +10,7 @@
int main() {
const char *message_queue_path = "/djumbai/fifos/message_queue";
if (faccessat(AT_FDCWD,message_queue_path, F_OK,AT_EACCESS) != -1) {
if (faccessat(AT_FDCWD, message_queue_path, F_OK, AT_EACCESS) != -1) {
// FIFO exists, delete it
if (unlink(message_queue_path) == -1) {
perror("unlink");
@ -37,9 +37,18 @@ int main() {
}
}
// Open the FIFO for writing
const char *send_fifo_path = "/djumbai/fifos/send_fifo";
// Check if I have write permissions on the FIFO
if (faccessat(AT_FDCWD, send_fifo_path, W_OK, AT_EACCESS) != -1) {
printf("You have write access to the FIFO.\n");
} else {
perror("Error");
exit(EXIT_FAILURE);
}
int send_fifo_fd;
// Open the FIFO for writing
send_fifo_fd = open(send_fifo_path, O_WRONLY);
if (send_fifo_fd == -1) {
if (errno == ENOENT) {

View file

@ -1,4 +1,5 @@
#include "djumbai_enqueue.h"
#include <stdlib.h>
int main() {
@ -6,6 +7,14 @@ int main() {
const char *message_queue_path =
"/djumbai/fifos/message_queue";
//Check if I have write permissions on the FIFO
if (faccessat(AT_FDCWD, message_queue_path,W_OK,AT_EACCESS) != -1) {
printf("You have write access to the FIFO.\n");
} else {
perror("Error");
exit(EXIT_FAILURE);
}
// Open the FIFO for writing
int queue_fd;
queue_fd = open(message_queue_path, O_WRONLY);