From owner-p4-projects@FreeBSD.ORG Sun Apr 1 17:36:14 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5F60016A404; Sun, 1 Apr 2007 17:36:14 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1723016A401 for ; Sun, 1 Apr 2007 17:36:14 +0000 (UTC) (envelope-from rdivacky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id F1A3E13C459 for ; Sun, 1 Apr 2007 17:36:13 +0000 (UTC) (envelope-from rdivacky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l31HaDRN068627 for ; Sun, 1 Apr 2007 17:36:13 GMT (envelope-from rdivacky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l31HaDhx068622 for perforce@freebsd.org; Sun, 1 Apr 2007 17:36:13 GMT (envelope-from rdivacky@FreeBSD.org) Date: Sun, 1 Apr 2007 17:36:13 GMT Message-Id: <200704011736.l31HaDhx068622@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to rdivacky@FreeBSD.org using -f From: Roman Divacky To: Perforce Change Reviews Cc: Subject: PERFORCE change 117109 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Apr 2007 17:36:14 -0000 http://perforce.freebsd.org/chv.cgi?CH=117109 Change 117109 by rdivacky@rdivacky_witten on 2007/04/01 17:35:45 Semi-implement fstatat64() - only compile tested. Check for fp being a vnode before referencing fp->f_vnode [1] Pointed out by: rwatson I commit this because my harddisk is likely to die in a few hours. Affected files ... .. //depot/projects/linuxolator/src/sys/compat/linux/linux_file.c#20 edit .. //depot/projects/linuxolator/src/sys/compat/linux/linux_stats.c#8 edit .. //depot/projects/linuxolator/src/sys/compat/linux/linux_util.h#5 edit Differences ... ==== //depot/projects/linuxolator/src/sys/compat/linux/linux_file.c#20 (text+ko) ==== @@ -105,6 +105,10 @@ 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) { @@ -144,7 +148,7 @@ } -static int +int linux_common_open(struct thread *td, char *path, int l_flags, int mode, int openat) { struct proc *p = td->td_proc; @@ -1387,12 +1391,6 @@ } int -linux_fstatat64(struct thread *td, struct linux_fstatat64_args *args) -{ - return (ENOSYS); -} - -int linux_fchownat(struct thread *td, struct linux_fchownat_args *args) { return (ENOSYS); ==== //depot/projects/linuxolator/src/sys/compat/linux/linux_stats.c#8 (text+ko) ==== @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -593,4 +594,52 @@ return (error); } +/* XXX: racy? */ +int +linux_fstatat64(struct thread *td, struct linux_fstatat64_args *args) +{ + int error; + char *newpath, *oldpath, *freebuf = NULL, *path; + int fd; + struct close_args cargs; + struct stat buf; + + /* open the file */ + oldpath = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); + error = copyinstr(args->pathname, oldpath, MAXPATHLEN, NULL); +#ifdef DEBUG + if (ldebug(fstatat64)) + printf(ARGS(fstatat64, "%i, %s, %i"), args->dfd, args->pathname, 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); + + error = linux_common_open(td, path, O_RDONLY, 0, 1); + free(oldpath, M_TEMP); + if (error) + return (error); + /* file opened */ + fd = td->td_retval[0]; + td->td_retval[0] = 0; + + /* do the actual fstat */ + + error = kern_fstat(td, fd, &buf); + translate_fd_major_minor(td, fd, &buf); + if (!error) + error = stat64_copyout(&buf, args->statbuf); + + /* close the opened file */ + cargs.fd = fd; + close(td, &cargs); + return (0); +} + #endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */ ==== //depot/projects/linuxolator/src/sys/compat/linux/linux_util.h#5 (text+ko) ==== @@ -106,5 +106,6 @@ /* XXX: doesnt belong here */ int linux_at(struct thread *td, int dirfd, char *filename, char **newpath, char **freebuf); +int linux_common_open(struct thread *td, char *path, int l_flags, int mode, int openat); #endif /* !_LINUX_UTIL_H_ */