|
|
564d46 |
|
|
|
564d46 |
|
|
|
564d46 |
If a special file (block, char, pipe etc) resides on an
|
|
|
564d46 |
xfs filesystem, platform_test_xfs_[fd|path] will return
|
|
|
564d46 |
true, but a subsequent xfsctl will fail, because the file
|
|
|
564d46 |
operations to support the xfs ioctls are not set up on such
|
|
|
564d46 |
files (see i_fop assignments in xfs_setup_inode()).
|
|
|
564d46 |
|
|
|
564d46 |
From the xfsctl manpage it's pretty clear that these functions
|
|
|
564d46 |
are supposed to return true iff a subsequent xfsctl can be
|
|
|
564d46 |
handled, so it makes sense to exclude special files.
|
|
|
564d46 |
|
|
|
564d46 |
This was showing up in xfstest generic/306, which creates
|
|
|
564d46 |
the dev/null block device on an xfstest an tries to pwrite
|
|
|
564d46 |
to it with xfs_io - which emitted a warning when the xfsctl
|
|
|
564d46 |
trying to get geometry failed.
|
|
|
564d46 |
|
|
|
564d46 |
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
|
|
|
564d46 |
Reviewed-by: Christoph Hellwig <hch@lst.de>
|
|
|
564d46 |
---
|
|
|
564d46 |
|
|
|
564d46 |
diff --git a/include/linux.h b/include/linux.h
|
|
|
564d46 |
index 5bb91cd..502fd1f 100644
|
|
|
564d46 |
--- a/include/linux.h
|
|
|
564d46 |
+++ b/include/linux.h
|
|
|
564d46 |
@@ -34,20 +34,38 @@ static __inline__ int xfsctl(const char *path, int fd, int cmd, void *p)
|
|
|
564d46 |
return ioctl(fd, cmd, p);
|
|
|
564d46 |
}
|
|
|
564d46 |
|
|
|
564d46 |
+/*
|
|
|
564d46 |
+ * platform_test_xfs_*() implies that xfsctl will succeed on the file;
|
|
|
564d46 |
+ * on Linux, at least, special files don't get xfs file ops,
|
|
|
564d46 |
+ * so return 0 for those
|
|
|
564d46 |
+ */
|
|
|
564d46 |
+
|
|
|
564d46 |
static __inline__ int platform_test_xfs_fd(int fd)
|
|
|
564d46 |
{
|
|
|
564d46 |
- struct statfs buf;
|
|
|
564d46 |
- if (fstatfs(fd, &buf) < 0)
|
|
|
564d46 |
+ struct statfs statfsbuf;
|
|
|
564d46 |
+ struct stat statbuf;
|
|
|
564d46 |
+
|
|
|
564d46 |
+ if (fstatfs(fd, &statfsbuf) < 0)
|
|
|
564d46 |
+ return 0;
|
|
|
564d46 |
+ if (fstat(fd, &statbuf) < 0)
|
|
|
564d46 |
return 0;
|
|
|
564d46 |
- return (buf.f_type == 0x58465342); /* XFSB */
|
|
|
564d46 |
+ if (!S_ISREG(statbuf.st_mode) && !S_ISDIR(statbuf.st_mode))
|
|
|
564d46 |
+ return 0;
|
|
|
564d46 |
+ return (statfsbuf.f_type == 0x58465342); /* XFSB */
|
|
|
564d46 |
}
|
|
|
564d46 |
|
|
|
564d46 |
static __inline__ int platform_test_xfs_path(const char *path)
|
|
|
564d46 |
{
|
|
|
564d46 |
- struct statfs buf;
|
|
|
564d46 |
- if (statfs(path, &buf) < 0)
|
|
|
564d46 |
+ struct statfs statfsbuf;
|
|
|
564d46 |
+ struct stat statbuf;
|
|
|
564d46 |
+
|
|
|
564d46 |
+ if (statfs(path, &statfsbuf) < 0)
|
|
|
564d46 |
+ return 0;
|
|
|
564d46 |
+ if (stat(path, &statbuf) < 0)
|
|
|
564d46 |
+ return 0;
|
|
|
564d46 |
+ if (!S_ISREG(statbuf.st_mode) && !S_ISDIR(statbuf.st_mode))
|
|
|
564d46 |
return 0;
|
|
|
564d46 |
- return (buf.f_type == 0x58465342); /* XFSB */
|
|
|
564d46 |
+ return (statfsbuf.f_type == 0x58465342); /* XFSB */
|
|
|
564d46 |
}
|
|
|
564d46 |
|
|
|
564d46 |
static __inline__ int platform_fstatfs(int fd, struct statfs *buf)
|
|
|
564d46 |
|
|
|
564d46 |
_______________________________________________
|
|
|
564d46 |
xfs mailing list
|
|
|
564d46 |
xfs@oss.sgi.com
|
|
|
564d46 |
http://oss.sgi.com/mailman/listinfo/xfs
|
|
|
564d46 |
|
|
|
564d46 |
|