diff mbox

[5/9] xfs_spaceman: print a nicer message when the file path isn't on an xfs

Message ID 152401956294.13048.1815463748899965760.stgit@magnolia (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Darrick J. Wong April 18, 2018, 2:46 a.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

If the file path passed in is not something on an xfs filesystem, print
a nice message about that instead of yelling about ioctls.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 spaceman/file.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)



--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Eric Sandeen May 3, 2018, 8:57 p.m. UTC | #1
On 4/17/18 9:46 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> If the file path passed in is not something on an xfs filesystem, print
> a nice message about that instead of yelling about ioctls.

Assumes that -ENOTTY is the only possible error though...

Maybe:

if (errno == ENOTTY)
	printf("nice thing")
else
	perror("XFS_IOC_FSGEOMETRY");

?

Not a lot else that should go wrong today (EFAULT?) but assuming only
one thing could go wrong seems wrong.

> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  spaceman/file.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> 
> diff --git a/spaceman/file.c b/spaceman/file.c
> index 4c13b4a..4f9f66c 100644
> --- a/spaceman/file.c
> +++ b/spaceman/file.c
> @@ -69,7 +69,8 @@ openfile(
>  	}
>  
>  	if (ioctl(fd, XFS_IOC_FSGEOMETRY, geom) < 0) {
> -		perror("XFS_IOC_FSGEOMETRY");
> +		fprintf(stderr, _("%s: Not on a mounted XFS filesystem.\n"),
> +				path);
>  		close(fd);
>  		return -1;
>  	}
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/spaceman/file.c b/spaceman/file.c
index 4c13b4a..4f9f66c 100644
--- a/spaceman/file.c
+++ b/spaceman/file.c
@@ -69,7 +69,8 @@  openfile(
 	}
 
 	if (ioctl(fd, XFS_IOC_FSGEOMETRY, geom) < 0) {
-		perror("XFS_IOC_FSGEOMETRY");
+		fprintf(stderr, _("%s: Not on a mounted XFS filesystem.\n"),
+				path);
 		close(fd);
 		return -1;
 	}