[haiku-commits] r34278 - in haiku/trunk: headers/posix headers/private/fs_shell src/libs/util

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 26 Nov 2009 15:17:46 +0100 (CET)

Author: axeld
Date: 2009-11-26 15:17:46 +0100 (Thu, 26 Nov 2009)
New Revision: 34278
Changeset: http://dev.haiku-os.org/changeset/34278/haiku

Modified:
   haiku/trunk/headers/posix/fcntl.h
   haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h
   haiku/trunk/headers/private/fs_shell/fssh_fcntl.h
   haiku/trunk/src/libs/util/pidfile.c
Log:
* 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.


Modified: haiku/trunk/headers/posix/fcntl.h
===================================================================
--- haiku/trunk/headers/posix/fcntl.h   2009-11-26 12:53:30 UTC (rev 34277)
+++ haiku/trunk/headers/posix/fcntl.h   2009-11-26 14:17:46 UTC (rev 34278)
@@ -53,16 +53,14 @@
 #define O_SYNC                 0x00010000      /* write 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_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: */
-#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_SHLOCK               0x01000000      /* obtain shared lock */
-#define O_EXLOCK               0x02000000      /* obtain exclusive lock */
 
 #ifdef B_ENABLE_INCOMPLETE_POSIX_AT_SUPPORT
 #define AT_FDCWD               (-1)            /* CWD FD for the *at() 
functions */

Modified: haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h
===================================================================
--- haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h     2009-11-26 
12:53:30 UTC (rev 34277)
+++ haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h     2009-11-26 
14:17:46 UTC (rev 34278)
@@ -779,10 +779,8 @@
 #define O_NOFOLLOW     FSSH_O_NOFOLLOW
 #define O_NOCACHE      FSSH_O_NOCACHE
 #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_SHLOCK       FSSH_O_SHLOCK
-#define O_EXLOCK       FSSH_O_EXLOCK
 
 #define S_IREAD                FSSH_S_IREAD
 #define S_IWRITE       FSSH_S_IWRITE

Modified: haiku/trunk/headers/private/fs_shell/fssh_fcntl.h
===================================================================
--- haiku/trunk/headers/private/fs_shell/fssh_fcntl.h   2009-11-26 12:53:30 UTC 
(rev 34277)
+++ haiku/trunk/headers/private/fs_shell/fssh_fcntl.h   2009-11-26 14:17:46 UTC 
(rev 34278)
@@ -50,16 +50,15 @@
 #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_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:
-#define FSSH_O_NOFOLLOW                0x00080000
        /* 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_SHLOCK          0x01000000      /* obtain shared lock */
-#define FSSH_O_EXLOCK          0x02000000      /* obtain exclusive lock */
 
 #define FSSH_S_IREAD           0x0100  /* owner may read */
 #define FSSH_S_IWRITE          0x0080  /* owner may write */

Modified: haiku/trunk/src/libs/util/pidfile.c
===================================================================
--- haiku/trunk/src/libs/util/pidfile.c 2009-11-26 12:53:30 UTC (rev 34277)
+++ haiku/trunk/src/libs/util/pidfile.c 2009-11-26 14:17:46 UTC (rev 34278)
@@ -113,7 +113,21 @@
         * pidfile_write() can be called multiple times.
         */
        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 (errno == EWOULDBLOCK && pidptr != NULL) {
                        errno = pidfile_read(pfh->pf_path, pidptr);
@@ -123,6 +137,7 @@
                free(pfh);
                return (NULL);
        }
+       
        /*
         * Remember file information, so in pidfile_write() we are sure we write
         * to the proper descriptor.


Other related posts: