PERFORCE change 120827 for review
Roman Divacky
rdivacky at FreeBSD.org
Sun Jun 3 10:48:32 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=120827
Change 120827 by rdivacky at rdivacky_witten on 2007/06/03 10:48:09
Implement kern_statat. Not tested at all yet.
Suggested by: rwatson
Affected files ...
.. //depot/projects/soc2007/rdivacky/linux_at/sys/kern/vfs_syscalls.c#5 edit
Differences ...
==== //depot/projects/soc2007/rdivacky/linux_at/sys/kern/vfs_syscalls.c#5 (text+ko) ====
@@ -91,6 +91,8 @@
int flags, int mode, struct nameidata *nd);
static int kern_common_access(struct thread *td, char *path, enum uio_seg pathseg,
int flags, struct nameidata *nd);
+static int kern_common_stat(struct thread *td, struct stat *sbp,
+ struct nameidata *nd);
/*
* The module initialization routine for POSIX asynchronous I/O will
@@ -2132,18 +2134,53 @@
kern_stat(struct thread *td, char *path, enum uio_seg pathseg, struct stat *sbp)
{
struct nameidata nd;
- struct stat sb;
- int error, vfslocked;
-
+
NDINIT(&nd, LOOKUP,
FOLLOW | LOCKSHARED | LOCKLEAF | MPSAFE | AUDITVNODE1,
pathseg, path, td);
if ((error = namei(&nd)) != 0)
return (error);
+
+ return kern_common_stat(td, sbp, nd);
+}
+
+int
+kern_statat(struct thread *td, char *path, enum uio_seg pathseg, struct stat *sbp, int dfd)
+{
+ int error;
+ struct nameidata nd;
+ struct vnode *dir_vn;
+
+ if (dirfd == AT_FDCWD)
+ dir_vn = NULL;
+ else {
+ error = fgetvp(td, dirfd, &dir_vn);
+ if (error)
+ return (error);
+ if (dir_vn->v_type != VDIR) {
+ vrele(dir_vn);
+ return (ENOTDIR);
+ }
+ }
+
+ NDINIT_AT(&nd, LOOKUP, FOLLOW | AUDITVNODE1 | MPSAFE, pathseg, path, td, dir_vn);
+
+ error = kern_common_stat(td, sbp, &nd);
+ if (dirfd != AT_FDCWD)
+ vrele(dir_vn);
+ return (error);
+}
+
+static int
+kern_common_stat(struct thread *td, struct stat *sbp, struct nameidata *nd)
+{
+ struct stat sb;
+ int error, vfslocked;
+
vfslocked = NDHASGIANT(&nd);
- error = vn_stat(nd.ni_vp, &sb, td->td_ucred, NOCRED, td);
+ error = vn_stat(nd->ni_vp, &sb, td->td_ucred, NOCRED, td);
NDFREE(&nd, NDF_ONLY_PNBUF);
- vput(nd.ni_vp);
+ vput(nd->ni_vp);
VFS_UNLOCK_GIANT(vfslocked);
if (mtx_owned(&Giant))
printf("stat(%d): %s\n", vfslocked, path);
@@ -2152,7 +2189,6 @@
*sbp = sb;
return (0);
}
-
/*
* Get file status; this version does not follow links.
*/
More information about the p4-projects
mailing list