]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
No Message Supplied
authorAndrew Gildfind <ajag@sgi.com>
Fri, 9 Feb 2001 07:45:14 +0000 (07:45 +0000)
committerAndrew Gildfind <ajag@sgi.com>
Fri, 9 Feb 2001 07:45:14 +0000 (07:45 +0000)
include/handle.h
include/jdm.h
include/xfs_fs.h
libhandle/handle.c
libhandle/jdm.c

index 0400a7046efd74e696d9c2d4515c08840859483f..98b16575cc9870eb62be000fee33a3f687e44201 100644 (file)
@@ -41,6 +41,7 @@ extern int  path_to_fshandle (char *__path, void **__hanp, size_t *__hlen);
 extern int  fd_to_handle (int __fd, void **__hanp, size_t *__hlen);
 extern int  handle_to_fshandle (void *__hanp, size_t __hlen, void **__fshanp,
                                size_t *__fshlen);
+extern int  handle_to_fsfd (void *__hanp);
 extern void free_handle (void *__hanp, size_t __hlen);
 extern int  open_by_handle (void *__hanp, size_t __hlen, int __rw);
 extern int  readlink_by_handle (void *__hanp, size_t __hlen, void *__buf,
index 3d20120185795807dcfc4794fd89d83383bc0497..f49140cc96a4b2e5ab1ba787c0cf30256d35824b 100644 (file)
 #define __JDM_H__
 
 typedef int    intgen_t;
-typedef void   jdm_fshandle_t;
+typedef void   jdm_fshandle_t;         /* filesystem handle */
+typedef void   jdm_filehandle_t;       /* filehandle */
 
 struct xfs_bstat;
-extern jdm_fshandle_t *jdm_getfshandle (char *mntpnt);
-extern intgen_t jdm_open       (jdm_fshandle_t *fsh, struct xfs_bstat *sp,
-                                intgen_t oflags);
-extern intgen_t jdm_readlink   (jdm_fshandle_t *fsh, struct xfs_bstat *sp,
-                                char *bufp, size_t bufsz);
-
-#ifdef EXTATTR
-
-struct attrlist_cursor;
-extern intgen_t jdm_attr_multi (jdm_fshandle_t *fsh, struct xfs_bstat *sp,
-                                char *bufp, int rtrvcnt, int flags);
-extern intgen_t        jdm_attr_list   (jdm_fshandle_t *fsh, struct xfs_bstat *sp,
-                                char *bufp, size_t bufsz, int flags, 
-                                struct attrlist_cursor *cursor);
-#endif /* EXTATTR */
+
+
+extern jdm_fshandle_t *
+jdm_getfshandle( char *mntpnt);
+
+extern void
+jdm_new_filehandle( jdm_filehandle_t **handlep,        /* new filehandle */
+                   size_t *hlen,               /* new filehandle size */
+                   jdm_fshandle_t *fshandlep,  /* filesystem filehandle */
+                   struct xfs_bstat *sp);      /* bulkstat info */
+                   
+extern void
+jdm_delete_filehandle( jdm_filehandle_t *handlep,/* filehandle to delete */
+                      size_t hlen);            /* filehandle size */
+
+extern intgen_t
+jdm_open( jdm_fshandle_t *fshandlep,
+         struct xfs_bstat *sp,
+         intgen_t oflags);
+
+extern intgen_t
+jdm_readlink( jdm_fshandle_t *fshandlep,
+             struct xfs_bstat *sp,
+             char *bufp,
+             size_t bufsz);
 
 /* macro for determining the size of a structure member */
 #define sizeofmember( t, m )   sizeof( ( ( t * )0 )->m )
index 13413eb93e43ba88f52fd729770bcab5a84388e2..0a0a481c3213175896342fd4dd6588e73cbb3b4f 100644 (file)
@@ -332,6 +332,7 @@ typedef struct xfs_fsop_handlereq {
  * code path.
  */
 /*#define INDUCE_IO_ERROR*/
+
 #if (defined(DEBUG) || defined(INDUCE_IO_ERROR))
 /*
  * Error injection.
@@ -342,6 +343,16 @@ typedef struct xfs_error_injection {
 } xfs_error_injection_t;
 #endif /* DEBUG || INDUCE_IO_ERROR */
 
+/*
+ * Compound structure for passing args through ioctl to xfs_attrctl_by_handle
+ */
+typedef struct xfs_fsop_attr_handlereq {
+       struct xfs_fsop_handlereq *hreq;/* handle request interface     */
+                                       /* structure                    */
+       struct attr_op  *ops;           /* array of attribute ops       */
+       int             count;          /* number of attribute ops      */
+} xfs_fsop_attr_handlereq_t;
+
 /*
  * File system identifier. Should be unique (at least per machine).
  */
@@ -438,10 +449,10 @@ typedef struct xfs_handle {
 #define        XFS_IOC_SET_RESBLKS          _IOR ('X', 114, struct xfs_fsop_resblks)
 #define        XFS_IOC_GET_RESBLKS          _IOR ('X', 115, struct xfs_fsop_resblks)
 #if (defined(DEBUG) || defined(INDUCE_IO_ERROR))
-#define XFS_IOC_ERROR_INJECTION  _IOW('X', 116, struct xfs_error_injection)
-#define XFS_IOC_ERROR_CLEARALL   _IOW('X', 117, struct xfs_error_injection)
+#define XFS_IOC_ERROR_INJECTION      _IOW('X', 116, struct xfs_error_injection)
+#define XFS_IOC_ERROR_CLEARALL       _IOW('X', 117, struct xfs_error_injection)
 #endif /* DEBUG || INDUCE_IO_ERROR */
-
+#define        XFS_IOC_ATTRCTL_BY_HANDLE    _IOWR('X', 118, struct xfs_fsop_attr_handlereq)
 /*
  * ioctl command to export information not in standard interfaces
  *     140: IRIX statvfs.f_fstr field - UUID from the superblock
index 39091297508186e07cc73ebc0e51f7466f5c9320..80b0a0bf915a609bcdb9f77521bb6383684aa14d 100644 (file)
@@ -43,7 +43,6 @@
 #include "handle.h"
 #include <libxfs.h>
 
-
 /* just pick a value we know is more than big enough */
 #define        MAXHANSIZ       64
 
@@ -62,12 +61,23 @@ typedef union {
        char    *path;
 } comarg_t;
 
-int    obj_to_handle (
-               int             fsfd,
-               int             opcode,
-               comarg_t        obj,
-               void            **hanp,
-               size_t          *hlen);
+
+int
+obj_to_handle (
+       int             fsfd,
+       int             opcode,
+       comarg_t        obj,
+       void            **hanp,
+       size_t          *hlen);
+
+
+/*
+ * Filesystem Handle -> Open File Descriptor Cache
+ *
+ * Maps filesystem handles to a corresponding open file descriptor for that
+ * filesystem. We need this because we're doing handle operations via ioctl
+ * and we need to remember the open file descriptor for each filesystem.
+ */
 
 struct fdhash {
        int     fsfd;
@@ -98,7 +108,7 @@ path_to_fshandle (
        obj.path = path;
 
        result = obj_to_handle (fd, XFS_IOC_PATH_TO_FSHANDLE,
-                                                       obj, hanp, hlen);
+                               obj, hanp, hlen);
 
        if (result >= 0) {
                fdhp = malloc(sizeof(struct fdhash));
@@ -187,6 +197,19 @@ handle_to_fshandle (
 }
 
 
+int
+handle_to_fsfd(void *hanp)
+{
+       struct fdhash   *fdhp;
+
+       for (fdhp = fdhash_head; fdhp != NULL; fdhp = fdhp->fnxt) {
+               if (memcmp(fdhp->fsh, hanp, FSIDSIZE) == 0)
+                       return fdhp->fsfd;
+       }
+       return -1;
+}
+
+
 int
 obj_to_handle (
        int             fsfd,
@@ -231,6 +254,7 @@ obj_to_handle (
 }
 
 
+
 int
 open_by_handle (
        void            *hanp,
@@ -239,20 +263,9 @@ open_by_handle (
 {
        int             fd;
        int             result;
-       struct fdhash   *fdhp;
        xfs_fsop_handlereq_t hreq;
 
-       fd = -1;
-
-       for (fdhp = fdhash_head; fdhp != NULL; fdhp = fdhp->fnxt) {
-
-               if (memcmp(fdhp->fsh, hanp, FSIDSIZE) == 0) {
-                       fd = fdhp->fsfd;
-                       break;
-               }
-       }
-
-       if (fd < 0) {
+       if ((fd = handle_to_fsfd(hanp)) < 0) {
                errno = EBADF;
                return -1;
        }
@@ -278,21 +291,10 @@ readlink_by_handle (
        size_t          bufsiz)
 {
        int             fd;
-       struct fdhash   *fdhp;
        xfs_fsop_handlereq_t hreq;
 
 
-       fd = -1;
-
-       for (fdhp = fdhash_head; fdhp != NULL; fdhp = fdhp->fnxt) {
-
-               if (memcmp(fdhp->fsh, hanp, FSIDSIZE) == 0) {
-                       fd = fdhp->fsfd;
-                       break;
-               }
-       }
-
-       if (fd < 0) {
+       if ((fd = handle_to_fsfd(hanp)) < 0) {
                errno = EBADF;
                return -1;
        }
index aae9be18a9c260743398f55b54a44b05018d9be9..b36f77b27fef90ed8fbf95d86cb8f6bde79b2209 100644 (file)
@@ -52,9 +52,10 @@ typedef struct filehandle {
        xfs_ino_t fh_ino;               /* 64 bit ino */
 } filehandle_t;
 
+
 static void
 jdm_fill_filehandle( filehandle_t *handlep,
-                    fshandle_t *fshandlep, 
+                    fshandle_t *fshandlep,
                     xfs_bstat_t *statp )
 {
        handlep->fh_fshandle = *fshandlep;
@@ -96,6 +97,30 @@ jdm_getfshandle( char *mntpnt )
        return ( jdm_fshandle_t * )fshandlep;
 }
 
+
+/* externally visible functions */
+
+void
+jdm_new_filehandle( jdm_filehandle_t **handlep,
+                   size_t *hlen,
+                   jdm_fshandle_t *fshandlep,
+                   xfs_bstat_t *statp)
+{
+       /* allocate and fill filehandle */
+       *hlen = sizeof(filehandle_t);
+       *handlep = (filehandle_t *) malloc(*hlen);
+
+       if (*handlep)
+               jdm_fill_filehandle(*handlep, (fshandle_t *) fshandlep, statp);
+}
+
+/* ARGSUSED */
+void
+jdm_delete_filehandle( jdm_filehandle_t *handlep, size_t hlen )
+{
+       free(handlep);
+}
+
 intgen_t
 jdm_open( jdm_fshandle_t *fshp, xfs_bstat_t *statp, intgen_t oflags )
 {
@@ -126,39 +151,3 @@ jdm_readlink( jdm_fshandle_t *fshp,
                                   bufsz );
        return rval;
 }
-
-#ifdef EXTATTR
-intgen_t
-jdm_attr_multi(        jdm_fshandle_t *fshp,
-             xfs_bstat_t *statp,
-             char *bufp, int rtrvcnt, int flags)
-{
-       register fshandle_t *fshandlep = ( fshandle_t * )fshp;
-       filehandle_t filehandle;
-       intgen_t rval;
-
-       jdm_fill_filehandle( &filehandle, fshandlep, statp );
-       rval = attr_multi_by_handle ( ( void * )&filehandle,
-                                     sizeof( filehandle ),
-                                     (void *) bufp,
-                                     rtrvcnt, flags);
-       return rval;
-}
-
-intgen_t
-jdm_attr_list( jdm_fshandle_t *fshp,
-               xfs_bstat_t *statp,
-               char *bufp, size_t bufsz, int flags, 
-               struct attrlist_cursor *cursor)
-{
-       register fshandle_t *fshandlep = ( fshandle_t * )fshp;
-       filehandle_t filehandle;
-       intgen_t rval;
-
-       jdm_fill_filehandle( &filehandle, fshandlep, statp );
-       rval = attr_list_by_handle (( void * )&filehandle,
-                       sizeof( filehandle ),
-                       bufp, bufsz, flags, cursor);
-       return rval;
-}
-#endif