[PATCH v2] xfsprogs: (xfs_quota) foreign fs path handling changes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Version 2 of this patch to xfs_quota in order to properly
handle foreign fs mount paths. Note that this version (2)
abandons the incorrect approach of version 1, in which the
fs-table wasn't populated with the foreign fs paths.

Commits b20b6c2 and 29647c8 modified xfs_quota for use on
non-XFS filesystems. Modifications to fs_initialise_mounts
(paths.c) resulted in an xfstest fail (xfs/261), due to foreign
fs paths being picked up from the fs table, and the xfs_quota
print command complaining about not being able to print the
foreign paths.

This patch fixes the foreign path print problem, with a
modification of the print and path commands to always be
allowed, regardless of fs type (similar to the help and quit
commands).

Additionally, the printpath() function in path.c is corrected
to skip printing foreign paths unless the -f flag is thrown
in the xfs_quota invocation. Also, some minor formatting
changes and comment clarifications to the print command are
made.

Signed-off-by: Bill O'Donnell <billodo@xxxxxxxxxx>
---
 quota/init.c | 19 +++++++++++++------
 quota/path.c | 19 ++++++++++++++-----
 2 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/quota/init.c b/quota/init.c
index 44be322..9f95e8f 100644
--- a/quota/init.c
+++ b/quota/init.c
@@ -112,21 +112,28 @@ init_check_command(
 	if (!fs_path)
 		return 1;
 
-	/* Always run commands that we are told to skip here */
+	/* Always run commands that are valid for all fs types. */
 	if (ct->flags & CMD_ALL_FSTYPES)
 		return 1;
 
-	/* if it's an XFS filesystem, always run the command */
+	/* If it's an XFS filesystem, always run the command. */
 	if (!(fs_path->fs_flags & FS_FOREIGN))
 		return 1;
 
-	/* If the user specified foreign filesysetms are ok, run it */
+	/* If the user specified foreign filesystems are ok (-f), run cmd. */
 	if (foreign_allowed &&
-	    (ct->flags & CMD_FLAG_FOREIGN_OK))
+		(ct->flags & CMD_FLAG_FOREIGN_OK))
 		return 1;
 
-	/* foreign filesystem and it's not a valid command! */
-	fprintf(stderr, _("%s command is for XFS filesystems only\n"),
+	/* If cmd not allowed on foreign fs, regardless of -f flag, skip it. */
+	if (!(ct->flags & CMD_FLAG_FOREIGN_OK)) {
+		fprintf(stderr, _("%s: command is for XFS filesystems only\n"),
+		ct->name);
+		return 0;
+	}
+
+	/* foreign fs, but cmd only allowed via -f flag. Skip it. */
+	fprintf(stderr, _("%s: foreign filesystem. Use -f to enable.\n"),
 		ct->name);
 	return 0;
 }
diff --git a/quota/path.c b/quota/path.c
index a623d25..d8f8f3c 100644
--- a/quota/path.c
+++ b/quota/path.c
@@ -36,14 +36,23 @@ printpath(
 	int		c;
 
 	if (index == 0) {
-		printf(_("%sFilesystem          Pathname\n"),
+		printf(_("%s    Filesystem          Pathname\n"),
 			number ? _("      ") : "");
 	}
 	if (number) {
 		printf(_("%c%03d%c "), braces? '[':' ', index, braces? ']':' ');
 	}
-	printf("%s ", (path->fs_flags & FS_FOREIGN) ? "(F)" : "   ");
-	printf(_("%-19s %s"), path->fs_dir, path->fs_name);
+	if (path->fs_flags & FS_FOREIGN) {
+	    if (foreign_allowed) {
+	      printf("(F) ");
+	      printf(_("%-19s %s"), path->fs_dir, path->fs_name);
+	    }
+	}
+	else {
+	      printf("    ");
+	      printf(_("%-19s %s"), path->fs_dir, path->fs_name);
+	}
+
 	if (path->fs_flags & FS_PROJECT_PATH) {
 		prj = getprprid(path->fs_prid);
 		printf(_(" (project %u"), path->fs_prid);
@@ -128,7 +137,7 @@ path_init(void)
 	path_cmd.cfunc = path_f;
 	path_cmd.argmin = 0;
 	path_cmd.argmax = 1;
-	path_cmd.flags = CMD_FLAG_GLOBAL | CMD_FLAG_FOREIGN_OK;
+	path_cmd.flags = CMD_FLAG_GLOBAL | CMD_ALL_FSTYPES;
 	path_cmd.oneline = _("set current path, or show the list of paths");
 
 	print_cmd.name = "print";
@@ -136,7 +145,7 @@ path_init(void)
 	print_cmd.cfunc = print_f;
 	print_cmd.argmin = 0;
 	print_cmd.argmax = 0;
-	print_cmd.flags = CMD_FLAG_GLOBAL | CMD_FLAG_FOREIGN_OK;
+	print_cmd.flags = CMD_FLAG_GLOBAL | CMD_ALL_FSTYPES;
 	print_cmd.oneline = _("list known mount points and projects");
 
 	if (expert)
-- 
2.7.4

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs



[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux