Skip to contentSkip to conversation

Improve error handling in filesystem df

PATCH In review Ben Gamari 2 participants 2 messages Dec 19, 2010 – Dec 20, 2010 Btrfs file system

lore
Share & tools
lore

Ben Gamari

author
#0 lore raw

PATCH 1/1 Improve error handling in filesystem df

The return values of ioctl weren't being printed to stderr on failure, causing the command to silently fail, resulting in a very confused user.

---
 btrfs_cmds.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
btrfs_cmds.c +2 -0
index 8031c58..45da2bd 100644
@@ -857,6 +857,7 @@ int do_df_filesystem(int nargs, char **argv)
 
 	ret = ioctl(fd, BTRFS_IOC_SPACE_INFO, sargs);
 	if (ret) {
+		fprintf(stderr, "ERROR: can't query '%s' for free space (%s)\n", path, strerror(-ret));
 		free(sargs);
 		return ret;
 	}
@@ -875,6 +876,7 @@ int do_df_filesystem(int nargs, char **argv)
 
 	ret = ioctl(fd, BTRFS_IOC_SPACE_INFO, sargs);
 	if (ret) {
+		fprintf(stderr, "ERROR: can't query '%s' for free space (%s)\n", path, strerror(-ret));
 		free(sargs);
 		return ret;
 	}
Signature · 1 line
1.7.1
#1 lore raw

Hi Ben,

I integrated your patch on the my one (see my next email). However I changed the argument of the strerror function from the ioctl return code to the errno variable.

Regards
G.Baroncelli

Quoted 14 lines · Ben Gamari

The return values of ioctl weren't being printed to stderr on failure, causing the command to silently fail, resulting in a very confused user.

---
 btrfs_cmds.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
btrfs_cmds.c +0 -0
index 8031c58..45da2bd 100644

btrfs_cmds.c int do_df_filesystem(int nargs, char **argv) · line 860

Quoted 4 lines
btrfs_cmds.c +1 -0
@@ -857,6 +857,7 @@ int do_df_filesystem(int nargs, char **argv)
 
 	ret = ioctl(fd, BTRFS_IOC_SPACE_INFO, sargs);
 	if (ret) {
+		fprintf(stderr, "ERROR: can't query '%s' for free space 

(%s)\n", path, strerror(-ret));

btrfs_cmds.c int do_df_filesystem(int nargs, char **argv) · line 879

Quoted 8 lines
btrfs_cmds.c +1 -0
 		free(sargs);
 		return ret;
 	}
@@ -875,6 +876,7 @@ int do_df_filesystem(int nargs, char **argv)
 
 	ret = ioctl(fd, BTRFS_IOC_SPACE_INFO, sargs);
 	if (ret) {
+		fprintf(stderr, "ERROR: can't query '%s' for free space 

(%s)\n", path, strerror(-ret));

Quoted 11 lines
btrfs_cmds.c +0 -0
 		free(sargs);
 		return ret;
 	}
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <[email protected]>
Key fingerprint = 4769 7E51 5293 D36C 814E  C054 BF04 F161 3DC5 0512