diff mbox

[RFC] Move all btrfs command to only one command

Message ID AANLkTimyQAgs6Hkhsein_m6iXZMGXK-q6snRmR2V_h=o@mail.gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

James Smith Aug. 19, 2010, 8:52 p.m. UTC
None
diff mbox

Patch

diff --git a/btrfs.c b/btrfs.c
index 4d263c4..3418837 100644
--- a/btrfs.c
+++ b/btrfs.c
@@ -44,52 +44,52 @@  static struct Command commands[] = {
 		avoid short commands different for the case only
 	*/
 	{ do_clone, 2,
-	  "subvolume snapshot", "<source> [<dest>/]<name>\n"
-		"Create a writable snapshot of the subvolume <source> with\n"
-		"the name <name> in the <dest> directory."
+	  "subvolume snapshot", "<Source> [<Dest>/]<Name>\n"
+		"Create a writable snapshot of the subvolume <Source> with\n"
+		"the name <Name> in the <Dest> directory."
 	},
 	{ do_delete_subvolume, 1,
-	  "subvolume delete", "<subvolume>\n"
-		"Delete the subvolume <subvolume>."
+	  "subvolume delete", "<Subvolume>\n"
+		"Delete the subvolume <Subvolume>."
 	},
 	{ do_create_subvol, 1,
-	  "subvolume create", "[<dest>/]<name>\n"
-		"Create a subvolume in <dest> (or the current directory if\n"
+	  "subvolume create", "[<Dest>/]<Name>\n"
+		"Create a subvolume in <Dest> (or the current directory if\n"
 		"not passed)."
 	},
 	{ do_defrag, -1,
-	  "filesystem defragment", "<file>|<dir> [<file>|<dir>...]\n"
+	  "filesystem defragment", "<File>|<Dir> [<File>|<Dir>...]\n"
 		"Defragment a file or a directory."
 	},
 	{ do_fssync, 1,
-	  "filesystem sync", "<path>\n"
-		"Force a sync on the filesystem <path>."
+	  "filesystem sync", "<Path>\n"
+		"Force a sync on the filesystem <Path>."
 	},
 	{ do_resize, 2,
-	  "filesystem resize", "[+/-]<newsize>[gkm]|max <filesystem>\n"
+	  "filesystem resize", "[+/-]<Newsize>[gkm]|max <Filesystem>\n"
 		"Resize the file system. If 'max' is passed, the filesystem\n"
-		"will occupe all available space on the device."
+		"will occupy all available space on the device."
 	},
 	{ do_show_filesystem, 999,
-	  "filesystem show", "[<uuid>|<label>]\n"
-		"Show the info of a btrfs filesystem. If no <uuid> or <label>\n"
-		"is passed, info of all the btrfs filesystem are shown."
+	  "filesystem show", "[<UUID>|<Label>]\n"
+		"Show all info about specific BTRFS filesystems. If no <UUID> or <Label>\n"
+		"is passed, information from all the BTRFS filesystems are shown."
 	},
 	{ do_balance, 1,
-	  "filesystem balance", "<path>\n"
+	  "filesystem balance", "<Path>\n"
 		"Balance the chunks across the device."
 	},
 	{ do_scan,
-	  999, "device scan", "[<device> [<device>..]\n"
-		"Scan all device for or the passed device for a btrfs\n"
+	  999, "device scan", "[<Device> [<Device>..]\n"
+		"Scan all devices or the passed device for a BTRFS\n"
 		"filesystem."
 	},	
 	{ do_add_volume, -1,
-	  "device add", "<dev> [<dev>..] <path>\n"
+	  "device add", "<Device> [<Device>..] <Path>\n"
 		"Add a device to a filesystem."
 	},
 	{ do_remove_volume, -1,
-	  "device delete", "<dev> [<dev>..] <path>\n"
+	  "device delete", "<Device> [<Device>..] <Path>\n"
 		"Remove a device from a filesystem."
 	},
 	/* coming soon
@@ -134,12 +134,13 @@  static void help(char *np)
 {
 	struct Command *cp;
 
-	printf("Usage:\n");
+	printf("VFS-2593 %s\n", BTRFS_BUILD_VERSION);
+	printf("\nNo matter where you go, there you are.\n");
+	printf("\nUsage:\n");
 	for( cp = commands; cp->verb; cp++ )
 		print_help(np, cp);
 
-	printf("\n\t%s help|--help|-h\n\t\tShow the help.\n",np);
-	printf("\n%s\n", BTRFS_BUILD_VERSION);
+	printf("\n\t%s help|--help|-h\n\t\tShow help.\n",np);
 }
 
 static int split_command(char *cmd, char ***commands)
@@ -195,7 +196,7 @@  static int check_ambiguity(struct Command *cmd, char **argv){
 		}
 		if(match){
 			int j;
-			fprintf(stderr, "ERROR: in command '");
+			fprintf(stderr, "ERR-A.11: in command '");
 			for( j = 0 ; j <= i ; j++ )
 				fprintf(stderr, "%s%s",j?" ":"", argv[j+1]);
 			fprintf(stderr, "', '%s' is ambiguous\n",argv[j]);
@@ -291,7 +292,7 @@  static int parse_args(int argc, char **argv,
 	}
 
 	if(!matchcmd){
-		fprintf( stderr, "ERROR: unknow command '%s'\n",argv[1]);
+		fprintf( stderr, "ERR-B.12: unknown command '%s'\n",argv[1]);
 		help(prgname);
 		return -1;
 	}
@@ -301,12 +302,12 @@  static int parse_args(int argc, char **argv,
 
 	/* check the number of argument */
 	if (matchcmd->nargs < 0 && matchcmd->nargs < -*nargs_ ){
-		fprintf(stderr, "ERROR: '%s' requires minimum %d arg(s)\n",
+		fprintf(stderr, "ERR-C.13: '%s' requires minimum %d arg(s)\n",
 			matchcmd->verb, -matchcmd->nargs);
 			return -2;
 	}
 	if(matchcmd->nargs >= 0 && matchcmd->nargs != *nargs_ && matchcmd->nargs != 999 ){
-		fprintf(stderr, "ERROR: '%s' requires %d arg(s)\n",
+		fprintf(stderr, "ERR-D.14: '%s' requires %d arg(s)\n",
 			matchcmd->verb, matchcmd->nargs);
 			return -2;
 	}
diff --git a/btrfs_cmds.c b/btrfs_cmds.c
index e112902..9475ac6 100644
--- a/btrfs_cmds.c
+++ b/btrfs_cmds.c
@@ -128,17 +128,17 @@  int do_clone(int argc, char **argv)
 
 	res = test_issubvolume(subvol);
 	if(res<0){
-		fprintf(stderr, "ERROR: error accessing '%s'\n", subvol);
+		fprintf(stderr, "ERR-A1: Error accessing '%s'\n", subvol);
 		return 12;
 	}
 	if(!res){
-		fprintf(stderr, "ERROR: '%s' is not a subvolume\n", subvol);
+		fprintf(stderr, "ERR-A2: '%s' is not a subvolume\n", subvol);
 		return 13;
 	}
 
 	res = test_isdir(dst);
 	if(res == 0 ){
-		fprintf(stderr, "ERROR: '%s' exists and it is not a directory\n", dst);
+		fprintf(stderr, "ERR-A3: '%s' exists and it is not a directory\n", dst);
 		return 12;
 	}
 
@@ -155,28 +155,28 @@  int do_clone(int argc, char **argv)
 
 	if( !strcmp(newname,".") || !strcmp(newname,"..") ||
 	     strchr(newname, '/') ){
-		fprintf(stderr, "ERROR: uncorrect snapshot name ('%s')\n",
+		fprintf(stderr, "ERR-B1: Uncorrect snapshot name ('%s')\n",
 			newname);
 		return 14;
 	}
 
 	len = strlen(newname);
 	if (len == 0 || len >= BTRFS_VOL_NAME_MAX) {
-		fprintf(stderr, "ERROR: snapshot name too long ('%s)\n",
+		fprintf(stderr, "ERR-B2: Snapshot name too long ('%s)\n",
 			newname);
 		return 14;
 	}
 
 	fddst = open_file_or_dir(dstdir);
 	if (fddst < 0) {
-		fprintf(stderr, "ERROR: can't access to '%s'\n", dstdir);
+		fprintf(stderr, "ERR-B3: Can't access to '%s'\n", dstdir);
 		return 12;
 	}
 
 	fd = open_file_or_dir(subvol);
 	if (fd < 0) {
 		close(fddst);
-		fprintf(stderr, "ERROR: can't access to '%s'\n", dstdir);
+		fprintf(stderr, "ERR-B4: Can't access to '%s'\n", dstdir);
 		return 12;
 	}
 
@@ -190,7 +190,7 @@  int do_clone(int argc, char **argv)
 	close(fddst);
 
 	if(res < 0 ){
-		fprintf( stderr, "ERROR: cannot snapshot '%s'\n",subvol);
+		fprintf( stderr, "ERR-B5: Cannot snapshot '%s'\n",subvol);
 		return 11;
 	}
 
@@ -207,11 +207,11 @@  int do_delete_subvolume(int argc, char **argv)
 
 	res = test_issubvolume(path);
 	if(res<0){
-		fprintf(stderr, "ERROR: error accessing '%s'\n", path);
+		fprintf(stderr, "ERR-C1: Error accessing '%s'\n", path);
 		return 12;
 	}
 	if(!res){
-		fprintf(stderr, "ERROR: '%s' is not a subvolume\n", path);
+		fprintf(stderr, "ERR-C2: '%s' is not a subvolume\n", path);
 		return 13;
 	}
 
@@ -224,14 +224,14 @@  int do_delete_subvolume(int argc, char **argv)
 
 	if( !strcmp(vname,".") || !strcmp(vname,"..") ||
 	     strchr(vname, '/') ){
-		fprintf(stderr, "ERROR: uncorrect subvolume name ('%s')\n",
+		fprintf(stderr, "ERR-C3: Incorrect subvolume name ('%s')\n",
 			vname);
 		return 14;
 	}
 
 	len = strlen(vname);
 	if (len == 0 || len >= BTRFS_VOL_NAME_MAX) {
-		fprintf(stderr, "ERROR: snapshot name too long ('%s)\n",
+		fprintf(stderr, "ERR-C4: Snapshot name too long ('%s)\n",
 			vname);
 		return 14;
 	}
@@ -239,7 +239,7 @@  int do_delete_subvolume(int argc, char **argv)
 	fd = open_file_or_dir(dname);
 	if (fd < 0) {
 		close(fd);
-		fprintf(stderr, "ERROR: can't access to '%s'\n", dname);
+		fprintf(stderr, "ERR-C5: Can't access to '%s'\n", dname);
 		return 12;
 	}
 
@@ -250,7 +250,7 @@  int do_delete_subvolume(int argc, char **argv)
 	close(fd);
 
 	if(res < 0 ){
-		fprintf( stderr, "ERROR: cannot delete '%s/%s'\n",dname, vname);
+		fprintf( stderr, "ERR-C6: Cannot delete '%s/%s'\n",dname, vname);
 		return 11;
 	}
 
@@ -268,7 +268,7 @@  int do_create_subvol(int argc, char **argv)
 
 	res = test_isdir(dst);
 	if(res >= 0 ){
-		fprintf(stderr, "ERROR: '%s' exists\n", dst);
+		fprintf(stderr, "ERR-D1: '%s' exists\n", dst);
 		return 12;
 	}
 
@@ -279,21 +279,21 @@  int do_create_subvol(int argc, char **argv)
 
 	if( !strcmp(newname,".") || !strcmp(newname,"..") ||
 	     strchr(newname, '/') ){
-		fprintf(stderr, "ERROR: uncorrect subvolume name ('%s')\n",
+		fprintf(stderr, "ERR-D2: Incorrect subvolume name ('%s')\n",
 			newname);
 		return 14;
 	}
 	
 	len = strlen(newname);
 	if (len == 0 || len >= BTRFS_VOL_NAME_MAX) {
-		fprintf(stderr, "ERROR: subvolume name too long ('%s)\n",
+		fprintf(stderr, "ERR-D3: Subvolume name too long ('%s)\n",
 			newname);
 		return 14;
 	}
 
 	fddst = open_file_or_dir(dstdir);
 	if (fddst < 0) {
-		fprintf(stderr, "ERROR: can't access to '%s'\n", dstdir);
+		fprintf(stderr, "ERR-D4: Can't access to '%s'\n", dstdir);
 		return 12;
 	}
 
@@ -304,7 +304,7 @@  int do_create_subvol(int argc, char **argv)
 	close(fddst);
 
 	if(res < 0 ){
-		fprintf( stderr, "ERROR: cannot create subvolume\n");
+		fprintf( stderr, "ERR-D5: Cannot create subvolume\n");
 		return 11;
 	}
 
@@ -319,7 +319,7 @@  int do_fssync(int argc, char **argv)
 
 	fd = open_file_or_dir(path);
 	if (fd < 0) {
-		fprintf(stderr, "ERROR: can't access to '%s'\n", path);
+		fprintf(stderr, "ERR-D6: Can't access to '%s'\n", path);
 		return 12;
 	}
 
@@ -327,7 +327,7 @@  int do_fssync(int argc, char **argv)
 	res = ioctl(fd, BTRFS_IOC_SYNC);
 	close(fd);
 	if( res < 0 ){
-		fprintf(stderr, "ERROR: unable to fs-syncing '%s'\n", path);
+		fprintf(stderr, "ERR-D7: Unable to drop-sync '%s'\n", path);
 		return 16;
 	}
 
@@ -343,7 +343,7 @@  int do_scan(int nargs, char **argv)
 		printf("Scanning for Btrfs filesystems\n");
 		ret = btrfs_scan_one_dir("/dev", 1);
 		if (ret){
-			fprintf(stderr, "ERROR: error %d while scanning\n", ret);
+			fprintf(stderr, "ERR-E1: Error %d while scanning\n", ret);
 			return 18;
 		}
 		return 0;
@@ -351,7 +351,7 @@  int do_scan(int nargs, char **argv)
 
 	fd = open("/dev/btrfs-control", O_RDWR);
 	if (fd < 0) {
-		perror("failed to open /dev/btrfs-control");
+		perror("ERR-E2: Failed to open /dev/btrfs-control");
 		return 10;
 	}
 
@@ -371,7 +371,7 @@  int do_scan(int nargs, char **argv)
 
 		if( ret < 0 ){
 			close(fd);
-			fprintf(stderr, "ERROR: unable to scan the device '%s'\n", argv[i]);
+			fprintf(stderr, "ERR-E3: Unable to scan the device '%s'\n", argv[i]);
 			return 11;
 		}
 	}
@@ -391,7 +391,7 @@  int do_defrag(int argc, char **argv)
 		char	*path = argv[i];
 		fd = open_file_or_dir(path);
 		if (fd < 0) {
-			fprintf(stderr, "ERROR: can't access to '%s'\n", path);
+			fprintf(stderr, "ERR-F1: Can't access to '%s'\n", path);
 			ret++;
 			continue;
 		}
@@ -400,7 +400,7 @@  int do_defrag(int argc, char **argv)
 		res = ioctl(fd, BTRFS_IOC_DEFRAG);
 		close(fd);
 		if( res < 0 ){
-			fprintf(stderr, "ERROR: unable to defrag '%s'\n", argv[i]);
+			fprintf(stderr, "ERR-F2: Unable to defragment '%s'\n", argv[i]);
 			ret++;
 			continue;
 		}
@@ -423,22 +423,22 @@  int do_resize(int argc, char **argv)
 	
 	fd = open_file_or_dir(path);
 	if (fd < 0) {
-		fprintf(stderr, "ERROR: can't access to '%s'\n", path);
+		fprintf(stderr, "ERR-G1: Can't access to '%s'\n", path);
 		return 12;
 	}
 	len = strlen(amount);
 	if (len == 0 || len >= BTRFS_VOL_NAME_MAX) {
-		fprintf(stderr, "ERROR: size value too long ('%s)\n",
+		fprintf(stderr, "ERR-G2: Size value too long ('%s)\n",
 			amount);
 		return 14;
 	}
 
-	printf("Resize '%s' of '%s'\n", path, amount);
+	printf("Resizing '%s' of '%s'\n", path, amount);
 	strcpy(args.name, amount);
 	res = ioctl(fd, BTRFS_IOC_RESIZE, &args);
 	close(fd);
 	if( res < 0 ){
-		fprintf(stderr, "ERROR: unable to resize '%s'\n", path);
+		fprintf(stderr, "ERR-G3: Unable to resize '%s'\n", path);
 		return 30;
 	}
 	return 0;
@@ -497,7 +497,7 @@  static void print_one_uuid(struct btrfs_fs_devices *fs_devices)
 		devs_found++;
 	}
 	if (devs_found < total) {
-		printf("\t*** Some devices missing\n");
+		printf("\t *** Some devices missing\n");
 	}
 	printf("\n");
 }
@@ -512,7 +512,7 @@  int do_show_filesystem(int argc, char **argv)
 
 	ret = btrfs_scan_one_dir("/dev", 0);
 	if (ret){
-		fprintf(stderr, "ERROR: error %d while scanning\n", ret);
+		fprintf(stderr, "ERR-H1: Error %d while scanning\n", ret);
 		return 18;
 	}
 
@@ -537,7 +537,7 @@  int do_add_volume(int nargs, char **args)
 
 	fdmnt = open_file_or_dir(mntpnt);
 	if (fdmnt < 0) {
-		fprintf(stderr, "ERROR: can't access to '%s'\n", mntpnt);
+		fprintf(stderr, "ERR-I1: Can't access to '%s'\n", mntpnt);
 		return 12;
 	}
 
@@ -549,20 +549,20 @@  int do_add_volume(int nargs, char **args)
 
 		devfd = open(args[i], O_RDWR);
 		if (!devfd) {
-			fprintf(stderr, "ERROR: Unable to open device '%s'\n", args[i]);
+			fprintf(stderr, "ERR-I2: Unable to open device '%s'\n", args[i]);
 			close(devfd);
 			ret++;
 			continue;
 		}
 		ret = fstat(devfd, &st);
 		if (ret) {
-			fprintf(stderr, "ERROR: Unable to stat '%s'\n", args[i]);
+			fprintf(stderr, "ERR-I3: Unable to stat '%s'\n", args[i]);
 			close(devfd);
 			ret++;
 			continue;
 		}
 		if (!S_ISBLK(st.st_mode)) {
-			fprintf(stderr, "ERROR: '%s' is not a block device\n", args[i]);
+			fprintf(stderr, "ERR-I4: '%s' is not a block device\n", args[i]);
 			close(devfd);
 			ret++;
 			continue;
@@ -570,7 +570,7 @@  int do_add_volume(int nargs, char **args)
 
 		res = btrfs_prepare_device(devfd, args[i], 1, &dev_block_count);
 		if (ret) {
-			fprintf(stderr, "ERROR: Unable to init '%s'\n", args[i]);
+			fprintf(stderr, "ERR-I5: Unable to init '%s'\n", args[i]);
 			close(devfd);
 			ret++;
 			continue;
@@ -580,7 +580,7 @@  int do_add_volume(int nargs, char **args)
 		strcpy(ioctl_args.name, args[i]);
 		res = ioctl(fdmnt, BTRFS_IOC_ADD_DEV, &ioctl_args);
 		if(res<0){
-			fprintf(stderr, "ERROR: error adding the device '%s'\n", args[i]);
+			fprintf(stderr, "ERR-I6: Error adding the device '%s'\n", args[i]);
 			ret++;
 		}
 
@@ -602,14 +602,14 @@  int do_balance(int argc, char **argv)
 
 	fdmnt = open_file_or_dir(path);
 	if (fdmnt < 0) {
-		fprintf(stderr, "ERROR: can't access to '%s'\n", path);
+		fprintf(stderr, "ERR-J1: Can't access to '%s'\n", path);
 		return 12;
 	}
 
 	ret = ioctl(fdmnt, BTRFS_IOC_BALANCE);
 	close(fdmnt);
 	if(ret<0){
-		fprintf(stderr, "ERROR: balancing '%s'\n", path);
+		fprintf(stderr, "ERR-J2: Balancing '%s'\n", path);
 
 		return 19;
 	}
@@ -623,7 +623,7 @@  int do_remove_volume(int nargs, char **args)
 
 	fdmnt = open_file_or_dir(mntpnt);
 	if (fdmnt < 0) {
-		fprintf(stderr, "ERROR: can't access to '%s'\n", mntpnt);
+		fprintf(stderr, "ERR-K1: Can't access to '%s'\n", mntpnt);
 		return 12;
 	}
 
@@ -634,7 +634,7 @@  int do_remove_volume(int nargs, char **args)
 		strcpy(arg.name, args[i]);
 		res = ioctl(fdmnt, BTRFS_IOC_RM_DEV, &arg);
 		if(res<0){
-			fprintf(stderr, "ERROR: error removing the device '%s'\n", args[i]);
+			fprintf(stderr, "ERR-K2: Error removing the device '%s'\n", args[i]);
 			ret++;
 		}
 	}