-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(logging): add DIRECT I/O to file
perf(logging): reduce system calls for file feat(utils): add generate_date_string and number_pad methods feat(utils): add open_file method feat(server): add error checking when initializing logs feat(commands): better getting connected at data for CLIENT INFO command
- Loading branch information
Showing
11 changed files
with
241 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "../../headers/utils.h" | ||
|
||
#include <errno.h> | ||
|
||
#include <fcntl.h> | ||
#include <unistd.h> | ||
|
||
int open_file(const char *file, int flags) { | ||
int fd; | ||
|
||
if ((fd = open(file, (O_RDWR | O_CREAT | O_DIRECT | flags), (S_IRUSR | S_IWUSR))) == -1) { | ||
switch (errno) { | ||
case EINVAL: | ||
write_log(LOG_ERR, "Direct I/O does not be supported by your file system, cannot open file."); | ||
break; | ||
|
||
case EISDIR: | ||
write_log(LOG_ERR, "Specified file is a directory, cannot open file."); | ||
break; | ||
|
||
case ENOMEM: | ||
write_log(LOG_ERR, "No available memory to create/open file."); | ||
break; | ||
|
||
case EROFS: | ||
write_log(LOG_ERR, "Your file system is read-only, cannot open file for writing."); | ||
break; | ||
|
||
default: | ||
write_log(LOG_ERR, "File cannot be opened or created."); | ||
} | ||
|
||
return -1; | ||
} | ||
|
||
return fd; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.