]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_quota: don't exit on fs_table_insert_project_path failure
authorEric Sandeen <sandeen@redhat.com>
Thu, 10 Mar 2022 14:11:04 +0000 (09:11 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Thu, 10 Mar 2022 14:11:04 +0000 (09:11 -0500)
If "project -p" fails in fs_table_insert_project_path, it
calls exit() today which is quite unfriendly. Return an error
and return to the command prompt as expected.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
[sandeen: move fprintf to caller per request]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libfrog/paths.c
libfrog/paths.h
quota/project.c

index d6793764298eaa9fa251d1dd543b10b18933ff61..abb29a237e80684ea9541abc9f73c405dedf6858 100644 (file)
@@ -546,7 +546,7 @@ out_error:
                progname, strerror(error));
 }
 
-void
+int
 fs_table_insert_project_path(
        char            *dir,
        prid_t          prid)
@@ -561,9 +561,5 @@ fs_table_insert_project_path(
        else
                error = ENOENT;
 
-       if (error) {
-               fprintf(stderr, _("%s: cannot setup path for project dir %s: %s\n"),
-                               progname, dir, strerror(error));
-               exit(1);
-       }
+       return error;
 }
index c08e37333781a0e050bf3657d5194c75079782cf..f20a2c3ef5828df71282406bc160ccbdd648a5c4 100644 (file)
@@ -40,7 +40,7 @@ extern char *mtab_file;
 extern void fs_table_initialise(int, char *[], int, char *[]);
 extern void fs_table_destroy(void);
 
-extern void fs_table_insert_project_path(char *__dir, uint __projid);
+extern int fs_table_insert_project_path(char *__dir, uint __projid);
 
 
 extern fs_path_t *fs_table_lookup(const char *__dir, uint __flags);
index 03ae10d185769049df2677392adf1e40403c17bc..adb26945fa57bd2cbc07c62dd2e3eb9ad823a3bb 100644 (file)
@@ -267,7 +267,7 @@ project_f(
        int             argc,
        char            **argv)
 {
-       int             c, type = 0, ispath = 0;
+       int             c, type = 0, ispath = 0, error = 0;
 
        while ((c = getopt(argc, argv, "cd:p:sC")) != EOF) {
                switch (c) {
@@ -281,7 +281,13 @@ project_f(
                        break;
                case 'p':
                        ispath = 1;
-                       fs_table_insert_project_path(optarg, -1);
+                       error = fs_table_insert_project_path(optarg, -1);
+                       if (error) {
+                               fprintf(stderr,
+_("%s: cannot setup path for project dir %s: %s\n"),
+                                       progname, optarg, strerror(error));
+                               return 0;
+                       }
                        break;
                case 's':
                        type = SETUP_PROJECT;