Added write access check
This commit is contained in:
parent
1b7e95c249
commit
1a05bc5d54
2 changed files with 20 additions and 2 deletions
|
@ -37,9 +37,18 @@ int main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open the FIFO for writing
|
|
||||||
const char *send_fifo_path = "/djumbai/fifos/send_fifo";
|
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;
|
int send_fifo_fd;
|
||||||
|
// Open the FIFO for writing
|
||||||
send_fifo_fd = open(send_fifo_path, O_WRONLY);
|
send_fifo_fd = open(send_fifo_path, O_WRONLY);
|
||||||
if (send_fifo_fd == -1) {
|
if (send_fifo_fd == -1) {
|
||||||
if (errno == ENOENT) {
|
if (errno == ENOENT) {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "djumbai_enqueue.h"
|
#include "djumbai_enqueue.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
|
@ -6,6 +7,14 @@ int main() {
|
||||||
const char *message_queue_path =
|
const char *message_queue_path =
|
||||||
"/djumbai/fifos/message_queue";
|
"/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
|
// Open the FIFO for writing
|
||||||
int queue_fd;
|
int queue_fd;
|
||||||
queue_fd = open(message_queue_path, O_WRONLY);
|
queue_fd = open(message_queue_path, O_WRONLY);
|
||||||
|
|
Loading…
Reference in a new issue