Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Apr 2007 15:55:32 GMT
From:      Roman Divacky <rdivacky@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 117369 for review
Message-ID:  <200704041555.l34FtWLl080167@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=117369

Change 117369 by rdivacky@rdivacky_witten on 2007/04/04 15:54:32

	Rewrite *at() in a proper way:
	
	o	change vn_open/kern_open to take dfd argument
	o	rename namei to namei1 and create namei that wraps namei1
	o	add dfd arugment to namei1 which specifies starting point
		of the name search, -1 meaning CWD (ie. no change from current
		behaviour)
	o	change all consumers of vn_open/kern_open to the new prototype
	o	implement linux_openat() using the new kern_open
	o	implement linux_fstatat64() using the new kern_open
	
	linux_openat passes all LTP tests and linux_fstatat64 passes all but
	one where it should fail but it succeeds in our implementation.

Affected files ...

.. //depot/projects/linuxolator/src/sys/compat/linux/linux_file.c#22 edit
.. //depot/projects/linuxolator/src/sys/compat/linux/linux_misc.c#64 edit
.. //depot/projects/linuxolator/src/sys/compat/linux/linux_stats.c#10 edit
.. //depot/projects/linuxolator/src/sys/compat/ndis/subr_ndis.c#2 edit
.. //depot/projects/linuxolator/src/sys/compat/svr4/svr4_fcntl.c#4 edit
.. //depot/projects/linuxolator/src/sys/dev/md/md.c#4 edit
.. //depot/projects/linuxolator/src/sys/dev/streams/streams.c#2 edit
.. //depot/projects/linuxolator/src/sys/i386/ibcs2/ibcs2_fcntl.c#2 edit
.. //depot/projects/linuxolator/src/sys/kern/kern_acct.c#7 edit
.. //depot/projects/linuxolator/src/sys/kern/kern_alq.c#4 edit
.. //depot/projects/linuxolator/src/sys/kern/kern_descrip.c#9 edit
.. //depot/projects/linuxolator/src/sys/kern/kern_ktrace.c#8 edit
.. //depot/projects/linuxolator/src/sys/kern/kern_linker.c#7 edit
.. //depot/projects/linuxolator/src/sys/kern/kern_sig.c#11 edit
.. //depot/projects/linuxolator/src/sys/kern/link_elf.c#4 edit
.. //depot/projects/linuxolator/src/sys/kern/tty_cons.c#4 edit
.. //depot/projects/linuxolator/src/sys/kern/vfs_lookup.c#8 edit
.. //depot/projects/linuxolator/src/sys/kern/vfs_syscalls.c#13 edit
.. //depot/projects/linuxolator/src/sys/kern/vfs_vnops.c#6 edit
.. //depot/projects/linuxolator/src/sys/security/audit/audit_syscalls.c#8 edit
.. //depot/projects/linuxolator/src/sys/sys/namei.h#2 edit
.. //depot/projects/linuxolator/src/sys/sys/syscallsubr.h#4 edit
.. //depot/projects/linuxolator/src/sys/sys/vnode.h#8 edit
.. //depot/projects/linuxolator/src/sys/ufs/ufs/ufs_quota.c#10 edit

Differences ...

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

@@ -68,68 +68,7 @@
 #endif
 #include <compat/linux/linux_util.h>
 
-/*
- * common code for linux *at set of syscalls
- *
- * works like this:
- * if filename is absolute 
- *    ignore dirfd
- * else
- *    if dirfd == AT_FDCWD 
- *       return CWD/filename
- *    else
- *       return DIRFD/filename
- */
 int
-linux_at(struct thread *td, int dirfd, char *filename, char **newpath, char **freebuf)
-{
-	struct file *fp;
-	int error = 0;
-	struct vnode *dvp;
-	struct filedesc *fdp = td->td_proc->p_fd;
-	char *fullpath = "unknown";
-	char *freepath = NULL;
-
-	/* don't do anything if the pathname is absolute */
-	if (*filename == '/') {
-		*newpath= filename;
-		return (0);
-	}
-
-	/* check for AT_FDWCD */
-	if (dirfd == LINUX_AT_FDCWD) {
-		FILEDESC_LOCK(fdp);
-		dvp = fdp->fd_cdir;
-		FILEDESC_UNLOCK(fdp);
-	} else {
-		error = fget(td, dirfd, &fp);
-		if (error)
-			return (error);
-		if (fp->f_type != DTYPE_VNODE) {
-			fdrop(fp, td);
-			return (EBADF);			
-		}	
-		dvp = fp->f_vnode;
-		/* only a dir can be dfd */
-		if (dvp->v_type != VDIR) {
-			fdrop(fp, td);
-			return (ENOTDIR);
-		}
-		fdrop(fp, td);
-	}
-
-	error = vn_fullpath(td, dvp, &fullpath, &freepath);
-	if (!error) {
-		*newpath = malloc(strlen(fullpath) + strlen(filename) + 2,
-		    M_TEMP, M_WAITOK | M_ZERO);
-		*freebuf = freepath;
-		sprintf(*newpath, "%s/%s", fullpath, filename);
-	}
-
-	return (error);
-}
-
-int
 linux_creat(struct thread *td, struct linux_creat_args *args)
 {
     char *path;
@@ -142,14 +81,14 @@
 		printf(ARGS(creat, "%s, %d"), path, args->mode);
 #endif
     error = kern_open(td, path, UIO_SYSSPACE, O_WRONLY | O_CREAT | O_TRUNC,
-	args->mode);
+	args->mode, -1);
     LFREEPATH(path);
     return (error);
 }
 
 
 int
-linux_common_open(struct thread *td, char *path, int l_flags, int mode, int openat)
+linux_common_open(struct thread *td, char *path, int l_flags, int mode, int dirfd)
 {
     struct proc *p = td->td_proc;
     struct file *fp;
@@ -191,7 +130,7 @@
 	bsd_flags |= O_NOFOLLOW;
     /* XXX LINUX_O_NOATIME: unable to be easily implemented. */
 
-    error = kern_open(td, path, UIO_SYSSPACE, bsd_flags, mode);
+    error = kern_open(td, path, UIO_SYSSPACE, bsd_flags, mode, dirfd);
     if (!error) {
 	    fd = td->td_retval[0];
 	    /*
@@ -233,46 +172,40 @@
     if (ldebug(open))
 	    printf(LMSG("open returns error %d"), error);
 #endif
-    if (!openat)
-	LFREEPATH(path);
+    LFREEPATH(path);
     return error;
 }
 
 int
 linux_openat(struct thread *td, struct linux_openat_args *args)
 {
-	char *newpath, *oldpath, *freebuf = NULL, *path;
-	int error;
+	char *path, *newpath;
+	int error, dfd;
+
+	path = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
+	error = copyinstr(args->filename, path, MAXPATHLEN, NULL);
+	if (error) {
+		free(path, M_TEMP);
+		return (EFAULT);
+	}
 
-	oldpath = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
-	error = copyinstr(args->filename, oldpath, MAXPATHLEN, NULL);
-	if (error)
-		return (error);	
+	if (args->flags & LINUX_O_CREAT)
+		LCONVPATH_SEG(td, path, &newpath, 1, UIO_SYSSPACE);
+	else
+		LCONVPATH_SEG(td, path, &newpath, 0, UIO_SYSSPACE);
+	free(path, M_TEMP);
 
 #ifdef DEBUG
 	if (ldebug(openat))
 		printf(ARGS(openat, "%i, %s, 0x%x, 0x%x"), args->dfd,
-		    oldpath, args->flags, args->mode);
+		    newpath, args->flags, args->mode);
 #endif
-
-	error = linux_at(td, args->dfd, oldpath, &newpath, &freebuf);
-	if (error)
-		return (error);
-#ifdef DEBUG
-	printf(LMSG("newpath: %s"), newpath);
-#endif
-	if (args->flags & LINUX_O_CREAT)
-		LCONVPATH_SEG(td, newpath, &path, 1, UIO_SYSSPACE);
+	if (args->dfd == LINUX_AT_FDCWD)
+		dfd = -1;
 	else
-		LCONVPATH_SEG(td, newpath, &path, 0, UIO_SYSSPACE);
-	if (freebuf)
-		free(freebuf, M_TEMP);
-	if (*oldpath != '/')
-		free(newpath, M_TEMP);
+		dfd = args->dfd;
 
-	error = linux_common_open(td, path, args->flags, args->mode, 1);
-	free(oldpath, M_TEMP);
-	return (error);
+	return linux_common_open(td, newpath, args->flags, args->mode, dfd);
 }
 
 int
@@ -291,7 +224,7 @@
 		    path, args->flags, args->mode);
 #endif
 
-	return linux_common_open(td, path, args->flags, args->mode, 0);
+	return linux_common_open(td, path, args->flags, args->mode, -1);
 }
 
 int

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

@@ -960,7 +960,7 @@
 		/* FALLTHROUGH */
 	case S_IFREG:
 		error = kern_open(td, path, UIO_SYSSPACE,
-		    O_WRONLY | O_CREAT | O_TRUNC, args->mode);
+		    O_WRONLY | O_CREAT | O_TRUNC, args->mode, -1);
 		break;
 
 	default:

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

@@ -125,7 +125,7 @@
 	if (!S_ISCHR(buf->st_mode) && !S_ISBLK(buf->st_mode))
 		return;
 	temp = td->td_retval[0];
-	if (kern_open(td, path, UIO_SYSSPACE, O_RDONLY, 0) != 0)
+	if (kern_open(td, path, UIO_SYSSPACE, O_RDONLY, 0, -1) != 0)
 		return;
 	fd = td->td_retval[0];
 	td->td_retval[0] = temp;
@@ -599,31 +599,36 @@
 linux_fstatat64(struct thread *td, struct linux_fstatat64_args *args)
 {
 	int error;
-	char *newpath, *oldpath, *freebuf = NULL, *path;
-	int fd;
+	char *path, *newpath;
+	int fd, dfd;
 	struct stat buf;
 
 	/* open the file */
-	oldpath = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
-	error = copyinstr(args->pathname, oldpath, MAXPATHLEN, NULL);
+	path = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
+	error = copyinstr(args->pathname, path, MAXPATHLEN, NULL);
+	if (error) {
+		free(path, M_TEMP);
+		return (EFAULT);
+	}
+
+	LCONVPATH_SEG(td, path, &newpath, 0, UIO_SYSSPACE);
+	free(path, M_TEMP);
+
 #ifdef DEBUG
 	if (ldebug(fstatat64))
-		printf(ARGS(fstatat64, "%i, %s, %i"), args->dfd, args->pathname, args->flag);
+		printf(ARGS(fstatat64, "%i, %s, %i"), args->dfd, newpath, args->flag);
 #endif
 
-	error = linux_at(td, args->dfd, oldpath, &newpath, &freebuf);
-	if (error)
-		return (error);
-	LCONVPATH_SEG(td, newpath, &path, 0, UIO_SYSSPACE);
-	if (freebuf)
-		free(freebuf, M_TEMP);
-	if (*oldpath != '/')
-		free(newpath, M_TEMP);
+	if (args->dfd == LINUX_AT_FDCWD)
+		dfd = -1;
+	else
+		dfd = args->dfd;
 
-	error = linux_common_open(td, path, O_RDONLY, 0, 1);
-	free(oldpath, M_TEMP);
-	if (error)
+	error = kern_open(td, newpath, UIO_SYSSPACE, O_RDONLY, 0, dfd);
+	if (error) {
+		LFREEPATH(newpath);
 		return (error);
+	}
 	/* file opened */
 	fd = td->td_retval[0];
 	td->td_retval[0] = 0;
@@ -637,6 +642,7 @@
 	
 	/* close the opened file */
 	kern_close(td, fd);
+	LFREEPATH(newpath);
 	return (0);
 }
 

==== //depot/projects/linuxolator/src/sys/compat/ndis/subr_ndis.c#2 (text+ko) ====

@@ -3008,7 +3008,7 @@
 	NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, path, td);
 
 	flags = FREAD;
-	error = vn_open(&nd, &flags, 0, -1);
+	error = vn_open(&nd, &flags, 0, -1, -1);
 	if (error) {
 		*status = NDIS_STATUS_FILE_NOT_FOUND;
 		ExFreePool(fh);

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

@@ -376,7 +376,7 @@
 	CHECKALTEXIST(td, uap->path, &newpath);
 
 	bsd_flags = svr4_to_bsd_flags(uap->flags);
-	error = kern_open(td, newpath, UIO_SYSSPACE, bsd_flags, uap->mode);
+	error = kern_open(td, newpath, UIO_SYSSPACE, bsd_flags, uap->mode, -1);
 	free(newpath, M_TEMP);
 
 	if (error) {
@@ -435,7 +435,7 @@
 	CHECKALTEXIST(td, uap->path, &newpath);
 
 	error = kern_open(td, newpath, UIO_SYSSPACE, O_WRONLY | O_CREAT |
-	    O_TRUNC, uap->mode);
+	    O_TRUNC, uap->mode, -1);
 	free(newpath, M_TEMP);
 	return (error);
 }

==== //depot/projects/linuxolator/src/sys/dev/md/md.c#4 (text+ko) ====

@@ -913,7 +913,7 @@
 	if ((mdio->md_options & MD_READONLY) != 0)
 		flags &= ~FWRITE;
 	NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, sc->file, td);
-	error = vn_open(&nd, &flags, 0, -1);
+	error = vn_open(&nd, &flags, 0, -1, -1);
 	if (error != 0)
 		return (error);
 	vfslocked = NDHASGIANT(&nd);

==== //depot/projects/linuxolator/src/sys/dev/streams/streams.c#2 (text+ko) ====

@@ -310,7 +310,7 @@
 		ptyname[8] = ttyletters[l];
 		ptyname[9] = ttynumbers[n];
 
-		error = kern_open(td, ptyname, UIO_SYSSPACE, O_RDWR, 0);
+		error = kern_open(td, ptyname, UIO_SYSSPACE, O_RDWR, 0, -1);
 		switch (error) {
 		case ENOENT:
 		case ENXIO:

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

@@ -187,7 +187,7 @@
 		CHECKALTCREAT(td, uap->path, &path);
 	else
 		CHECKALTEXIST(td, uap->path, &path);
-	ret = kern_open(td, path, UIO_SYSSPACE, flags, uap->mode);
+	ret = kern_open(td, path, UIO_SYSSPACE, flags, uap->mode, -1);
 
 #ifdef SPX_HACK
 	if (ret == ENXIO) {
@@ -227,7 +227,7 @@
 
 	CHECKALTCREAT(td, uap->path, &path);
 	error = kern_open(td, path, UIO_SYSSPACE, O_WRONLY | O_CREAT | O_TRUNC,
-	    uap->mode);
+	    uap->mode, -1);
 	free(path, M_TEMP);
 	return (error);
 }       

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

@@ -203,7 +203,7 @@
 		NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE | AUDITVNODE1,
 		    UIO_USERSPACE, uap->path, td);
 		flags = FWRITE | O_APPEND;
-		error = vn_open(&nd, &flags, 0, -1);
+		error = vn_open(&nd, &flags, 0, -1, -1);
 		if (error)
 			return (error);
 		vfslocked = NDHASGIANT(&nd);

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

@@ -356,7 +356,7 @@
 	NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_SYSSPACE, file, td);
 	flags = FWRITE | O_NOFOLLOW | O_CREAT;
 
-	error = vn_open_cred(&nd, &flags, cmode, cred, -1);
+	error = vn_open_cred(&nd, &flags, cmode, cred, -1, -1);
 	if (error)
 		return (error);
 

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

@@ -1833,7 +1833,7 @@
 			NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE,
 			    "/dev/null", td);
 			flags = FREAD | FWRITE;
-			error = vn_open(&nd, &flags, 0, fd);
+			error = vn_open(&nd, &flags, 0, fd, -1);
 			if (error != 0) {
 				/*
 				 * Someone may have closed the entry in the

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

@@ -596,7 +596,7 @@
 		NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_USERSPACE,
 		    uap->fname, td);
 		flags = FREAD | FWRITE | O_NOFOLLOW;
-		error = vn_open(&nd, &flags, 0, -1);
+		error = vn_open(&nd, &flags, 0, -1, -1);
 		if (error) {
 			ktrace_exit(td);
 			return (error);

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

@@ -1515,7 +1515,7 @@
 		 */
 		NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, result, td);
 		flags = FREAD;
-		error = vn_open(&nd, &flags, 0, -1);
+		error = vn_open(&nd, &flags, 0, -1, -1);
 		if (error == 0) {
 			vfslocked = NDHASGIANT(&nd);
 			NDFREE(&nd, NDF_ONLY_PNBUF);
@@ -1566,7 +1566,7 @@
 
 	NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_SYSSPACE, pathbuf, td);
 	flags = FREAD;
-	error = vn_open(&nd, &flags, 0, -1);
+	error = vn_open(&nd, &flags, 0, -1, -1);
 	if (error)
 		goto bad;
 	vfslocked = NDHASGIANT(&nd);

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

@@ -3068,7 +3068,7 @@
 		return (EINVAL);
 	NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_SYSSPACE, name, td);
 	flags = O_CREAT | FWRITE | O_NOFOLLOW;
-	error = vn_open(&nd, &flags, S_IRUSR | S_IWUSR, -1);
+	error = vn_open(&nd, &flags, S_IRUSR | S_IWUSR, -1, -1);
 	free(name, M_TEMP);
 	if (error)
 		return (error);

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

@@ -566,7 +566,7 @@
 
     NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, filename, td);
     flags = FREAD;
-    error = vn_open(&nd, &flags, 0, -1);
+    error = vn_open(&nd, &flags, 0, -1, -1);
     if (error)
 	return error;
     vfslocked = NDHASGIANT(&nd);

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

@@ -407,7 +407,7 @@
 	}
 	snprintf(path, sizeof(path), "/dev/%s", cnd->cnd_cn->cn_name);
 	NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, td);
-	error = vn_open(&nd, &openflag, 0, -1);
+	error = vn_open(&nd, &openflag, 0, -1, -1);
 	if (error == 0) {
 		NDFREE(&nd, NDF_ONLY_PNBUF);
 		VOP_UNLOCK(nd.ni_vp, 0, td);

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

@@ -96,6 +96,12 @@
 SYSCTL_INT(_vfs, OID_AUTO, lookup_shared, CTLFLAG_RW, &lookup_shared, 0,
     "Enables/Disables shared locks for path name translation");
 
+int
+namei(struct nameidata *ndp)
+{
+	return namei1(ndp, -1);
+}
+
 /*
  * Convert a pathname into a pointer to a locked vnode.
  *
@@ -115,9 +121,11 @@
  *		call lookup to search path.
  *		if symbolic link, massage name in buffer and continue
  *	}
+ *
+ * The dirfd parameter determines the starting point, -1 means CWD.
  */
 int
-namei(struct nameidata *ndp)
+namei1(struct nameidata *ndp, int dirfd)
 {
 	struct filedesc *fdp;	/* pointer to file descriptor state */
 	char *cp;		/* pointer into pathname argument */
@@ -192,9 +200,40 @@
 	ndp->ni_rootdir = fdp->fd_rdir;
 	ndp->ni_topdir = fdp->fd_jdir;
 
-	dp = fdp->fd_cdir;
+	if (dirfd == -1) {
+		dp = fdp->fd_cdir;
+		VREF(dp);
+	} else {
+	   	struct file *fp;
+
+		/* XXX: */
+		if (fdp == NULL) {
+		   	FILEDESC_UNLOCK(fdp);
+			return (EBADF);
+		}
+		fp = fget_locked(fdp, dirfd);
+		if (fp == NULL || fp->f_ops == &badfileops) {
+		   	FILEDESC_UNLOCK(fdp);
+			return (EBADF);
+		}
+		fhold(fp);
+		if (fp->f_type != DTYPE_VNODE) {
+			fdrop(fp, td);
+			FILEDESC_UNLOCK(fdp);
+			return (EBADF);
+		}
+
+		dp = fp->f_vnode;
+
+		if (dp->v_type != VDIR) {
+			fdrop(fp, td);
+		   	FILEDESC_UNLOCK(fdp);
+			return (ENOTDIR);
+		}
+		VREF(dp);
+		fdrop(fp, td);
+	}
 	vfslocked = VFS_LOCK_GIANT(dp->v_mount);
-	VREF(dp);
 	FILEDESC_UNLOCK(fdp);
 	for (;;) {
 		/*

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

@@ -949,12 +949,12 @@
 	} */ *uap;
 {
 
-	return kern_open(td, uap->path, UIO_USERSPACE, uap->flags, uap->mode);
+	return kern_open(td, uap->path, UIO_USERSPACE, uap->flags, uap->mode, -1);
 }
 
 int
 kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
-    int mode)
+    int mode, int dirfd)
 {
 	struct proc *p = td->td_proc;
 	struct filedesc *fdp = p->p_fd;
@@ -982,7 +982,7 @@
 	cmode = ((mode &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT;
 	NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1 | MPSAFE, pathseg, path, td);
 	td->td_dupfd = -1;		/* XXX check for fdopen */
-	error = vn_open(&nd, &flags, cmode, indx);
+	error = vn_open(&nd, &flags, cmode, indx, dirfd);
 	if (error) {
 		/*
 		 * If the vn_open replaced the method vector, something
@@ -1105,8 +1105,8 @@
 	} */ *uap;
 {
 
-	return (kern_open(td, uap->path, UIO_USERSPACE,
-	    O_WRONLY | O_CREAT | O_TRUNC, uap->mode));
+	return kern_open(td, uap->path, UIO_USERSPACE,
+	    O_WRONLY | O_CREAT | O_TRUNC, uap->mode, -1);
 }
 #endif /* COMPAT_43 */
 

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

@@ -84,13 +84,11 @@
 };
 
 int
-vn_open(ndp, flagp, cmode, fdidx)
-	struct nameidata *ndp;
-	int *flagp, cmode, fdidx;
+vn_open(struct nameidata *ndp, int *flagp, int cmode, int fdidx, int dirfd)
 {
 	struct thread *td = ndp->ni_cnd.cn_thread;
 
-	return (vn_open_cred(ndp, flagp, cmode, td->td_ucred, fdidx));
+	return vn_open_cred(ndp, flagp, cmode, td->td_ucred, fdidx, dirfd);
 }
 
 /*
@@ -101,11 +99,8 @@
  * due to the NDINIT being done elsewhere.
  */
 int
-vn_open_cred(ndp, flagp, cmode, cred, fdidx)
-	struct nameidata *ndp;
-	int *flagp, cmode;
-	struct ucred *cred;
-	int fdidx;
+vn_open_cred(struct nameidata *ndp, int *flagp, int cmode, struct ucred *cred, 
+	int fdidx, int dirfd)
 {
 	struct vnode *vp;
 	struct mount *mp;
@@ -126,7 +121,7 @@
 		if ((fmode & O_EXCL) == 0 && (fmode & O_NOFOLLOW) == 0)
 			ndp->ni_cnd.cn_flags |= FOLLOW;
 		bwillwrite();
-		if ((error = namei(ndp)) != 0)
+		if ((error = namei1(ndp, dirfd)) != 0)
 			return (error);
 		vfslocked = NDHASGIANT(ndp);
 		if (!mpsafe)
@@ -184,7 +179,7 @@
 		ndp->ni_cnd.cn_flags = ISOPEN |
 		    ((fmode & O_NOFOLLOW) ? NOFOLLOW : FOLLOW) |
 		    LOCKSHARED | LOCKLEAF | MPSAFE | AUDITVNODE1;
-		if ((error = namei(ndp)) != 0)
+		if ((error = namei1(ndp, dirfd)) != 0)
 			return (error);
 		if (!mpsafe)
 			ndp->ni_cnd.cn_flags &= ~MPSAFE;

==== //depot/projects/linuxolator/src/sys/security/audit/audit_syscalls.c#8 (text) ====

@@ -567,7 +567,7 @@
 	NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1,
 	    UIO_USERSPACE, uap->path, td);
 	flags = AUDIT_OPEN_FLAGS;
-	error = vn_open(&nd, &flags, 0, -1);
+	error = vn_open(&nd, &flags, 0, -1, -1);
 	if (error)
 		return (error);
 	vfslocked = NDHASGIANT(&nd);

==== //depot/projects/linuxolator/src/sys/sys/namei.h#2 (text+ko) ====

@@ -177,6 +177,7 @@
 void NDFREE(struct nameidata *, const u_int);
 
 int	namei(struct nameidata *ndp);
+int	namei1(struct nameidata *ndp, int dirfd);
 int	lookup(struct nameidata *ndp);
 int	relookup(struct vnode *dvp, struct vnode **vpp,
 	    struct componentname *cnp);

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

@@ -119,7 +119,7 @@
 int     kern_nanosleep(struct thread *td, struct timespec *rqt,
 	    struct timespec *rmt);
 int	kern_open(struct thread *td, char *path, enum uio_seg pathseg,
-	    int flags, int mode);
+	    int flags, int mode, int dirfd);
 int	kern_pathconf(struct thread *td, char *path, enum uio_seg pathseg,
 	    int name);
 int	kern_preadv(struct thread *td, int fd, struct uio *auio, off_t offset);

==== //depot/projects/linuxolator/src/sys/sys/vnode.h#8 (text+ko) ====

@@ -613,9 +613,9 @@
 int	vn_isdisk(struct vnode *vp, int *errp);
 int	_vn_lock(struct vnode *vp, int flags, struct thread *td, char *file, int line);
 #define vn_lock(vp, flags, td) _vn_lock(vp, flags, td, __FILE__, __LINE__)
-int	vn_open(struct nameidata *ndp, int *flagp, int cmode, int fdidx);
+int	vn_open(struct nameidata *ndp, int *flagp, int cmode, int fdidx, int dirfd);
 int	vn_open_cred(struct nameidata *ndp, int *flagp, int cmode,
-	    struct ucred *cred, int fdidx);
+	    struct ucred *cred, int fdidx, int dirfd);
 int	vn_pollrecord(struct vnode *vp, struct thread *p, int events);
 int	vn_rdwr(enum uio_rw rw, struct vnode *vp, void *base,
 	    int len, off_t offset, enum uio_seg segflg, int ioflg,

==== //depot/projects/linuxolator/src/sys/ufs/ufs/ufs_quota.c#10 (text+ko) ====

@@ -524,7 +524,7 @@
 
 	NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_USERSPACE, fname, td);
 	flags = FREAD | FWRITE;
-	error = vn_open(&nd, &flags, 0, -1);
+	error = vn_open(&nd, &flags, 0, -1, -1);
 	if (error)
 		return (error);
 	vfslocked = NDHASGIANT(&nd);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200704041555.l34FtWLl080167>