PERFORCE change 117735 for review

Roman Divacky rdivacky at FreeBSD.org
Mon Apr 9 11:09:07 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=117735

Change 117735 by rdivacky at rdivacky_witten on 2007/04/09 11:08:54

	Linux faccessat implementation. This changes kern_access() prototype
	so I changed all the consumers.

Affected files ...

.. //depot/projects/linuxolator/src/sys/compat/linux/linux_file.c#24 edit
.. //depot/projects/linuxolator/src/sys/compat/svr4/svr4_fcntl.c#5 edit
.. //depot/projects/linuxolator/src/sys/i386/ibcs2/ibcs2_fcntl.c#3 edit
.. //depot/projects/linuxolator/src/sys/kern/vfs_syscalls.c#15 edit
.. //depot/projects/linuxolator/src/sys/sys/syscallsubr.h#5 edit

Differences ...

==== //depot/projects/linuxolator/src/sys/compat/linux/linux_file.c#24 (text+ko) ====

@@ -567,7 +567,7 @@
 	if (ldebug(access))
 		printf(ARGS(access, "%s, %d"), path, args->flags);
 #endif
-	error = kern_access(td, path, UIO_SYSSPACE, args->flags);
+	error = kern_access(td, path, UIO_SYSSPACE, args->flags, -1);
 	LFREEPATH(path);
 
 	return (error);
@@ -576,7 +576,29 @@
 int
 linux_faccessat(struct thread *td, struct linux_faccessat_args *args)
 {
-	return (ENOSYS);
+	char *path;
+	int error, dfd;
+
+	/* linux convention */
+	if (args->mode & ~(F_OK | X_OK | W_OK | R_OK))
+		return (EINVAL);
+
+	LCONVPATHEXIST(td, args->filename, &path);
+
+#ifdef DEBUG
+	if (ldebug(access))
+		printf(ARGS(access, "%s, %d"), path, args->mode);
+#endif
+
+	if (args->dfd == LINUX_AT_FDCWD)
+		dfd = -1;
+	else
+		dfd = args->dfd;
+
+	error = kern_access(td, path, UIO_SYSSPACE, args->mode, dfd);
+	LFREEPATH(path);
+
+	return (error);
 }
 
 int

==== //depot/projects/linuxolator/src/sys/compat/svr4/svr4_fcntl.c#5 (text+ko) ====

@@ -478,7 +478,7 @@
 	int error;
 
 	CHECKALTEXIST(td, uap->path, &newpath);
-	error = kern_access(td, newpath, UIO_SYSSPACE, uap->flags);
+	error = kern_access(td, newpath, UIO_SYSSPACE, uap->flags, -1);
 	free(newpath, M_TEMP);
 	return (error);
 }

==== //depot/projects/linuxolator/src/sys/i386/ibcs2/ibcs2_fcntl.c#3 (text+ko) ====

@@ -241,7 +241,7 @@
 	int error;
 
         CHECKALTEXIST(td, uap->path, &path);
-	error = kern_access(td, path, UIO_SYSSPACE, uap->flags);
+	error = kern_access(td, path, UIO_SYSSPACE, uap->flags, -1);
 	free(path, M_TEMP);
 	return (error);
 }

==== //depot/projects/linuxolator/src/sys/kern/vfs_syscalls.c#15 (text+ko) ====

@@ -1849,11 +1849,11 @@
 	} */ *uap;
 {
 
-	return (kern_access(td, uap->path, UIO_USERSPACE, uap->flags));
+	return kern_access(td, uap->path, UIO_USERSPACE, uap->flags, -1);
 }
 
 int
-kern_access(struct thread *td, char *path, enum uio_seg pathseg, int flags)
+kern_access(struct thread *td, char *path, enum uio_seg pathseg, int flags, int dirfd)
 {
 	struct ucred *cred, *tmpcred;
 	register struct vnode *vp;
@@ -1873,7 +1873,7 @@
 	td->td_ucred = tmpcred;
 	NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1,
 	    pathseg, path, td);
-	if ((error = namei(&nd)) != 0)
+	if ((error = namei1(&nd, dirfd)) != 0)
 		goto out1;
 	vfslocked = NDHASGIANT(&nd);
 	vp = nd.ni_vp;

==== //depot/projects/linuxolator/src/sys/sys/syscallsubr.h#5 (text+ko) ====

@@ -54,7 +54,7 @@
 int	kern_accept(struct thread *td, int s, struct sockaddr **name,
 	    socklen_t *namelen, struct file **fp);
 int	kern_access(struct thread *td, char *path, enum uio_seg pathseg,
-	    int flags);
+	    int flags, int dirfd);
 int	kern_adjtime(struct thread *td, struct timeval *delta,
 	    struct timeval *olddelta);
 int	kern_alternate_path(struct thread *td, const char *prefix, char *path,


More information about the p4-projects mailing list