* Removed the O_* modes that we currently don't and probably won't support
(O_MOUNT, O_EXLOCK, and O_SHLOCK). I only left the non-standard O_TEMPORARY for the time being (as it shouldn't fool anyone). * Fixed libutil that already used O_EXLOCK, even though it did not do anything. * Moved O_NOCACHE, and O_NOFOLLOW to the section with implemented modes. * Added O_DIRECTORY. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34278 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -53,16 +53,14 @@
|
|||||||
#define O_SYNC 0x00010000 /* write synchronized I/O file integrity */
|
#define O_SYNC 0x00010000 /* write synchronized I/O file integrity */
|
||||||
#define O_RSYNC 0x00020000 /* read synchronized I/O file integrity */
|
#define O_RSYNC 0x00020000 /* read synchronized I/O file integrity */
|
||||||
#define O_DSYNC 0x00040000 /* write synchronized I/O data integrity */
|
#define O_DSYNC 0x00040000 /* write synchronized I/O data integrity */
|
||||||
|
#define O_NOFOLLOW 0x00080000 /* fail on symlinks */
|
||||||
|
#define O_NOCACHE 0x00100000 /* do not use the file system cache if */
|
||||||
|
/* possible */
|
||||||
|
#define O_DIRECT O_NOCACHE
|
||||||
|
#define O_DIRECTORY 0x00200000 /* fail if not a directory */
|
||||||
|
|
||||||
/* TODO: currently not implemented additions: */
|
/* TODO: currently not implemented additions: */
|
||||||
#define O_NOFOLLOW 0x00080000
|
|
||||||
/* should we implement this? it's similar to O_NOTRAVERSE but will fail on symlinks */
|
|
||||||
#define O_NOCACHE 0x00100000 /* doesn't use the file system cache if possible */
|
|
||||||
#define O_DIRECT O_NOCACHE
|
|
||||||
#define O_MOUNT 0x00200000 /* for file systems */
|
|
||||||
#define O_TEMPORARY 0x00400000 /* used to avoid writing temporary files to disk */
|
#define O_TEMPORARY 0x00400000 /* used to avoid writing temporary files to disk */
|
||||||
#define O_SHLOCK 0x01000000 /* obtain shared lock */
|
|
||||||
#define O_EXLOCK 0x02000000 /* obtain exclusive lock */
|
|
||||||
|
|
||||||
#ifdef B_ENABLE_INCOMPLETE_POSIX_AT_SUPPORT
|
#ifdef B_ENABLE_INCOMPLETE_POSIX_AT_SUPPORT
|
||||||
#define AT_FDCWD (-1) /* CWD FD for the *at() functions */
|
#define AT_FDCWD (-1) /* CWD FD for the *at() functions */
|
||||||
|
|||||||
@@ -779,10 +779,8 @@
|
|||||||
#define O_NOFOLLOW FSSH_O_NOFOLLOW
|
#define O_NOFOLLOW FSSH_O_NOFOLLOW
|
||||||
#define O_NOCACHE FSSH_O_NOCACHE
|
#define O_NOCACHE FSSH_O_NOCACHE
|
||||||
#define O_DIRECT FSSH_O_DIRECT
|
#define O_DIRECT FSSH_O_DIRECT
|
||||||
#define O_MOUNT FSSH_O_MOUNT
|
#define O_DIRECTORY FSSH_O_DIRECTORY
|
||||||
#define O_TEMPORARY FSSH_O_TEMPORARY
|
#define O_TEMPORARY FSSH_O_TEMPORARY
|
||||||
#define O_SHLOCK FSSH_O_SHLOCK
|
|
||||||
#define O_EXLOCK FSSH_O_EXLOCK
|
|
||||||
|
|
||||||
#define S_IREAD FSSH_S_IREAD
|
#define S_IREAD FSSH_S_IREAD
|
||||||
#define S_IWRITE FSSH_S_IWRITE
|
#define S_IWRITE FSSH_S_IWRITE
|
||||||
|
|||||||
@@ -50,16 +50,15 @@
|
|||||||
#define FSSH_O_SYNC 0x00010000 /* write synchronized I/O file integrity */
|
#define FSSH_O_SYNC 0x00010000 /* write synchronized I/O file integrity */
|
||||||
#define FSSH_O_RSYNC 0x00020000 /* read synchronized I/O file integrity */
|
#define FSSH_O_RSYNC 0x00020000 /* read synchronized I/O file integrity */
|
||||||
#define FSSH_O_DSYNC 0x00040000 /* write synchronized I/O data integrity */
|
#define FSSH_O_DSYNC 0x00040000 /* write synchronized I/O data integrity */
|
||||||
|
#define FSSH_O_NOFOLLOW 0x00080000 /* fail on symlinks */
|
||||||
|
#define FSSH_O_NOCACHE 0x00100000 /* do not use the file system cache if */
|
||||||
|
/* possible */
|
||||||
|
#define FSSH_O_DIRECT FSSH_O_NOCACHE
|
||||||
|
#define FSSH_O_DIRECTORY 0x00200000 /* fail if not a directory */
|
||||||
|
|
||||||
// TODO: currently not implemented additions:
|
// TODO: currently not implemented additions:
|
||||||
#define FSSH_O_NOFOLLOW 0x00080000
|
|
||||||
/* should we implement this? it's similar to O_NOTRAVERSE but will fail on symlinks */
|
/* should we implement this? it's similar to O_NOTRAVERSE but will fail on symlinks */
|
||||||
#define FSSH_O_NOCACHE 0x00100000 /* doesn't use the file system cache if possible */
|
|
||||||
#define FSSH_O_DIRECT FSSH_O_NOCACHE
|
|
||||||
#define FSSH_O_MOUNT 0x00200000 /* for file systems */
|
|
||||||
#define FSSH_O_TEMPORARY 0x00400000 /* used to avoid writing temporary files to disk */
|
#define FSSH_O_TEMPORARY 0x00400000 /* used to avoid writing temporary files to disk */
|
||||||
#define FSSH_O_SHLOCK 0x01000000 /* obtain shared lock */
|
|
||||||
#define FSSH_O_EXLOCK 0x02000000 /* obtain exclusive lock */
|
|
||||||
|
|
||||||
#define FSSH_S_IREAD 0x0100 /* owner may read */
|
#define FSSH_S_IREAD 0x0100 /* owner may read */
|
||||||
#define FSSH_S_IWRITE 0x0080 /* owner may write */
|
#define FSSH_S_IWRITE 0x0080 /* owner may write */
|
||||||
|
|||||||
+16
-1
@@ -113,7 +113,21 @@ pidfile_open(const char *path, mode_t mode, pid_t *pidptr)
|
|||||||
* pidfile_write() can be called multiple times.
|
* pidfile_write() can be called multiple times.
|
||||||
*/
|
*/
|
||||||
fd = open(pfh->pf_path,
|
fd = open(pfh->pf_path,
|
||||||
O_WRONLY | O_CREAT | O_EXLOCK | O_TRUNC | O_NONBLOCK, mode);
|
O_WRONLY | O_CREAT | O_TRUNC | O_NONBLOCK, mode);
|
||||||
|
|
||||||
|
if (fd >= 0) {
|
||||||
|
struct flock lock;
|
||||||
|
lock.l_type = F_WRLCK;
|
||||||
|
lock.l_whence = SEEK_SET;
|
||||||
|
lock.l_start = 0;
|
||||||
|
lock.l_len = 0;
|
||||||
|
|
||||||
|
if (fcntl(F_SETLK, &lock) == -1) {
|
||||||
|
close(fd);
|
||||||
|
fd = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
if (errno == EWOULDBLOCK && pidptr != NULL) {
|
if (errno == EWOULDBLOCK && pidptr != NULL) {
|
||||||
errno = pidfile_read(pfh->pf_path, pidptr);
|
errno = pidfile_read(pfh->pf_path, pidptr);
|
||||||
@@ -123,6 +137,7 @@ pidfile_open(const char *path, mode_t mode, pid_t *pidptr)
|
|||||||
free(pfh);
|
free(pfh);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remember file information, so in pidfile_write() we are sure we write
|
* Remember file information, so in pidfile_write() we are sure we write
|
||||||
* to the proper descriptor.
|
* to the proper descriptor.
|
||||||
|
|||||||
Reference in New Issue
Block a user