svr4_misc.c (159960) | svr4_misc.c (160276) |
---|---|
1/*- 2 * Copyright (c) 1998 Mark Newton 3 * Copyright (c) 1994 Christos Zoulas 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 19 unchanged lines hidden (view full) --- 28/* 29 * SVR4 compatibility module. 30 * 31 * SVR4 system calls that are implemented differently in BSD are 32 * handled here. 33 */ 34 35#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1998 Mark Newton 3 * Copyright (c) 1994 Christos Zoulas 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 19 unchanged lines hidden (view full) --- 28/* 29 * SVR4 compatibility module. 30 * 31 * SVR4 system calls that are implemented differently in BSD are 32 * handled here. 33 */ 34 35#include <sys/cdefs.h> |
36__FBSDID("$FreeBSD: head/sys/compat/svr4/svr4_misc.c 159960 2006-06-26 18:36:57Z jhb $"); | 36__FBSDID("$FreeBSD: head/sys/compat/svr4/svr4_misc.c 160276 2006-07-11 20:52:08Z jhb $"); |
37 38#include "opt_mac.h" 39 40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/dirent.h> 43#include <sys/fcntl.h> 44#include <sys/filedesc.h> --- 190 unchanged lines hidden (view full) --- 235 int len, reclen; /* BSD-format */ 236 caddr_t outp; /* SVR4-format */ 237 int resid, svr4reclen=0; /* SVR4-format */ 238 struct file *fp; 239 struct uio auio; 240 struct iovec aiov; 241 off_t off; 242 struct svr4_dirent64 svr4_dirent; | 37 38#include "opt_mac.h" 39 40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/dirent.h> 43#include <sys/fcntl.h> 44#include <sys/filedesc.h> --- 190 unchanged lines hidden (view full) --- 235 int len, reclen; /* BSD-format */ 236 caddr_t outp; /* SVR4-format */ 237 int resid, svr4reclen=0; /* SVR4-format */ 238 struct file *fp; 239 struct uio auio; 240 struct iovec aiov; 241 off_t off; 242 struct svr4_dirent64 svr4_dirent; |
243 int buflen, error, eofflag, nbytes, justone; | 243 int buflen, error, eofflag, nbytes, justone, vfslocked; |
244 u_long *cookies = NULL, *cookiep; 245 int ncookies; 246 247 DPRINTF(("svr4_sys_getdents64(%d, *, %d)\n", 248 uap->fd, uap->nbytes)); 249 if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0) { 250 return (error); 251 } 252 253 if ((fp->f_flag & FREAD) == 0) { 254 fdrop(fp, td); 255 return (EBADF); 256 } 257 258 vp = fp->f_vnode; | 244 u_long *cookies = NULL, *cookiep; 245 int ncookies; 246 247 DPRINTF(("svr4_sys_getdents64(%d, *, %d)\n", 248 uap->fd, uap->nbytes)); 249 if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0) { 250 return (error); 251 } 252 253 if ((fp->f_flag & FREAD) == 0) { 254 fdrop(fp, td); 255 return (EBADF); 256 } 257 258 vp = fp->f_vnode; |
259 | 259 vfslocked = VFS_LOCK_GIANT(vp->v_mount); |
260 if (vp->v_type != VDIR) { | 260 if (vp->v_type != VDIR) { |
261 VFS_UNLOCK_GIANT(vfslocked); |
|
261 fdrop(fp, td); 262 return (EINVAL); 263 } 264 265 nbytes = uap->nbytes; 266 if (nbytes == 1) { 267 nbytes = sizeof (struct svr4_dirent64); 268 justone = 1; --- 120 unchanged lines hidden (view full) --- 389 390 if (justone) 391 nbytes = resid + svr4reclen; 392 393eof: 394 td->td_retval[0] = nbytes - resid; 395out: 396 VOP_UNLOCK(vp, 0, td); | 262 fdrop(fp, td); 263 return (EINVAL); 264 } 265 266 nbytes = uap->nbytes; 267 if (nbytes == 1) { 268 nbytes = sizeof (struct svr4_dirent64); 269 justone = 1; --- 120 unchanged lines hidden (view full) --- 390 391 if (justone) 392 nbytes = resid + svr4reclen; 393 394eof: 395 td->td_retval[0] = nbytes - resid; 396out: 397 VOP_UNLOCK(vp, 0, td); |
398 VFS_UNLOCK_GIANT(vfslocked); |
|
397 fdrop(fp, td); 398 if (cookies) 399 free(cookies, M_TEMP); 400 free(buf, M_TEMP); 401 return error; 402} 403 404 --- 8 unchanged lines hidden (view full) --- 413 int len, reclen; /* BSD-format */ 414 caddr_t outp; /* SVR4-format */ 415 int resid, svr4_reclen; /* SVR4-format */ 416 struct file *fp; 417 struct uio auio; 418 struct iovec aiov; 419 struct svr4_dirent idb; 420 off_t off; /* true file offset */ | 399 fdrop(fp, td); 400 if (cookies) 401 free(cookies, M_TEMP); 402 free(buf, M_TEMP); 403 return error; 404} 405 406 --- 8 unchanged lines hidden (view full) --- 415 int len, reclen; /* BSD-format */ 416 caddr_t outp; /* SVR4-format */ 417 int resid, svr4_reclen; /* SVR4-format */ 418 struct file *fp; 419 struct uio auio; 420 struct iovec aiov; 421 struct svr4_dirent idb; 422 off_t off; /* true file offset */ |
421 int buflen, error, eofflag; | 423 int buflen, error, eofflag, vfslocked; |
422 u_long *cookiebuf = NULL, *cookie; 423 int ncookies = 0, *retval = td->td_retval; 424 425 if (uap->nbytes < 0) 426 return (EINVAL); 427 428 if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0) 429 return (error); 430 431 if ((fp->f_flag & FREAD) == 0) { 432 fdrop(fp, td); 433 return (EBADF); 434 } 435 436 vp = fp->f_vnode; | 424 u_long *cookiebuf = NULL, *cookie; 425 int ncookies = 0, *retval = td->td_retval; 426 427 if (uap->nbytes < 0) 428 return (EINVAL); 429 430 if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0) 431 return (error); 432 433 if ((fp->f_flag & FREAD) == 0) { 434 fdrop(fp, td); 435 return (EBADF); 436 } 437 438 vp = fp->f_vnode; |
439 vfslocked = VFS_LOCK_GIANT(vp->v_mount); |
|
437 if (vp->v_type != VDIR) { | 440 if (vp->v_type != VDIR) { |
441 VFS_UNLOCK_GIANT(vfslocked); |
|
438 fdrop(fp, td); 439 return (EINVAL); 440 } 441 442 buflen = min(MAXBSIZE, uap->nbytes); 443 buf = malloc(buflen, M_TEMP, M_WAITOK); 444 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); 445 off = fp->f_offset; --- 73 unchanged lines hidden (view full) --- 519 if (outp == uap->buf) 520 goto again; 521 fp->f_offset = off; /* update the vnode offset */ 522 523eof: 524 *retval = uap->nbytes - resid; 525out: 526 VOP_UNLOCK(vp, 0, td); | 442 fdrop(fp, td); 443 return (EINVAL); 444 } 445 446 buflen = min(MAXBSIZE, uap->nbytes); 447 buf = malloc(buflen, M_TEMP, M_WAITOK); 448 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); 449 off = fp->f_offset; --- 73 unchanged lines hidden (view full) --- 523 if (outp == uap->buf) 524 goto again; 525 fp->f_offset = off; /* update the vnode offset */ 526 527eof: 528 *retval = uap->nbytes - resid; 529out: 530 VOP_UNLOCK(vp, 0, td); |
531 VFS_UNLOCK_GIANT(vfslocked); |
|
527 fdrop(fp, td); 528 if (cookiebuf) 529 free(cookiebuf, M_TEMP); 530 free(buf, M_TEMP); 531 return error; 532} 533 534 --- 1086 unchanged lines hidden --- | 532 fdrop(fp, td); 533 if (cookiebuf) 534 free(cookiebuf, M_TEMP); 535 free(buf, M_TEMP); 536 return error; 537} 538 539 --- 1086 unchanged lines hidden --- |