FreeBSD Bugzilla – Attachment 149353 Details for
Bug 194985
getdtablecount new syscall from openbsd
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Proposed patch
getdtablecount.txt (text/plain), 8.96 KB, created by
David CARLIER
on 2014-11-13 08:20:41 UTC
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
David CARLIER
Created:
2014-11-13 08:20:41 UTC
Size:
8.96 KB
patch
obsolete
>diff --git a/include/unistd.h b/include/unistd.h >index 40ed78e..310200b 100644 >--- a/include/unistd.h >+++ b/include/unistd.h >@@ -581,6 +581,7 @@ off_t __syscall(quad_t, ...); > int undelete(const char *); > int unwhiteout(const char *); > void *valloc(size_t); /* obsoleted by malloc() */ >+int getdtablecount(void); > > #ifndef _OPTRESET_DECLARED >diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc >index e5022ab..c47d99b 100644 >--- a/lib/libc/sys/Makefile.inc >+++ b/lib/libc/sys/Makefile.inc >@@ -122,6 +122,7 @@ MAN+= abort2.2 \ > fork.2 \ > fsync.2 \ > getdirentries.2 \ >+ getdtablecount.2 \ > getdtablesize.2 \ > getfh.2 \ >diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map >index ea86e81..b52b068 100644 >--- a/lib/libc/sys/Symbol.map >+++ b/lib/libc/sys/Symbol.map >@@ -393,6 +393,7 @@ FBSD_1.3 { > ffclock_getcounter; > ffclock_getestimate; > ffclock_setestimate; >+ getdtablecount; > pipe2; > posix_fadvise; >@@ -608,6 +609,8 @@ FBSDprivate_1.0 { > __sys_getdents; > _getdirentries; > __sys_getdirentries; >+ _getdtablecount; >+ __sys_getdtablecount; > _getdtablesize; > __sys_getdtablesize; > _getegid; >diff --git a/lib/libc/sys/getdtablecount.2 b/lib/libc/sys/getdtablecount.2 >new file mode 100644 >index 0000000..bb7cd2e >--- /dev/null >+++ b/lib/libc/sys/getdtablecount.2 >@@ -0,0 +1,38 @@ >+.\" $OpenBSD: getdtablecount.2,v 1.4 2014/01/26 22:27:31 tedu Exp $ >+.\" >+.\" Copyright (c) 2012 Theo de Raadt >+.\" >+.\" Permission to use, copy, modify, and distribute this software for any >+.\" purpose with or without fee is hereby granted, provided that the above >+.\" copyright notice and this permission notice appear in all copies. >+.\" >+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES >+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF >+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR >+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES >+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN >+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF >+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. >+.\" >+.Dd $Mdocdate: January 26 2014 $ >+.Dt GETDTABLECOUNT 2 >+.Os >+.Sh NAME >+.Nm getdtablecount >+.Nd get descriptor table count >+.Sh SYNOPSIS >+.Fd #include <unistd.h> >+.Ft int >+.Fn getdtablecount void >+.Sh DESCRIPTION >+.Nm >+returns the number of file descriptors the process currently has >+open. >+.Sh SEE ALSO >+.Xr getrlimit 2 , >+.Xr getdtablesize 3 >+.Sh HISTORY >+The >+.Nm >+function appeared in >+.Ox 5.2 . >diff --git a/sys/kern/init_sysent.c b/sys/kern/init_sysent.c >index eb20547..0ddae5f 100644 >--- a/sys/kern/init_sysent.c >+++ b/sys/kern/init_sysent.c >@@ -3,7 +3,7 @@ > * > * DO NOT EDIT-- this file is automatically generated. > * $FreeBSD$ >- * created from FreeBSD: head/sys/kern/syscalls.master 272823 2014-10-09 15:16:52Z marcel >+ * created from FreeBSD > */ > > #include "opt_compat.h" >@@ -580,4 +580,5 @@ struct sysent sysent[] = { > { AS(aio_mlock_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 543 = aio_mlock */ > { AS(procctl_args), (sy_call_t *)sys_procctl, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 544 = procctl */ >+ { 0, (sy_call_t *)sys_getdtablecount, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 546 = getdtablecount */ > }; >diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c >index e955b87..76962d2 100644 >--- a/sys/kern/kern_descrip.c >+++ b/sys/kern/kern_descrip.c >@@ -255,6 +255,7 @@ fdused_init(struct filedesc *fdp, int fd) > KASSERT(!fdisused(fdp, fd), ("fd=%d is already used", fd)); > > fdp->fd_map[NDSLOT(fd)] |= NDBIT(fd); >+ fdp->fd_openfd++; > } > > static void >@@ -288,6 +289,7 @@ fdunused(struct filedesc *fdp, int fd) > fdp->fd_freefile = fd; > if (fd == fdp->fd_lastfile) > fdp->fd_lastfile = fd_last_used(fdp, fd); >+ fdp->fd_openfd--; > } > > /* >@@ -1262,6 +1264,29 @@ sys_closefrom(struct thread *td, struct closefrom_args *uap) > return (0); > } > >+/* >+ * Number of file descriptors per process >+ */ >+#ifndef _SYS_SYSPROTO_H_ >+struct getdtablecount_args { >+ int dummy; >+}; >+#endif >+/* ARGSUSED */ >+ >+int >+sys_getdtablecount(struct thread *td, struct getdtablecount_args *uap) >+{ >+ struct proc *p; >+ >+ p = td->td_proc; >+ PROC_LOCK(p); >+ td->td_retval[0] = p->p_fd->fd_openfd; >+ PROC_UNLOCK(p); >+ >+ return (0); >+} >+ > #if defined(COMPAT_43) > /* > * Return status information about a file descriptor. >diff --git a/sys/kern/syscalls.c b/sys/kern/syscalls.c >index 4b74333..ee89312 100644 >--- a/sys/kern/syscalls.c >+++ b/sys/kern/syscalls.c >@@ -3,7 +3,7 @@ > * > * DO NOT EDIT-- this file is automatically generated. > * $FreeBSD$ >- * created from FreeBSD: head/sys/kern/syscalls.master 272823 2014-10-09 15:16:52Z marcel >+ * created from FreeBSD > */ > > const char *syscallnames[] = { >@@ -553,4 +553,5 @@ const char *syscallnames[] = { > "aio_mlock", /* 543 = aio_mlock */ > "procctl", /* 544 = procctl */ > "getentropy", /* 545 = getentropy */ >+ "getdtablecount", /* 546 = getdtablecount */ > }; >diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master >index 8fcb562..0c76bcc 100644 >--- a/sys/kern/syscalls.master >+++ b/sys/kern/syscalls.master >@@ -981,5 +981,6 @@ > 544 AUE_NULL STD { int procctl(idtype_t idtype, id_t id, \ > int com, void *data); } > 545 AUE_NULL STD { int getentropy(void *ptr, size_t len); } >+546 AUE_NULL STD { int getdtablecount(void); } > ; Please copy any additions and changes to the following compatability tables: > ; sys/compat/freebsd32/syscalls.master >diff --git a/sys/kern/systrace_args.c b/sys/kern/systrace_args.c >index d229f96..49c499c 100644 >--- a/sys/kern/systrace_args.c >+++ b/sys/kern/systrace_args.c >@@ -3380,6 +3380,11 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) > *n_args = 2; > break; > } >+ /* getdtablecount */ >+ case 546: { >+ *n_args = 0; >+ break; >+ } > default: > *n_args = 0; > break; >@@ -9011,6 +9016,9 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) > break; > }; > break; >+ /* getdtablecount */ >+ case 546: >+ break; > default: > break; > }; >@@ -10954,6 +10962,8 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) > if (ndx == 0 || ndx == 1) > p = "int"; > break; >+ /* getdtablecount */ >+ case 546: > default: > break; > }; >diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h >index 3b8f7eb..b6e843c 100644 >--- a/sys/sys/filedesc.h >+++ b/sys/sys/filedesc.h >@@ -82,6 +82,7 @@ struct filedesc { > NDSLOTTYPE *fd_map; /* bitmap of free fds */ > int fd_lastfile; /* high-water mark of fd_ofiles */ > int fd_freefile; /* approx. next free file */ >+ int fd_openfd; /* number of files currently open */ > u_short fd_cmask; /* mask for file creation */ > u_short fd_refcnt; /* thread reference count */ > u_short fd_holdcnt; /* hold count on structure + mutex */ >diff --git a/sys/sys/syscall.h b/sys/sys/syscall.h >index 0ad780c..3cae797 100644 >--- a/sys/sys/syscall.h >+++ b/sys/sys/syscall.h >@@ -3,7 +3,7 @@ > * > * DO NOT EDIT-- this file is automatically generated. > * $FreeBSD$ >- * created from FreeBSD: head/sys/kern/syscalls.master 272823 2014-10-09 15:16:52Z marcel >+ * created from FreeBSD > */ > > #define SYS_syscall 0 >@@ -463,4 +463,5 @@ > #define SYS_aio_mlock 543 > #define SYS_procctl 544 > #define SYS_getentropy 545 >-#define SYS_MAXSYSCALL 546 >+#define SYS_getdtablecount 546 >+#define SYS_MAXSYSCALL 547 >diff --git a/sys/sys/syscall.mk b/sys/sys/syscall.mk >index 49f9401..f994865 100644 >--- a/sys/sys/syscall.mk >+++ b/sys/sys/syscall.mk >@@ -1,7 +1,7 @@ > # FreeBSD system call names. > # DO NOT EDIT-- this file is automatically generated. > # $FreeBSD$ >-# created from FreeBSD: head/sys/kern/syscalls.master 272823 2014-10-09 15:16:52Z marcel >+# created from FreeBSD > MIASM = \ > syscall.o \ > exit.o \ >@@ -410,4 +410,5 @@ MIASM = \ > pipe2.o \ > aio_mlock.o \ > procctl.o \ >+ getentropy.o \ >+ getdtablecount.o >diff --git a/sys/sys/sysproto.h b/sys/sys/sysproto.h >index cd152a5..f7d8414 100644 >--- a/sys/sys/sysproto.h >+++ b/sys/sys/sysproto.h >@@ -3,7 +3,7 @@ > * > * DO NOT EDIT-- this file is automatically generated. > * $FreeBSD$ >- * created from FreeBSD: head/sys/kern/syscalls.master 272823 2014-10-09 15:16:52Z marcel >+ * created from FreeBSD > */ > >+struct getdtablecount_args { >+ register_t dummy; >+}; > int nosys(struct thread *, struct nosys_args *); > void sys_sys_exit(struct thread *, struct sys_exit_args *); > int sys_fork(struct thread *, struct fork_args *); >@@ -2209,6 +2212,7 @@ int sys_pipe2(struct thread *, struct pipe2_args *); > int sys_aio_mlock(struct thread *, struct aio_mlock_args *); > int sys_procctl(struct thread *, struct procctl_args *); > int sys_getentropy(struct thread *, struct getentropy_args *); >+int sys_getdtablecount(struct thread *, struct getdtablecount_args *); > > #ifdef COMPAT_43 > >@@ -2915,6 +2919,7 @@ int freebsd7_shmctl(struct thread *, struct freebsd7_shmctl_args *); > #define SYS_AUE_aio_mlock AUE_NULL > #define SYS_AUE_procctl AUE_NULL > #define SYS_AUE_getentropy AUE_NULL >+#define SYS_AUE_getdtablecount AUE_NULL > > #undef PAD_ > #undef PADL_
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 194985
: 149353 |
149376