From: Eric Sandeen Date: Thu, 10 Mar 2022 14:11:04 +0000 (-0500) Subject: xfs_quota: don't exit on fs_table_insert_project_path failure X-Git-Tag: v5.15.0-rc1~3 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=c10023e4f85916dbb9f77c365dbc4f2577b77348;p=thirdparty%2Fxfsprogs-dev.git xfs_quota: don't exit on fs_table_insert_project_path failure 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 Reviewed-by: Darrick J. Wong [sandeen: move fprintf to caller per request] Signed-off-by: Eric Sandeen --- diff --git a/libfrog/paths.c b/libfrog/paths.c index d67937642..abb29a237 100644 --- a/libfrog/paths.c +++ b/libfrog/paths.c @@ -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; } diff --git a/libfrog/paths.h b/libfrog/paths.h index c08e37333..f20a2c3ef 100644 --- a/libfrog/paths.h +++ b/libfrog/paths.h @@ -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); diff --git a/quota/project.c b/quota/project.c index 03ae10d18..adb26945f 100644 --- a/quota/project.c +++ b/quota/project.c @@ -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;