Date: Sun, 3 Jun 2007 11:54:31 GMT From: Roman Divacky <rdivacky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 120835 for review Message-ID: <200706031154.l53BsVQU077984@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=120835 Change 120835 by rdivacky@rdivacky_witten on 2007/06/03 11:53:31 Compilation etc. fixes. Affected files ... .. //depot/projects/soc2007/rdivacky/linux_at/sys/compat/linux/linux_stats.c#6 edit .. //depot/projects/soc2007/rdivacky/linux_at/sys/kern/vfs_syscalls.c#9 edit Differences ... ==== //depot/projects/soc2007/rdivacky/linux_at/sys/compat/linux/linux_stats.c#6 (text+ko) ==== @@ -133,6 +133,25 @@ fdclose(fdp, fdp->fd_ofiles[fd], fd, td); } +static void +translate_path_major_minor_at(struct thread *td, char *path, struct stat *buf, int dfd) +{ + struct proc *p = td->td_proc; + struct filedesc *fdp = p->p_fd; + int fd; + int temp; + + if (!S_ISCHR(buf->st_mode) && !S_ISBLK(buf->st_mode)) + return; + temp = td->td_retval[0]; + if (kern_openat(td, path, UIO_SYSSPACE, O_RDONLY, 0, dfd) != 0) + return; + fd = td->td_retval[0]; + td->td_retval[0] = temp; + translate_fd_major_minor(td, fd, buf); + fdclose(fdp, fdp->fd_ofiles[fd], fd, td); +} + static int newstat_copyout(struct stat *buf, void *ubuf) { @@ -589,11 +608,11 @@ if (args->flag & ~LINUX_AT_SYMLINK_NOFOLLOW) return (EINVAL); - LCONVPATHEXIST(td, args->filename, &path); + LCONVPATHEXIST(td, args->pathname, &path); #ifdef DEBUG if (ldebug(fstatat64)) - printf(ARGS(fstatat64, "%i, %s, %i"), args->dfd, args->path, args->flag); + printf(ARGS(fstatat64, "%i, %s, %i"), args->dfd, path, args->flag); #endif if (args->dfd == LINUX_AT_FDCWD) @@ -601,12 +620,12 @@ else dfd = args->dfd; - if (args->flags & LINUX_AT_SYMLINK_NOFOLLOW) - error = kern_statat(td, fd, &buf, dfd); + if (args->flag & LINUX_AT_SYMLINK_NOFOLLOW) + error = kern_statat(td, path, UIO_SYSSPACE, &buf, dfd); else - error = kern_lstatat(td, fd, &buf, dfd); + error = kern_lstatat(td, path, UIO_SYSSPACE, &buf, dfd); - translate_fd_major_minor(td, fd, &buf); + translate_path_major_minor_at(td, args->pathname, &buf, dfd); if (!error) error = stat64_copyout(&buf, args->statbuf); LFREEPATH(path); ==== //depot/projects/soc2007/rdivacky/linux_at/sys/kern/vfs_syscalls.c#9 (text+ko) ==== @@ -1033,7 +1033,7 @@ fp = nfp; cmode = ((mode &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT; td->td_dupfd = -1; /* XXX check for fdopen */ - error = vn_open(&nd, &flags, cmode, fp); + error = vn_open(nd, &flags, cmode, fp); if (error) { /* * If the vn_open replaced the method vector, something @@ -2134,6 +2134,7 @@ kern_stat(struct thread *td, char *path, enum uio_seg pathseg, struct stat *sbp) { struct nameidata nd; + int error; NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | MPSAFE | AUDITVNODE1, @@ -2141,11 +2142,11 @@ if ((error = namei(&nd)) != 0) return (error); - return kern_common_stat(td, sbp, nd); + return kern_common_stat(td, sbp, &nd); } int -kern_statat(struct thread *td, char *path, enum uio_seg pathseg, struct stat *sbp, int dfd) +kern_statat(struct thread *td, char *path, enum uio_seg pathseg, struct stat *sbp, int dirfd) { int error; struct nameidata nd; @@ -2177,13 +2178,14 @@ struct stat sb; int error, vfslocked; - vfslocked = NDHASGIANT(&nd); + vfslocked = NDHASGIANT(nd); error = vn_stat(nd->ni_vp, &sb, td->td_ucred, NOCRED, td); - NDFREE(&nd, NDF_ONLY_PNBUF); + NDFREE(nd, NDF_ONLY_PNBUF); vput(nd->ni_vp); VFS_UNLOCK_GIANT(vfslocked); + /* dont bother with the path as this is hopefully going away soon */ if (mtx_owned(&Giant)) - printf("stat(%d): %s\n", vfslocked, path); + printf("stat(%d):\n", vfslocked); if (error) return (error); *sbp = sb; @@ -2219,6 +2221,7 @@ kern_lstat(struct thread *td, char *path, enum uio_seg pathseg, struct stat *sbp) { struct nameidata nd; + int error; NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKSHARED | MPSAFE | AUDITVNODE1, @@ -2226,11 +2229,11 @@ if ((error = namei(&nd)) != 0) return (error); - return kern_common_lstat(td, sbp, &nd) + return kern_common_lstat(td, sbp, &nd); } int -kern_lstatat(struct thread *td, char *path, enum uio_seg pathseg, struct stat *sbp, int dfd) +kern_lstatat(struct thread *td, char *path, enum uio_seg pathseg, struct stat *sbp, int dirfd) { int error; struct nameidata nd; @@ -2263,10 +2266,10 @@ struct stat sb; int error, vfslocked; - vfslocked = NDHASGIANT(&nd); + vfslocked = NDHASGIANT(nd); vp = nd->ni_vp; error = vn_stat(vp, &sb, td->td_ucred, NOCRED, td); - NDFREE(&nd, NDF_ONLY_PNBUF); + NDFREE(nd, NDF_ONLY_PNBUF); vput(vp); VFS_UNLOCK_GIANT(vfslocked); if (error)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200706031154.l53BsVQU077984>