diff options
author | Dean Roehrich <roehrich@sgi.com> | 2002-03-21 17:33:31 +0000 |
---|---|---|
committer | Dean Roehrich <roehrich@sgi.com> | 2002-03-21 17:33:31 +0000 |
commit | 363c5b6535b0225c7d1055d6334d0131bea06022 (patch) | |
tree | d3127b6bfbc7e090d87882a346c7df26f62a0d58 | |
parent | 5d215ddc03d9fff15da0a4161dc7c0ae514fe0c2 (diff) | |
download | dmapi-dev-363c5b6535b0225c7d1055d6334d0131bea06022.tar.gz |
dm_handle_to_path() will now work in most cases, and in the other cases
there's just a little more grunt work that has to be done in the library. If
the directory that contains some component of the path has never had a lookup
performed on it, then the kernel won't have that dir in its dcache. In that
case it'll create an anonymous dentry for the filesystem's root dir, and the
library detects that this happened.
If the library detects that an anonymous dentry was created, then it returns
an error indicating that it didn't find the path. Before I take this another
step, I'd like to know if this scenario happens in actual practice. I'm
betting the directory of interest has almost always been loaded into the
dcache by a user process before the HSM uses dm_handle_to_path(). We'll see.
It seems that ioctl(XFS_IOC_OPEN_BY_HANDLE) would have the same restriction,
though it looks like it's never used in a case where the path hasn't already
been accessed.
This mod also removes libdm's dependence on libhandle.
update revision
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | configure.in | 7 | ||||
-rw-r--r-- | debian/changelog | 6 | ||||
-rw-r--r-- | include/dmapi.h | 6 | ||||
-rw-r--r-- | include/dmapi_kern.h | 6 | ||||
-rw-r--r-- | libdm/Makefile | 2 | ||||
-rw-r--r-- | libdm/dm_handle.c | 9 | ||||
-rw-r--r-- | libdm/dm_handle2path.c | 53 | ||||
-rw-r--r-- | libdm/dmapi_lib.c | 6 | ||||
-rw-r--r-- | man/man3/dmapi.3 | 2 |
10 files changed, 74 insertions, 25 deletions
@@ -3,5 +3,5 @@ # PKG_MAJOR=2 PKG_MINOR=0 -PKG_REVISION=0 +PKG_REVISION=1 PKG_BUILD=0 diff --git a/configure.in b/configure.in index 2afd346..8995d81 100644 --- a/configure.in +++ b/configure.in @@ -105,13 +105,6 @@ AC_CHECK_HEADER(xfs/handle.h,, [ echo 'Alternatively, run "make install-dev" from the xfsprogs source.' exit 1 ]) -AC_CHECK_LIB(handle, attr_list_by_handle,, [ - echo - echo 'FATAL ERROR: could not find a current XFS handle library.' - echo 'Upgrade the xfsprogs-devel (rpm) or the xfslibs-dev (deb) package.' - echo 'Alternatively, run "make install-dev" from the xfsprogs source.' - exit 1 -]) dnl ensure libtool is installed AC_PATH_PROG(LIBTOOL, libtool,,/usr/bin) diff --git a/debian/changelog b/debian/changelog index bcbd60d..d6d8493 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +dmapi (2.0.1-1) unstable; urgency=low + + * Fix dm_handle_to_path(). + + -- Dean Roehrich, Thu Mar 21 11:10:24 2002 + dmapi (2.0.0-1) unstable; urgency=low * Major release to coincide with switch to new extended attributes diff --git a/include/dmapi.h b/include/dmapi.h index b30eed8..0519eaa 100644 --- a/include/dmapi.h +++ b/include/dmapi.h @@ -1021,6 +1021,12 @@ dm_write_invis( /* Non-standard SGI additions to the DMAPI interface. */ +int +dm_open_by_handle( + void *hanp, + size_t hlen, + int mode); + extern int dm_get_dioinfo( dm_sessid_t sid, diff --git a/include/dmapi_kern.h b/include/dmapi_kern.h index 7c474a7..10a4aa8 100644 --- a/include/dmapi_kern.h +++ b/include/dmapi_kern.h @@ -112,6 +112,10 @@ int dm_vp_to_handle ( struct vnode *vp, xfs_handle_t *handlep); +void dm_hookup_vfsmount( + vfs_t *vfsp, + struct vfsmount *mnt); + /* The following prototypes and definitions are used by DMAPI as its interface into the filesystem code. Communication between DMAPI and the filesystem are established as follows: @@ -543,6 +547,6 @@ typedef struct dm_fcntl_mapevent dm_fcntl_mapevent_t; #define DM_SYNC_BY_HANDLE 54 #define DM_UPGRADE_RIGHT 55 #define DM_WRITE_INVIS 56 - +#define DM_OPEN_BY_HANDLE 57 #endif /* __DMAPI_KERN_H__ */ diff --git a/libdm/Makefile b/libdm/Makefile index 07008c7..8082161 100644 --- a/libdm/Makefile +++ b/libdm/Makefile @@ -34,7 +34,7 @@ TOPDIR = .. include $(TOPDIR)/include/builddefs LTLIBRARY = libdm.la -LDLIBS = -lhandle +#LDLIBS = -lhandle LT_CURRENT = 0 LT_REVISION = 2 LT_AGE = 0 diff --git a/libdm/dm_handle.c b/libdm/dm_handle.c index 9209f91..bea933b 100644 --- a/libdm/dm_handle.c +++ b/libdm/dm_handle.c @@ -154,7 +154,6 @@ parse_handle( dm_ino_t *inop, dm_igen_t *igenp) { -/* XXX */ xfs_handle_t handle; xfs_fid2_t *xfid2; fid_t *fidp; @@ -173,13 +172,13 @@ parse_handle( if (hlen == sizeof(handle.ha_fsid)) return(DM_HANDLE_FILESYSTEM); -#if 0 - if (handle.ha_fid.fid_len != (hlen - sizeof(handle.ha_fsid) - sizeof(handle.ha_fid.fid_len))) - return(DM_HANDLE_BAD); -#else +#ifdef linux fidp = (fid_t*)&handle.ha_fid; if (fidp->fid_len != (hlen - sizeof(handle.ha_fsid) - sizeof(fidp->fid_len))) return(DM_HANDLE_BAD); +#else + if (handle.ha_fid.fid_len != (hlen - sizeof(handle.ha_fsid) - sizeof(handle.ha_fid.fid_len))) + return(DM_HANDLE_BAD); #endif xfid2 = (struct xfs_fid2 *)&handle.ha_fid; diff --git a/libdm/dm_handle2path.c b/libdm/dm_handle2path.c index a6fb1fe..f01cd19 100644 --- a/libdm/dm_handle2path.c +++ b/libdm/dm_handle2path.c @@ -102,10 +102,10 @@ dm_handle_to_path( if ((origfd = open(".", O_RDONLY)) < 0) return -1; /* leave errno set from open */ -#if 0 - dirfd = (int)syssgi(SGI_OPEN_BY_HANDLE, dirhanp, dirhlen, O_RDONLY); +#ifdef linux + dirfd = dmi(DM_OPEN_BY_HANDLE, dirhanp, dirhlen, O_RDONLY); #else - dirfd = open_by_handle(dirhanp, dirhlen, O_RDONLY); + dirfd = (int)syssgi(SGI_OPEN_BY_HANDLE, dirhanp, dirhlen, O_RDONLY); #endif if (dirfd < 0) { err = errno; @@ -118,8 +118,44 @@ dm_handle_to_path( if ((err = errno) == ERANGE) /* buffer too small */ err = E2BIG; } else { - err = getcomp(dirfd, targhanp, targhlen, pathbufp, - buflen, rlenp); + char hbuf[DM_MAX_HANDLE_SIZE]; + size_t hlen; + + /* Check that we're in the correct directory. + * If the dir we wanted has not been accessed + * then the kernel would have put us into the + * filesystem's root directory--but at least + * we'll be on the correct filesystem. + */ + + err = 0; + if (dmi(DM_PATH_TO_HANDLE, pathbufp, hbuf, &hlen)) { + err = ENOENT; + } + else { + if (dm_handle_cmp(dirhanp, dirhlen, hbuf, hlen)) { + /* The dir we want has never been + * accessed, so we'll have to find + * it. + */ + + /* XXX -- need something to march + through all the dirs, trying to + find the right one. Something + like a recursive version of + getcomp(). + In practice, are we ever going + to need this? */ + + err = ENOENT; + } + } + + /* Now march through the dir to find the target. */ + if (!err) { + err = getcomp(dirfd, targhanp, targhlen, pathbufp, + buflen, rlenp); + } } (void) fchdir(origfd); /* can't do anything about a failure */ } @@ -160,11 +196,10 @@ getcomp( int loc = 0; /* byte offset of entry in the buffer */ int size = 0; /* number of bytes of data in buffer */ int eof = 0; /* did last ngetdents exhaust dir.? */ -#if 0 -/* XXX */ - struct dirent64 *dp; /* pointer to directory entry */ -#else +#ifdef linux struct dirent *dp; +#else + struct dirent64 *dp; /* pointer to directory entry */ #endif char hbuf[DM_MAX_HANDLE_SIZE]; size_t hlen; diff --git a/libdm/dmapi_lib.c b/libdm/dmapi_lib.c index 2525b0a..bb33c4d 100644 --- a/libdm/dmapi_lib.c +++ b/libdm/dmapi_lib.c @@ -363,6 +363,12 @@ dmi( int opcode, ... ) u.arg7 = ARG(char*); u.arg8 = ARG(char*); break; +/* dm_handle2path */ + case DM_OPEN_BY_HANDLE: + u.arg1 = ARG(void*); + u.arg2 = ARG(size_t); + u.arg3 = ARG(int); + break; /* dm_hole */ case DM_GET_ALLOCINFO: u.arg1 = ARG(dm_sessid_t); diff --git a/man/man3/dmapi.3 b/man/man3/dmapi.3 index 193bda8..c061d9a 100644 --- a/man/man3/dmapi.3 +++ b/man/man3/dmapi.3 @@ -5,7 +5,7 @@ dmapi \- \&DMAPI library .nf \f3#include <xfs/dmapi.h>\f1 .sp .8v -\f3cc ... -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -ldm -lhandle +\f3cc ... -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -ldm .fi .SH DESCRIPTION \f2DMAPI\f1, or \f2XDSM\f1, is an implementation of |