linux_file.c (240387) | linux_file.c (241896) |
---|---|
1/*- 2 * Copyright (c) 1994-1995 S��ren Schmidt 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1994-1995 S��ren Schmidt 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/sys/compat/linux/linux_file.c 240387 2012-09-12 10:12:03Z kevlo $"); | 30__FBSDID("$FreeBSD: head/sys/compat/linux/linux_file.c 241896 2012-10-22 17:50:54Z kib $"); |
31 32#include "opt_compat.h" 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/capability.h> 37#include <sys/conf.h> 38#include <sys/dirent.h> --- 293 unchanged lines hidden (view full) --- 332 struct file *fp; 333 struct uio auio; 334 struct iovec aiov; 335 off_t off; 336 struct l_dirent *linux_dirent; 337 struct l_dirent64 *linux_dirent64; 338 int buflen, error, eofflag, nbytes, justone; 339 u_long *cookies = NULL, *cookiep; | 31 32#include "opt_compat.h" 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/capability.h> 37#include <sys/conf.h> 38#include <sys/dirent.h> --- 293 unchanged lines hidden (view full) --- 332 struct file *fp; 333 struct uio auio; 334 struct iovec aiov; 335 off_t off; 336 struct l_dirent *linux_dirent; 337 struct l_dirent64 *linux_dirent64; 338 int buflen, error, eofflag, nbytes, justone; 339 u_long *cookies = NULL, *cookiep; |
340 int ncookies, vfslocked; | 340 int ncookies; |
341 342 nbytes = args->count; 343 if (nbytes == 1) { 344 /* readdir(2) case. Always struct dirent. */ 345 if (is64bit) 346 return (EINVAL); 347 nbytes = sizeof(*linux_dirent); 348 justone = 1; --- 5 unchanged lines hidden (view full) --- 354 355 if ((fp->f_flag & FREAD) == 0) { 356 fdrop(fp, td); 357 return (EBADF); 358 } 359 360 off = foffset_lock(fp, 0); 361 vp = fp->f_vnode; | 341 342 nbytes = args->count; 343 if (nbytes == 1) { 344 /* readdir(2) case. Always struct dirent. */ 345 if (is64bit) 346 return (EINVAL); 347 nbytes = sizeof(*linux_dirent); 348 justone = 1; --- 5 unchanged lines hidden (view full) --- 354 355 if ((fp->f_flag & FREAD) == 0) { 356 fdrop(fp, td); 357 return (EBADF); 358 } 359 360 off = foffset_lock(fp, 0); 361 vp = fp->f_vnode; |
362 vfslocked = VFS_LOCK_GIANT(vp->v_mount); | |
363 if (vp->v_type != VDIR) { | 362 if (vp->v_type != VDIR) { |
364 VFS_UNLOCK_GIANT(vfslocked); | |
365 foffset_unlock(fp, off, 0); 366 fdrop(fp, td); 367 return (EINVAL); 368 } 369 370 371 buflen = max(LINUX_DIRBLKSIZ, nbytes); 372 buflen = min(buflen, MAXBSIZE); --- 143 unchanged lines hidden (view full) --- 516eof: 517 td->td_retval[0] = nbytes - resid; 518 519out: 520 if (cookies) 521 free(cookies, M_TEMP); 522 523 VOP_UNLOCK(vp, 0); | 363 foffset_unlock(fp, off, 0); 364 fdrop(fp, td); 365 return (EINVAL); 366 } 367 368 369 buflen = max(LINUX_DIRBLKSIZ, nbytes); 370 buflen = min(buflen, MAXBSIZE); --- 143 unchanged lines hidden (view full) --- 514eof: 515 td->td_retval[0] = nbytes - resid; 516 517out: 518 if (cookies) 519 free(cookies, M_TEMP); 520 521 VOP_UNLOCK(vp, 0); |
524 VFS_UNLOCK_GIANT(vfslocked); | |
525 foffset_unlock(fp, off, 0); 526 fdrop(fp, td); 527 free(buf, M_TEMP); 528 free(lbuf, M_TEMP); 529 return (error); 530} 531 532int --- 1090 unchanged lines hidden --- | 522 foffset_unlock(fp, off, 0); 523 fdrop(fp, td); 524 free(buf, M_TEMP); 525 free(lbuf, M_TEMP); 526 return (error); 527} 528 529int --- 1090 unchanged lines hidden --- |