Whamcloud - gitweb
Don't pass garbage mode bits to the filesystem with O_CREAT.
authoradilger <adilger>
Thu, 12 Feb 2004 18:19:54 +0000 (18:19 +0000)
committeradilger <adilger>
Thu, 12 Feb 2004 18:19:54 +0000 (18:19 +0000)
It is really the fault of K&R that there are 2 different open prototypes.

lustre/tests/openfile.c

index 81236b0..d494b4a 100644 (file)
@@ -53,7 +53,7 @@ int main(int argc, char** argv)
 {
         int    fd;
         int    flags=0;
 {
         int    fd;
         int    flags=0;
-        mode_t mode=0;
+        mode_t mode=0644;
         char*  fname=NULL;
         int    mode_set=0;
         int    flag_set=0;
         char*  fname=NULL;
         int    mode_set=0;
         int    flag_set=0;
@@ -131,7 +131,7 @@ int main(int argc, char** argv)
         }
 
 
         }
 
 
-        if (mode_set)
+        if (flags & O_CREAT)
                 fd = open(fname, flags, mode);
         else
                 fd = open(fname, flags);
                 fd = open(fname, flags, mode);
         else
                 fd = open(fname, flags);