Deleted Added
full compact
kern_descrip.c (11607) kern_descrip.c (12221)
1/*
2 * Copyright (c) 1982, 1986, 1989, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94
1/*
2 * Copyright (c) 1982, 1986, 1989, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94
39 * $Id: kern_descrip.c,v 1.11 1995/10/08 00:06:00 swallace Exp $
39 * $Id: kern_descrip.c,v 1.12 1995/10/21 08:38:09 davidg Exp $
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/sysproto.h>
44#include <sys/filedesc.h>
45#include <sys/kernel.h>
46#include <sys/vnode.h>
47#include <sys/proc.h>
48#include <sys/file.h>
49#include <sys/socket.h>
50#include <sys/socketvar.h>
51#include <sys/stat.h>

--- 8 unchanged lines hidden (view full) ---

60 * Descriptor management.
61 */
62struct file *filehead; /* head of list of open files */
63int nfiles; /* actual number of open files */
64
65/*
66 * System calls on descriptors.
67 */
45#include <sys/filedesc.h>
46#include <sys/kernel.h>
47#include <sys/vnode.h>
48#include <sys/proc.h>
49#include <sys/file.h>
50#include <sys/socket.h>
51#include <sys/socketvar.h>
52#include <sys/stat.h>

--- 8 unchanged lines hidden (view full) ---

61 * Descriptor management.
62 */
63struct file *filehead; /* head of list of open files */
64int nfiles; /* actual number of open files */
65
66/*
67 * System calls on descriptors.
68 */
69#ifndef _SYS_SYSPROTO_H_
68struct getdtablesize_args {
69 int dummy;
70};
70struct getdtablesize_args {
71 int dummy;
72};
73#endif
71/* ARGSUSED */
72int
73getdtablesize(p, uap, retval)
74 struct proc *p;
75 struct getdtablesize_args *uap;
76 int *retval;
77{
78
79 *retval = min((int)p->p_rlimit[RLIMIT_NOFILE].rlim_cur, maxfilesperproc);
80 return (0);
81}
82
83/*
84 * Duplicate a file descriptor to a particular value.
85 */
74/* ARGSUSED */
75int
76getdtablesize(p, uap, retval)
77 struct proc *p;
78 struct getdtablesize_args *uap;
79 int *retval;
80{
81
82 *retval = min((int)p->p_rlimit[RLIMIT_NOFILE].rlim_cur, maxfilesperproc);
83 return (0);
84}
85
86/*
87 * Duplicate a file descriptor to a particular value.
88 */
89#ifndef _SYS_SYSPROTO_H_
86struct dup2_args {
87 u_int from;
88 u_int to;
89};
90struct dup2_args {
91 u_int from;
92 u_int to;
93};
94#endif
90/* ARGSUSED */
91int
92dup2(p, uap, retval)
93 struct proc *p;
94 struct dup2_args *uap;
95 int *retval;
96{
97 register struct filedesc *fdp = p->p_fd;

--- 23 unchanged lines hidden (view full) ---

121 (void) closef(fdp->fd_ofiles[new], p);
122 }
123 return (finishdup(fdp, (int)old, (int)new, retval));
124}
125
126/*
127 * Duplicate a file descriptor.
128 */
95/* ARGSUSED */
96int
97dup2(p, uap, retval)
98 struct proc *p;
99 struct dup2_args *uap;
100 int *retval;
101{
102 register struct filedesc *fdp = p->p_fd;

--- 23 unchanged lines hidden (view full) ---

126 (void) closef(fdp->fd_ofiles[new], p);
127 }
128 return (finishdup(fdp, (int)old, (int)new, retval));
129}
130
131/*
132 * Duplicate a file descriptor.
133 */
134#ifndef _SYS_SYSPROTO_H_
129struct dup_args {
130 u_int fd;
131};
135struct dup_args {
136 u_int fd;
137};
138#endif
132/* ARGSUSED */
133int
134dup(p, uap, retval)
135 struct proc *p;
136 struct dup_args *uap;
137 int *retval;
138{
139 register struct filedesc *fdp;

--- 15 unchanged lines hidden (view full) ---

155 if ((error = fdalloc(p, 0, &new)))
156 return (error);
157 return (finishdup(fdp, (int)old, new, retval));
158}
159
160/*
161 * The file control system call.
162 */
139/* ARGSUSED */
140int
141dup(p, uap, retval)
142 struct proc *p;
143 struct dup_args *uap;
144 int *retval;
145{
146 register struct filedesc *fdp;

--- 15 unchanged lines hidden (view full) ---

162 if ((error = fdalloc(p, 0, &new)))
163 return (error);
164 return (finishdup(fdp, (int)old, new, retval));
165}
166
167/*
168 * The file control system call.
169 */
170#ifndef _SYS_SYSPROTO_H_
163struct fcntl_args {
164 int fd;
165 int cmd;
166 int arg;
167};
171struct fcntl_args {
172 int fd;
173 int cmd;
174 int arg;
175};
176#endif
168/* ARGSUSED */
169int
170fcntl(p, uap, retval)
171 struct proc *p;
172 register struct fcntl_args *uap;
173 int *retval;
174{
175 register struct filedesc *fdp = p->p_fd;

--- 147 unchanged lines hidden (view full) ---

323 fdp->fd_lastfile = new;
324 *retval = new;
325 return (0);
326}
327
328/*
329 * Close a file descriptor.
330 */
177/* ARGSUSED */
178int
179fcntl(p, uap, retval)
180 struct proc *p;
181 register struct fcntl_args *uap;
182 int *retval;
183{
184 register struct filedesc *fdp = p->p_fd;

--- 147 unchanged lines hidden (view full) ---

332 fdp->fd_lastfile = new;
333 *retval = new;
334 return (0);
335}
336
337/*
338 * Close a file descriptor.
339 */
340#ifndef _SYS_SYSPROTO_H_
331struct close_args {
332 int fd;
333};
341struct close_args {
342 int fd;
343};
344#endif
334/* ARGSUSED */
335int
336close(p, uap, retval)
337 struct proc *p;
338 struct close_args *uap;
339 int *retval;
340{
341 register struct filedesc *fdp = p->p_fd;

--- 15 unchanged lines hidden (view full) ---

357 *pf = 0;
358 return (closef(fp, p));
359}
360
361#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
362/*
363 * Return status information about a file descriptor.
364 */
345/* ARGSUSED */
346int
347close(p, uap, retval)
348 struct proc *p;
349 struct close_args *uap;
350 int *retval;
351{
352 register struct filedesc *fdp = p->p_fd;

--- 15 unchanged lines hidden (view full) ---

368 *pf = 0;
369 return (closef(fp, p));
370}
371
372#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
373/*
374 * Return status information about a file descriptor.
375 */
376#ifndef _SYS_SYSPROTO_H_
365struct ofstat_args {
366 int fd;
367 struct ostat *sb;
368};
377struct ofstat_args {
378 int fd;
379 struct ostat *sb;
380};
381#endif
369/* ARGSUSED */
370int
371ofstat(p, uap, retval)
372 struct proc *p;
373 register struct ofstat_args *uap;
374 int *retval;
375{
376 register struct filedesc *fdp = p->p_fd;

--- 24 unchanged lines hidden (view full) ---

401 error = copyout((caddr_t)&oub, (caddr_t)uap->sb, sizeof (oub));
402 return (error);
403}
404#endif /* COMPAT_43 || COMPAT_SUNOS */
405
406/*
407 * Return status information about a file descriptor.
408 */
382/* ARGSUSED */
383int
384ofstat(p, uap, retval)
385 struct proc *p;
386 register struct ofstat_args *uap;
387 int *retval;
388{
389 register struct filedesc *fdp = p->p_fd;

--- 24 unchanged lines hidden (view full) ---

414 error = copyout((caddr_t)&oub, (caddr_t)uap->sb, sizeof (oub));
415 return (error);
416}
417#endif /* COMPAT_43 || COMPAT_SUNOS */
418
419/*
420 * Return status information about a file descriptor.
421 */
422#ifndef _SYS_SYSPROTO_H_
409struct fstat_args {
410 int fd;
411 struct stat *sb;
412};
423struct fstat_args {
424 int fd;
425 struct stat *sb;
426};
427#endif
413/* ARGSUSED */
414int
415fstat(p, uap, retval)
416 struct proc *p;
417 register struct fstat_args *uap;
418 int *retval;
419{
420 register struct filedesc *fdp = p->p_fd;

--- 21 unchanged lines hidden (view full) ---

442 if (error == 0)
443 error = copyout((caddr_t)&ub, (caddr_t)uap->sb, sizeof (ub));
444 return (error);
445}
446
447/*
448 * Return pathconf information about a file descriptor.
449 */
428/* ARGSUSED */
429int
430fstat(p, uap, retval)
431 struct proc *p;
432 register struct fstat_args *uap;
433 int *retval;
434{
435 register struct filedesc *fdp = p->p_fd;

--- 21 unchanged lines hidden (view full) ---

457 if (error == 0)
458 error = copyout((caddr_t)&ub, (caddr_t)uap->sb, sizeof (ub));
459 return (error);
460}
461
462/*
463 * Return pathconf information about a file descriptor.
464 */
465#ifndef _SYS_SYSPROTO_H_
450struct fpathconf_args {
451 int fd;
452 int name;
453};
466struct fpathconf_args {
467 int fd;
468 int name;
469};
470#endif
454/* ARGSUSED */
455int
456fpathconf(p, uap, retval)
457 struct proc *p;
458 register struct fpathconf_args *uap;
459 int *retval;
460{
461 struct filedesc *fdp = p->p_fd;

--- 345 unchanged lines hidden (view full) ---

807}
808
809/*
810 * Apply an advisory lock on a file descriptor.
811 *
812 * Just attempt to get a record lock of the requested type on
813 * the entire file (l_whence = SEEK_SET, l_start = 0, l_len = 0).
814 */
471/* ARGSUSED */
472int
473fpathconf(p, uap, retval)
474 struct proc *p;
475 register struct fpathconf_args *uap;
476 int *retval;
477{
478 struct filedesc *fdp = p->p_fd;

--- 345 unchanged lines hidden (view full) ---

824}
825
826/*
827 * Apply an advisory lock on a file descriptor.
828 *
829 * Just attempt to get a record lock of the requested type on
830 * the entire file (l_whence = SEEK_SET, l_start = 0, l_len = 0).
831 */
832#ifndef _SYS_SYSPROTO_H_
815struct flock_args {
816 int fd;
817 int how;
818};
833struct flock_args {
834 int fd;
835 int how;
836};
837#endif
819/* ARGSUSED */
820int
821flock(p, uap, retval)
822 struct proc *p;
823 register struct flock_args *uap;
824 int *retval;
825{
826 register struct filedesc *fdp = p->p_fd;

--- 137 unchanged lines hidden ---
838/* ARGSUSED */
839int
840flock(p, uap, retval)
841 struct proc *p;
842 register struct flock_args *uap;
843 int *retval;
844{
845 register struct filedesc *fdp = p->p_fd;

--- 137 unchanged lines hidden ---