From: Tim Shimmin Date: Mon, 4 Jul 2005 06:00:09 +0000 (+0000) Subject: Get libhandle working on IRIX for qa. Put back fd_to_handle. X-Git-Tag: v2.7.0~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8967ee43817f33e23a11058cac11ac7f32b7ae12;p=thirdparty%2Fxfsprogs-dev.git Get libhandle working on IRIX for qa. Put back fd_to_handle. Merge of master-melb:xfs-cmds:23053a by kenmcd. --- diff --git a/VERSION b/VERSION index 67985537a..e5f2789ed 100644 --- a/VERSION +++ b/VERSION @@ -3,5 +3,5 @@ # PKG_MAJOR=2 PKG_MINOR=6 -PKG_REVISION=34 +PKG_REVISION=35 PKG_BUILD=1 diff --git a/doc/CHANGES b/doc/CHANGES index 87c1054a1..73126e66d 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,3 +1,7 @@ +xfsprogs-2.6.35 (1 July 2005) + - Add back fd_to_handle() to libhandle. + - Add handle call mappings to xfsctl() for IRIX. + xfsprogs-2.6.34 (20 June 2005) - Switch to the fsxattr xfsctl for getting/setting project identifiers on inodes, remove the short-lived specialised diff --git a/include/irix.h b/include/irix.h index a263359e7..fd01c2d13 100644 --- a/include/irix.h +++ b/include/irix.h @@ -59,8 +59,8 @@ #define __s64 __int64_t #define __u8 unsigned char #define __u16 unsigned short -#define __u32 __int32_t -#define __u64 __int64_t +#define __u32 __uint32_t +#define __u64 __uint64_t #define __int8_t char #define __int16_t short #define __uint8_t unsigned char @@ -76,18 +76,62 @@ typedef char* xfs_caddr_t; #define xfs_flock64_t struct flock64 typedef struct xfs_error_injection { - __int32_t fd; - __int32_t errtag; + __int32_t fd; + __int32_t errtag; } xfs_error_injection_t; +/* --- xfs_fsop_*req - request data structures --- */ typedef struct xfs_fsop_bulkreq { - ino64_t *lastip; - __int32_t icount; - xfs_bstat_t *ubuffer; - __int32_t *ocount; + ino64_t *lastip; + __int32_t icount; + xfs_bstat_t *ubuffer; + __int32_t *ocount; } xfs_fsop_bulkreq_t; +typedef struct xfs_fsop_handlereq { + __u32 fd; /* fd for FD_TO_HANDLE */ + void *path; /* user pathname */ + __u32 oflags; /* open flags */ + void *ihandle; /* user supplied handle */ + __u32 ihandlen; /* user supplied length */ + void *ohandle; /* user buffer for handle */ + __u32 *ohandlen; /* user buffer length */ +} xfs_fsop_handlereq_t; + +typedef struct xfs_fsop_setdm_handlereq { + struct xfs_fsop_handlereq hreq; /* handle information */ + struct fsdmidata *data; /* DMAPI data */ +} xfs_fsop_setdm_handlereq_t; + +typedef struct xfs_attrlist_cursor { + __u32 opaque[4]; +} xfs_attrlist_cursor_t; + +typedef struct xfs_fsop_attrlist_handlereq { + struct xfs_fsop_handlereq hreq; /* handle interface structure */ + struct xfs_attrlist_cursor pos; /* opaque cookie, list offset */ + __u32 flags; /* which namespace to use */ + __u32 buflen; /* length of buffer supplied */ + void *buffer; /* returned names */ +} xfs_fsop_attrlist_handlereq_t; + +typedef struct xfs_attr_multiop { + __u32 am_opcode; + __s32 am_error; + void *am_attrname; + void *am_attrvalue; + __u32 am_length; + __u32 am_flags; +} xfs_attr_multiop_t; + +typedef struct xfs_fsop_attrmulti_handlereq { + struct xfs_fsop_handlereq hreq; /* handle interface structure */ + __u32 opcount;/* count of following multiop */ + struct xfs_attr_multiop *ops; /* attr_multi data */ +} xfs_fsop_attrmulti_handlereq_t; + + #include #define __BYTE_ORDER BYTE_ORDER #define __BIG_ENDIAN BIG_ENDIAN @@ -104,6 +148,7 @@ typedef struct xfs_fsop_bulkreq { #define constpp char * const * +/*ARGSUSED*/ static __inline__ int xfsctl(const char *path, int fd, int cmd, void *arg) { if (cmd >= 0 && cmd < XFS_FSOPS_COUNT) { @@ -120,13 +165,13 @@ static __inline__ int xfsctl(const char *path, int fd, int cmd, void *arg) switch (cmd) { case SGI_FS_INUMBERS: case SGI_FS_BULKSTAT: - return syssgi(cmd, fd, + return syssgi(cmd, fd, ((xfs_fsop_bulkreq_t*)arg)->lastip, ((xfs_fsop_bulkreq_t*)arg)->icount, ((xfs_fsop_bulkreq_t*)arg)->ubuffer, ((xfs_fsop_bulkreq_t*)arg)->ocount); case SGI_FS_BULKSTAT_SINGLE: - return syssgi(SGI_FS_BULKSTAT_SINGLE, fd, + return syssgi(SGI_FS_BULKSTAT_SINGLE, fd, ((xfs_fsop_bulkreq_t*)arg)->lastip, ((xfs_fsop_bulkreq_t*)arg)->ubuffer); case SGI_XFS_INJECT_ERROR: @@ -135,6 +180,48 @@ static __inline__ int xfsctl(const char *path, int fd, int cmd, void *arg) fd); case SGI_XFS_CLEARALL_ERROR: return syssgi(SGI_XFS_CLEARALL_ERROR, fd); + case SGI_PATH_TO_HANDLE: + case SGI_PATH_TO_FSHANDLE: + return syssgi(cmd, + ((xfs_fsop_handlereq_t*)arg)->path, + ((xfs_fsop_handlereq_t*)arg)->ohandle, + ((xfs_fsop_handlereq_t*)arg)->ohandlen); + case SGI_FD_TO_HANDLE: + return syssgi(cmd, + ((xfs_fsop_handlereq_t*)arg)->fd, + ((xfs_fsop_handlereq_t*)arg)->ohandle, + ((xfs_fsop_handlereq_t*)arg)->ohandlen); + case SGI_OPEN_BY_HANDLE: + return syssgi(cmd, + ((xfs_fsop_handlereq_t*)arg)->ihandle, + ((xfs_fsop_handlereq_t*)arg)->ihandlen, + ((xfs_fsop_handlereq_t*)arg)->oflags); + case SGI_READLINK_BY_HANDLE: + return syssgi(cmd, + ((xfs_fsop_handlereq_t*)arg)->ihandle, + ((xfs_fsop_handlereq_t*)arg)->ihandlen, + ((xfs_fsop_handlereq_t*)arg)->ohandle, + ((xfs_fsop_handlereq_t*)arg)->ohandlen); + case SGI_ATTR_LIST_BY_HANDLE: + return syssgi(cmd, + ((xfs_fsop_attrlist_handlereq_t*)arg)->hreq.ihandle, + ((xfs_fsop_attrlist_handlereq_t*)arg)->hreq.ihandlen, + ((xfs_fsop_attrlist_handlereq_t*)arg)->buffer, + ((xfs_fsop_attrlist_handlereq_t*)arg)->buflen, + ((xfs_fsop_attrlist_handlereq_t*)arg)->flags, + &(((xfs_fsop_attrlist_handlereq_t*)arg)->pos)); + case SGI_ATTR_MULTI_BY_HANDLE: + return syssgi(cmd, + ((xfs_fsop_attrmulti_handlereq_t*)arg)->hreq.ihandle, + ((xfs_fsop_attrmulti_handlereq_t*)arg)->hreq.ihandlen, + ((xfs_fsop_attrmulti_handlereq_t*)arg)->ops, + ((xfs_fsop_attrmulti_handlereq_t*)arg)->opcount, + ((xfs_fsop_attrmulti_handlereq_t*)arg)->hreq.oflags); + case SGI_FSSETDM_BY_HANDLE: + return syssgi(cmd, + ((xfs_fsop_setdm_handlereq_t*)arg)->hreq.ihandle, + ((xfs_fsop_setdm_handlereq_t*)arg)->hreq.ihandlen, + ((xfs_fsop_setdm_handlereq_t*)arg)->data); } return fcntl(fd, cmd, arg); } @@ -196,23 +283,23 @@ static __inline__ char * strsep(char **s, const char *ct) #define XFS_IOC_FREESP64 F_FREESP64 #define XFS_IOC_GETBMAP F_GETBMAP #define XFS_IOC_FSSETDM F_FSSETDM -#define XFS_IOC_RESVSP F_RESVSP +#define XFS_IOC_RESVSP F_RESVSP #define XFS_IOC_RESVSP64 F_RESVSP64 -#define XFS_IOC_UNRESVSP F_UNRESVSP +#define XFS_IOC_UNRESVSP F_UNRESVSP #define XFS_IOC_UNRESVSP64 F_UNRESVSP64 #define XFS_IOC_GETBMAPA F_GETBMAPA #define XFS_IOC_FSGETXATTRA F_FSGETXATTRA #define XFS_IOC_GETBMAPX F_GETBMAPX #define XFS_IOC_FSGEOMETRY_V1 XFS_FS_GEOMETRY -#define XFS_IOC_FSBULKSTAT SGI_FS_BULKSTAT +#define XFS_IOC_FSBULKSTAT SGI_FS_BULKSTAT #define XFS_IOC_FSBULKSTAT_SINGLE SGI_FS_BULKSTAT_SINGLE #define XFS_IOC_FSINUMBERS SGI_FS_INUMBERS -#define XFS_IOC_PATH_TO_FSHANDLE /* TODO */ -#define XFS_IOC_PATH_TO_HANDLE /* TODO */ -#define XFS_IOC_FD_TO_HANDLE /* TODO */ -#define XFS_IOC_OPEN_BY_HANDLE /* TODO */ -#define XFS_IOC_READLINK_BY_HANDLE /* TODO */ +#define XFS_IOC_PATH_TO_FSHANDLE SGI_PATH_TO_FSHANDLE +#define XFS_IOC_PATH_TO_HANDLE SGI_PATH_TO_HANDLE +#define XFS_IOC_FD_TO_HANDLE SGI_FD_TO_HANDLE +#define XFS_IOC_OPEN_BY_HANDLE SGI_OPEN_BY_HANDLE +#define XFS_IOC_READLINK_BY_HANDLE SGI_READLINK_BY_HANDLE #define XFS_IOC_SWAPEXT /* TODO */ #define XFS_IOC_FSGROWFSDATA XFS_GROWFS_DATA #define XFS_IOC_FSGROWFSLOG XFS_GROWFS_LOG @@ -224,9 +311,9 @@ static __inline__ char * strsep(char **s, const char *ct) #define XFS_IOC_ERROR_CLEARALL SGI_XFS_CLEARALL_ERROR #define XFS_IOC_FREEZE XFS_FS_FREEZE #define XFS_IOC_THAW XFS_FS_THAW -#define XFS_IOC_FSSETDM_BY_HANDLE /* TODO */ -#define XFS_IOC_ATTRLIST_BY_HANDLE /* TODO */ -#define XFS_IOC_ATTRMULTI_BY_HANDLE /* TODO */ +#define XFS_IOC_FSSETDM_BY_HANDLE SGI_FSSETDM_BY_HANDLE +#define XFS_IOC_ATTRLIST_BY_HANDLE SGI_ATTR_LIST_BY_HANDLE +#define XFS_IOC_ATTRMULTI_BY_HANDLE SGI_ATTR_MULTI_BY_HANDLE #define XFS_IOC_FSGEOMETRY XFS_FS_GEOMETRY #define XFS_IOC_GOINGDOWN XFS_FS_GOINGDOWN diff --git a/libhandle/handle.c b/libhandle/handle.c index f19d8825b..2e8c7e156 100644 --- a/libhandle/handle.c +++ b/libhandle/handle.c @@ -144,6 +144,20 @@ path_to_handle( return result; } + +int +fd_to_handle ( + int fd, /* input, file descriptor */ + void **hanp, /* output, pointer to data */ + size_t *hlen) /* output, size of returned data */ +{ + comarg_t obj; + + obj.fd = fd; + return obj_to_handle(NULL, fd, XFS_IOC_FD_TO_HANDLE, obj, hanp, hlen); +} + + int handle_to_fshandle( void *hanp, @@ -170,6 +184,12 @@ handle_to_fsfd(void *hanp, char **path) { struct fdhash *fdhp; + /* + * Look in cache for matching fsid field in the handle + * (which is at the start of the handle). + * When found return the file descriptor and path that + * we have in the cache. + */ for (fdhp = fdhash_head; fdhp != NULL; fdhp = fdhp->fnxt) { if (memcmp(fdhp->fsh, hanp, FSIDSIZE) == 0) { *path = fdhp->fspath; @@ -302,6 +322,7 @@ readlink_by_handle( return xfsctl(path, fd, XFS_IOC_READLINK_BY_HANDLE, &hreq); } +/*ARGSUSED4*/ int attr_multi_by_handle( void *hanp, @@ -389,6 +410,7 @@ fssetdm_by_handle( return xfsctl(path, fd, XFS_IOC_FSSETDM_BY_HANDLE, &dmhreq); } +/*ARGSUSED1*/ void free_handle( void *hanp, diff --git a/man/man3/handle.3 b/man/man3/handle.3 index 82919a70c..67dbc198a 100644 --- a/man/man3/handle.3 +++ b/man/man3/handle.3 @@ -1,6 +1,6 @@ .TH HANDLE 3 .SH NAME -path_to_handle, path_to_fshandle, handle_to_fshandle, open_by_handle, readlink_by_handle, attr_multi_by_handle, attr_list_by_handle, fssetdm_by_handle, free_handle \- file handle operations +path_to_handle, path_to_fshandle, fd_to_handle, handle_to_fshandle, open_by_handle, readlink_by_handle, attr_multi_by_handle, attr_list_by_handle, fssetdm_by_handle, free_handle \- file handle operations .SH C SYNOPSIS .nf .B #include @@ -12,6 +12,8 @@ path_to_handle, path_to_fshandle, handle_to_fshandle, open_by_handle, readlink_b .B "int path_to_fshandle (char *path, void **hanp," .B " size_t *hlen);" .PP +.B "int fd_to_handle (int fd, void **hanp, size_t *hlen); +.PP .B "int handle_to_fshandle (void *hanp, size_t hlen," .B " void **fshanp, size_t *fshlen); .PP @@ -80,6 +82,12 @@ in which the object given by the .I path argument resides. .P +The \f2fd_to_handle\f1() function +returns the handle for the object referenced by the +.I fd +argument, +which must be a valid file descriptor. +.P The \f2handle_to_fshandle\f1() function returns the handle for the filesystem in which the object referenced by the @@ -124,6 +132,7 @@ frees the storage allocated for handles returned by the following functions: \f2path_to_handle\f1(), \f2path_to_fshandle\f1(), +\f2fd_to_handle\f1(), and \f2handle_to_fshandle\f1(). .SH "SEE ALSO"