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 <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>
diff --git a/libfrog/paths.c b/libfrog/paths.c
index d679376..abb29a2 100644
--- a/libfrog/paths.c
+++ b/libfrog/paths.c
@@ -546,7 +546,7 @@
progname, strerror(error));
}
-void
+int
fs_table_insert_project_path(
char *dir,
prid_t prid)
@@ -561,9 +561,5 @@
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 c08e373..f20a2c3 100644
--- a/libfrog/paths.h
+++ b/libfrog/paths.h
@@ -40,7 +40,7 @@
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 03ae10d..adb2694 100644
--- a/quota/project.c
+++ b/quota/project.c
@@ -267,7 +267,7 @@
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 @@
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;