Date: Sun, 3 Jun 2007 11:10:10 GMT From: Roman Divacky <rdivacky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 120832 for review Message-ID: <200706031110.l53BAAHU030007@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=120832 Change 120832 by rdivacky@rdivacky_witten on 2007/06/03 11:10:04 Implement linux_fstatat64 using kern_[l]statat. Suggested by: rwatson Affected files ... .. //depot/projects/soc2007/rdivacky/linux_at/sys/compat/linux/linux_stats.c#5 edit Differences ... ==== //depot/projects/soc2007/rdivacky/linux_at/sys/compat/linux/linux_stats.c#5 (text+ko) ==== @@ -579,35 +579,21 @@ return (error); } -/* XXX: racy? */ int linux_fstatat64(struct thread *td, struct linux_fstatat64_args *args) { - int error; - char *path, *newpath; - int fd, dfd, flags = O_RDONLY; + char *path; + int error, dfd; struct stat buf; if (args->flag & ~LINUX_AT_SYMLINK_NOFOLLOW) return (EINVAL); - if (args->flag & LINUX_AT_SYMLINK_NOFOLLOW) - flags |= O_NOFOLLOW; + LCONVPATHEXIST(td, args->filename, &path); - /* open the file */ - 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, newpath, args->flag); + printf(ARGS(fstatat64, "%i, %s, %i"), args->dfd, args->path, args->flag); #endif if (args->dfd == LINUX_AT_FDCWD) @@ -615,26 +601,17 @@ else dfd = args->dfd; - error = kern_openat(td, newpath, UIO_SYSSPACE, flags, 0, dfd); - if (error) { - LFREEPATH(newpath); - return (error); - } - /* file opened */ - fd = td->td_retval[0]; - td->td_retval[0] = 0; - - /* do the actual fstat */ - - error = kern_fstat(td, fd, &buf); + if (args->flags & LINUX_AT_SYMLINK_NOFOLLOW) + error = kern_statat(td, fd, &buf, dfd); + else + error = kern_lstatat(td, fd, &buf, dfd); + translate_fd_major_minor(td, fd, &buf); if (!error) error = stat64_copyout(&buf, args->statbuf); + LFREEPATH(path); - /* close the opened file */ - kern_close(td, fd); - LFREEPATH(newpath); - return (0); + return (error); } #endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200706031110.l53BAAHU030007>