From ebcbe8f3fae1cf29c426dc3c5f88b03125d0073c Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Mon, 9 Sep 2013 21:22:02 -0400 Subject: [PATCH] libuafs: move code for uafs_LookupLink in order that we can make a future version static, move the code. Change-Id: I67e50ef5f14db3567ecd437b694b62b2c8fdb760 Reviewed-on: http://gerrit.openafs.org/10239 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/afs/UKERNEL/afs_usrops.c | 120 +++++++++++++++++------------------ 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/src/afs/UKERNEL/afs_usrops.c b/src/afs/UKERNEL/afs_usrops.c index 95cea9ef1..efb52eaa8 100644 --- a/src/afs/UKERNEL/afs_usrops.c +++ b/src/afs/UKERNEL/afs_usrops.c @@ -1653,6 +1653,66 @@ uafs_RPCStatsClearPeer(void) return rc; } +/* + * Lookup the target of a symbolic link + * Call VN_HOLD on the output vnode if successful. + * Returns zero on success, error code on failure. + * + * Note: Caller must hold the AFS global lock. + */ +int +uafs_LookupLink(struct usr_vnode *vp, struct usr_vnode *parentVp, + struct usr_vnode **vpp) +{ + int code; + int len; + char *pathP; + struct usr_vnode *linkVp; + struct usr_uio uio; + struct iovec iov[1]; + + AFS_ASSERT_GLOCK(); + + pathP = afs_osi_Alloc(MAX_OSI_PATH + 1); + usr_assert(pathP != NULL); + + /* + * set up the uio buffer + */ + iov[0].iov_base = pathP; + iov[0].iov_len = MAX_OSI_PATH + 1; + uio.uio_iov = &iov[0]; + uio.uio_iovcnt = 1; + uio.uio_offset = 0; + uio.uio_segflg = 0; + uio.uio_fmode = FREAD; + uio.uio_resid = MAX_OSI_PATH + 1; + + /* + * Read the link data + */ + code = afs_readlink(VTOAFS(vp), &uio, get_user_struct()->u_cred); + if (code) { + afs_osi_Free(pathP, MAX_OSI_PATH + 1); + return code; + } + len = MAX_OSI_PATH + 1 - uio.uio_resid; + pathP[len] = '\0'; + + /* + * Find the target of the symbolic link + */ + code = uafs_LookupName(pathP, parentVp, &linkVp, 1, 0); + if (code) { + afs_osi_Free(pathP, MAX_OSI_PATH + 1); + return code; + } + + afs_osi_Free(pathP, MAX_OSI_PATH + 1); + *vpp = linkVp; + return 0; +} + /* * Lookup a file or directory given its path. * Call VN_HOLD on the output vnode if successful. @@ -1800,66 +1860,6 @@ uafs_LookupName(char *path, struct usr_vnode *parentVp, return 0; } -/* - * Lookup the target of a symbolic link - * Call VN_HOLD on the output vnode if successful. - * Returns zero on success, error code on failure. - * - * Note: Caller must hold the AFS global lock. - */ -int -uafs_LookupLink(struct usr_vnode *vp, struct usr_vnode *parentVp, - struct usr_vnode **vpp) -{ - int code; - int len; - char *pathP; - struct usr_vnode *linkVp; - struct usr_uio uio; - struct iovec iov[1]; - - AFS_ASSERT_GLOCK(); - - pathP = afs_osi_Alloc(MAX_OSI_PATH + 1); - usr_assert(pathP != NULL); - - /* - * set up the uio buffer - */ - iov[0].iov_base = pathP; - iov[0].iov_len = MAX_OSI_PATH + 1; - uio.uio_iov = &iov[0]; - uio.uio_iovcnt = 1; - uio.uio_offset = 0; - uio.uio_segflg = 0; - uio.uio_fmode = FREAD; - uio.uio_resid = MAX_OSI_PATH + 1; - - /* - * Read the link data - */ - code = afs_readlink(VTOAFS(vp), &uio, get_user_struct()->u_cred); - if (code) { - afs_osi_Free(pathP, MAX_OSI_PATH + 1); - return code; - } - len = MAX_OSI_PATH + 1 - uio.uio_resid; - pathP[len] = '\0'; - - /* - * Find the target of the symbolic link - */ - code = uafs_LookupName(pathP, parentVp, &linkVp, 1, 0); - if (code) { - afs_osi_Free(pathP, MAX_OSI_PATH + 1); - return code; - } - - afs_osi_Free(pathP, MAX_OSI_PATH + 1); - *vpp = linkVp; - return 0; -} - /* * Lookup the parent of a file or directory given its path * Call VN_HOLD on the output vnode if successful. -- 2.39.5