From owner-p4-projects@FreeBSD.ORG Mon Apr 2 13:17:49 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 BFF0D16A40B; Mon, 2 Apr 2007 13:17:49 +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 63A9816A408; Mon, 2 Apr 2007 13:17:49 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.freebsd.org (Postfix) with ESMTP id E9D7A13C4D1; Mon, 2 Apr 2007 13:17:48 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.8/8.13.8) with ESMTP id l32DHiQa085527; Mon, 2 Apr 2007 09:17:46 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: Roman Divacky Date: Mon, 2 Apr 2007 09:09:25 -0400 User-Agent: KMail/1.9.6 References: <200704011736.l31HaDhx068622@repoman.freebsd.org> In-Reply-To: <200704011736.l31HaDhx068622@repoman.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200704020909.26327.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Mon, 02 Apr 2007 09:17:47 -0400 (EDT) X-Virus-Scanned: ClamAV 0.88.3/2997/Mon Apr 2 06:19:52 2007 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Perforce Change Reviews Subject: Re: 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: Mon, 02 Apr 2007 13:17:50 -0000 On Sunday 01 April 2007 01:36:13 pm Roman Divacky wrote: > 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); > +} Why not use kern_close()? -- John Baldwin