]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
Prevent project commands from operating on special files.
authorDonald Douwsma <donaldd@sgi.com>
Thu, 17 May 2007 15:57:27 +0000 (15:57 +0000)
committerDonald Douwsma <donaldd@sgi.com>
Thu, 17 May 2007 15:57:27 +0000 (15:57 +0000)
Merge of master-melb:xfs-cmds:28597a by kenmcd.

doc/CHANGES
quota/project.c

index 3d7e8c8b813119327b6ffb1e5dd8e7172c65e5e0..9517afe2da59b3bce12e59cf6976292204442321 100644 (file)
@@ -1,3 +1,7 @@
+xfsprogs-2.8.21
+       - Fix xfs_quota project command to stop it operating on speical files. 
+         Thanks to Leo Baltus.
+
 xfsprogs-2.8.20 (23 February 2007)
        - Fix xfs_repair not detecting invalid btree root in inodes.
        - Fix xfs_repair restoring corrupted superblock after repairing it.
index 6eae4dff2a194839a92bc4897a8a75c22fa1dd1f..e2e61c37bc9ad5596f0b9468443589b6283a0027 100644 (file)
@@ -30,6 +30,13 @@ enum {
        CLEAR_PROJECT   = 0x4,
 };
 
+#define EXCLUDED_FILE_TYPES(x) \
+          S_ISCHR((x)) \
+       || S_ISBLK((x)) \
+       || S_ISFIFO((x)) \
+       || S_ISLNK((x)) \
+       || S_ISSOCK((x))
+
 static void
 project_help(void)
 {
@@ -77,12 +84,21 @@ static int
 check_project(
        const char              *path,
        const struct stat       *stat,
-       int                     status,
+       int                     flag,
        struct FTW              *data)
 {
        struct fsxattr          fsx;
        int                     fd;
 
+       if (flag == FTW_NS ){
+               fprintf(stderr, _("%s: cannot stat file %s\n"), progname, path);
+               return 0;
+       }
+       if (EXCLUDED_FILE_TYPES(stat->st_mode)) {
+               fprintf(stderr, _("%s: skipping special file %s\n"), progname, path);
+               return 0;
+       }
+
        if ((fd = open(path, O_RDONLY|O_NOCTTY)) == -1)
                fprintf(stderr, _("%s: cannot open %s: %s\n"),
                        progname, path, strerror(errno));
@@ -107,12 +123,21 @@ static int
 clear_project(
        const char              *path,
        const struct stat       *stat,
-       int                     status,
+       int                     flag,
        struct FTW              *data)
 {
        struct fsxattr          fsx;
        int                     fd;
 
+       if (flag == FTW_NS ){
+               fprintf(stderr, _("%s: cannot stat file %s\n"), progname, path);
+               return 0;
+       }
+       if (EXCLUDED_FILE_TYPES(stat->st_mode)) {
+               fprintf(stderr, _("%s: skipping special file %s\n"), progname, path);
+               return 0;
+       }
+
        if ((fd = open(path, O_RDONLY|O_NOCTTY)) == -1) {
                fprintf(stderr, _("%s: cannot open %s: %s\n"),
                        progname, path, strerror(errno));
@@ -137,12 +162,21 @@ static int
 setup_project(
        const char              *path,
        const struct stat       *stat,
-       int                     status,
+       int                     flag,
        struct FTW              *data)
 {
        struct fsxattr          fsx;
        int                     fd;
 
+       if (flag == FTW_NS ){
+               fprintf(stderr, _("%s: cannot stat file %s\n"), progname, path);
+               return 0;
+       }
+       if (EXCLUDED_FILE_TYPES(stat->st_mode)) {
+               fprintf(stderr, _("%s: skipping special file %s\n"), progname, path);
+               return 0;
+       }
+
        if ((fd = open(path, O_RDONLY|O_NOCTTY)) == -1) {
                fprintf(stderr, _("%s: cannot open %s: %s\n"),
                        progname, path, strerror(errno));