]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Clean up usage of open()
authorDoug Ledford <dledford@redhat.com>
Thu, 24 Jul 2008 22:35:11 +0000 (18:35 -0400)
committerDoug Ledford <dledford@redhat.com>
Thu, 24 Jul 2008 22:35:11 +0000 (18:35 -0400)
Fix on call that passed an invalid mode to open
Don't pass a third arg unless we also pass O_CREAT
Use symbolic args for 2nd and 3rd args

Signed-off-by: Doug Ledford <dledford@redhat.com>
Create.c
Detail.c
Grow.c
Monitor.c
Query.c
mdassemble.c
mdopen.c

index 84075797f394930702f110f148c0393cd32cd7a8..7b1836a319b267c67484580c5d7af57cefffa26f 100644 (file)
--- a/Create.c
+++ b/Create.c
@@ -212,7 +212,7 @@ int Create(struct supertype *st, char *mddev, int mdfd,
                info.array.working_disks++;
                if (dnum < raiddisks)
                        info.array.active_disks++;
-               fd = open(dname, O_RDONLY|O_EXCL, 0);
+               fd = open(dname, O_RDONLY|O_EXCL);
                if (fd <0 ) {
                        fprintf(stderr, Name ": Cannot open %s: %s\n",
                                dname, strerror(errno));
@@ -543,7 +543,7 @@ int Create(struct supertype *st, char *mddev, int mdfd,
                                info.disk.minor = 0;
                                info.disk.state = (1<<MD_DISK_FAULTY);
                        } else {
-                               fd = open(dv->devname, O_RDONLY|O_EXCL, 0);
+                               fd = open(dv->devname, O_RDONLY|O_EXCL);
                                if (fd < 0) {
                                        fprintf(stderr, Name ": failed to open %s after earlier success - aborting\n",
                                                dv->devname);
index 2488c03abfad9747667169b1c402dbadacf618e4..2b2111cd2f448cf691753d9382cda86c2eea4910 100644 (file)
--- a/Detail.c
+++ b/Detail.c
@@ -38,7 +38,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
         * GET_ARRAY_INFO and GET_DISK_INFO ioctl calls
         */
 
-       int fd = open(dev, O_RDONLY, 0);
+       int fd = open(dev, O_RDONLY);
        int vers;
        mdu_array_info_t array;
        mdu_disk_info_t *disks;
diff --git a/Grow.c b/Grow.c
index c2eae32bbb5645fb0744cfc1f3544d047813d243..a8194bf05b69e3e86b5eefcc88241bdb837ea398 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -686,7 +686,7 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
                        }
                spares = sra->array.spare_disks;
                if (backup_file) {
-                       fdlist[d] = open(backup_file, O_RDWR|O_CREAT|O_EXCL, 0600);
+                       fdlist[d] = open(backup_file, O_RDWR|O_CREAT|O_EXCL, S_IRUSR | S_IWUSR);
                        if (fdlist[d] < 0) {
                                fprintf(stderr, Name ": %s: cannot create backup file %s: %s\n",
                                        devname, backup_file, strerror(errno));
index 54193f5c1fa51c1c1537164d167d83d774d4033f..abc2dbd684b24cc578932bcef8bfbedc4e6c458b 100644 (file)
--- a/Monitor.c
+++ b/Monitor.c
@@ -156,7 +156,7 @@ int Monitor(mddev_dev_t devlist,
                        return 1;
                }
                close(0);
-               open("/dev/null", 3);
+               open("/dev/null", O_RDWR);
                dup2(0,1);
                dup2(0,2);
                setsid();
diff --git a/Query.c b/Query.c
index 080296425af6bf41ee1adb69a1253f03a120af7e..190ee298834e70d9640e29fbc551bba0a5742934 100644 (file)
--- a/Query.c
+++ b/Query.c
@@ -37,7 +37,7 @@ int Query(char *dev)
         * whether it is an md device and whether it has
         * a superblock
         */
-       int fd = open(dev, O_RDONLY, 0);
+       int fd = open(dev, O_RDONLY);
        int vers;
        int ioctlerr;
        int superror, superrno;
index 9926dde29404a125cae306fa9eca415804d612ea..b0d87b8362e7ceee98571d7ae9ceff12f71ba526 100644 (file)
@@ -57,7 +57,7 @@ mapping_t pers[] = {
 /* from mdopen.c */
 int open_mddev(char *dev, int autof/*unused */)
 {
-       int mdfd = open(dev, O_RDWR, 0);
+       int mdfd = open(dev, O_RDWR);
        if (mdfd < 0)
                fprintf(stderr, Name ": error opening %s: %s\n",
                        dev, strerror(errno));
index 448a9eb85eb49aec091558d1881c8182f41740f9..4fbcb484a21c2e856bdb4067a96a68135b796260 100644 (file)
--- a/mdopen.c
+++ b/mdopen.c
@@ -173,7 +173,7 @@ int open_mddev(char *dev, int autof)
                        must_remove = 1;
                if (stb.st_mode && !must_remove) {
                        /* looks ok, see if it is available */
-                       mdfd = open(dev, O_RDWR, 0);
+                       mdfd = open(dev, O_RDWR);
                        if (mdfd < 0) {
                                fprintf(stderr, Name ": error opening %s: %s\n",
                                        dev, strerror(errno));
@@ -254,7 +254,7 @@ int open_mddev(char *dev, int autof)
                                make_parts(dev,parts, ci->symlinks);
                }
        }
-       mdfd = open(dev, O_RDWR, 0);
+       mdfd = open(dev, O_RDWR);
        if (mdfd < 0)
                fprintf(stderr, Name ": error opening %s: %s\n",
                        dev, strerror(errno));