* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <xfs/libxfs.h>
-
-/* attributes.h (purposefully) unavailable to xfsprogs, make do */
-struct attrlist_cursor { __u32 opaque[4]; };
-
+#include <xfs/xfs.h>
#include <xfs/handle.h>
+#include <xfs/parent.h>
/* just pick a value we know is more than big enough */
#define MAXHANSIZ 64
char *path, /* input, path to convert */
void **hanp, /* output, pointer to data */
size_t *hlen) /* output, size of returned data */
+{
+ return lpath_to_handle(path, path, hanp, hlen);
+}
+
+/* Like path_to_handle, but reliable for paths which are either dangling
+ * symlinks or symlinks whose targets are not in XFS filesystems.
+ */
+int
+lpath_to_handle(
+ char *fspath, /* input, path in filesystem */
+ char *path, /* input, path to convert */
+ void **hanp, /* output, pointer to data */
+ size_t *hlen) /* output, size of returned data */
{
int fd;
int result;
comarg_t obj;
- fd = open(path, O_RDONLY);
+ fd = open(fspath, O_RDONLY);
if (fd < 0)
return -1;
obj.path = path;
- result = obj_to_handle(path, fd, XFS_IOC_PATH_TO_HANDLE,
+ result = obj_to_handle(fspath, fd, XFS_IOC_PATH_TO_HANDLE,
obj, hanp, hlen);
close(fd);
return result;
int flags,
struct attrlist_cursor *cursor)
{
- int fd;
+ int error, fd;
char *path;
xfs_fsop_attrlist_handlereq_t alhreq;
memcpy(&alhreq.pos, cursor, sizeof(alhreq.pos));
alhreq.flags = flags;
- alhreq.buflen = bufsize;
alhreq.buffer = buf;
+ alhreq.buflen = bufsize;
+ /* prevent needless EINVAL from the kernel */
+ if (alhreq.buflen > XATTR_LIST_MAX)
+ alhreq.buflen = XATTR_LIST_MAX;
+
+ error = xfsctl(path, fd, XFS_IOC_ATTRLIST_BY_HANDLE, &alhreq);
- return xfsctl(path, fd, XFS_IOC_ATTRLIST_BY_HANDLE, &alhreq);
+ memcpy(cursor, &alhreq.pos, sizeof(alhreq.pos));
+ return error;
+}
+
+int
+parents_by_handle(
+ void *hanp,
+ size_t hlen,
+ parent_t *buf,
+ size_t bufsiz,
+ unsigned int *count)
+
+{
+ errno = EOPNOTSUPP;
+ return -1;
+}
+
+int
+parentpaths_by_handle(
+ void *hanp,
+ size_t hlen,
+ parent_t *buf,
+ size_t bufsiz,
+ unsigned int *count)
+{
+ errno = EOPNOTSUPP;
+ return -1;
}
int