summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/syscalls.conf4
-rw-r--r--sys/kern/syscalls.master25
-rw-r--r--sys/kern/sysv_msg.c142
-rw-r--r--sys/kern/sysv_sem.c165
-rw-r--r--sys/kern/sysv_shm.c88
-rw-r--r--sys/kern/vfs_syscalls.c176
6 files changed, 33 insertions, 567 deletions
diff --git a/sys/kern/syscalls.conf b/sys/kern/syscalls.conf
index 5de47030b03..dfe018accce 100644
--- a/sys/kern/syscalls.conf
+++ b/sys/kern/syscalls.conf
@@ -1,11 +1,11 @@
-# $OpenBSD: syscalls.conf,v 1.4 1999/08/08 00:28:33 niklas Exp $
+# $OpenBSD: syscalls.conf,v 1.5 2001/05/16 17:14:35 millert Exp $
# $NetBSD: syscalls.conf,v 1.2 1994/10/26 06:45:57 cgd Exp $
sysnames="syscalls.c"
sysnumhdr="../sys/syscall.h"
syssw="init_sysent.c"
sysarghdr="../sys/syscallargs.h"
-compatopts="compat_43 compat_09 compat_10"
+compatopts="compat_43 compat_09 compat_10 compat_23 compat_25"
libcompatopts=""
switchname="sysent"
diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master
index 1202c4a9bcb..0e352b129e4 100644
--- a/sys/kern/syscalls.master
+++ b/sys/kern/syscalls.master
@@ -1,4 +1,4 @@
-; $OpenBSD: syscalls.master,v 1.44 2001/03/09 15:11:47 art Exp $
+; $OpenBSD: syscalls.master,v 1.45 2001/05/16 17:14:35 millert Exp $
; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@@ -70,8 +70,8 @@
16 STD { int sys_chown(const char *path, uid_t uid, \
gid_t gid); }
17 STD { int sys_obreak(char *nsize); } break
-18 STD { int sys_ogetfsstat(struct statfs *buf, long bufsize, \
- int flags); }
+18 COMPAT_25 { int sys_getfsstat(struct statfs *buf, long bufsize, \
+ int flags); } ogetfsstat
19 COMPAT_43 { long sys_lseek(int fd, long offset, int whence); } \
olseek
20 STD { pid_t sys_getpid(void); }
@@ -286,9 +286,10 @@
#endif
156 COMPAT_43 { int sys_getdirentries(int fd, char *buf, \
int count, long *basep); } ogetdirentries
-157 STD { int sys_ostatfs(const char *path, \
- struct ostatfs *buf); }
-158 STD { int sys_ofstatfs(int fd, struct ostatfs *buf); }
+157 COMPAT_25 { int sys_statfs(const char *path, \
+ struct ostatfs *buf); } ostatfs
+158 COMPAT_25 { int sys_fstatfs(int fd, struct ostatfs *buf); } \
+ ostatfs
159 UNIMPL
160 UNIMPL
161 STD { int sys_getfh(const char *fname, fhandle_t *fhp); }
@@ -417,8 +418,8 @@
#endif /* !LKM */
; System calls 220-240 are reserved for use by OpenBSD
#ifdef SYSVSEM
-220 STD { int sys___osemctl(int semid, int semnum, int cmd, \
- union semun *arg); }
+220 COMPAT_23 { int sys___semctl(int semid, int semnum, int cmd, \
+ union semun *arg); } __osemctl
221 STD { int sys_semget(key_t key, int nsems, int semflg); }
222 STD { int sys_semop(int semid, struct sembuf *sops, \
u_int nsops); }
@@ -430,8 +431,8 @@
223 UNIMPL semconfig
#endif
#ifdef SYSVMSG
-224 STD { int sys_omsgctl(int msqid, int cmd, \
- struct omsqid_ds *buf); }
+224 COMPAT_23 { int sys_msgctl(int msqid, int cmd, \
+ struct omsqid_ds *buf); } omsgctl
225 STD { int sys_msgget(key_t key, int msgflg); }
226 STD { int sys_msgsnd(int msqid, const void *msgp, size_t msgsz, \
int msgflg); }
@@ -446,8 +447,8 @@
#ifdef SYSVSHM
228 STD { void *sys_shmat(int shmid, const void *shmaddr, \
int shmflg); }
-229 STD { int sys_oshmctl(int shmid, int cmd, \
- struct oshmid_ds *buf); }
+229 COMPAT_23 { int sys_shmctl(int shmid, int cmd, \
+ struct oshmid_ds *buf); } oshmctl
230 STD { int sys_shmdt(const void *shmaddr); }
231 STD { int sys_shmget(key_t key, int size, int shmflg); }
#else
diff --git a/sys/kern/sysv_msg.c b/sys/kern/sysv_msg.c
index 2a7f2097828..66d34143026 100644
--- a/sys/kern/sysv_msg.c
+++ b/sys/kern/sysv_msg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysv_msg.c,v 1.8 1999/08/09 21:44:24 deraadt Exp $ */
+/* $OpenBSD: sysv_msg.c,v 1.9 2001/05/16 17:14:35 millert Exp $ */
/* $NetBSD: sysv_msg.c,v 1.19 1996/02/09 19:00:18 christos Exp $ */
/*
@@ -37,7 +37,7 @@ int nfree_msgmaps; /* # of free map entries */
short free_msgmaps; /* head of linked list of free map entries */
struct msg *free_msghdrs; /* list of free msg headers */
-static void msg_freehdr __P((struct msg *));
+void msg_freehdr __P((struct msg *));
void
msginit()
@@ -90,7 +90,7 @@ msginit()
}
}
-static void
+void
msg_freehdr(msghdr)
struct msg *msghdr;
{
@@ -142,142 +142,6 @@ msqid_n2o(n, o)
}
int
-sys_omsgctl(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
-{
- register struct sys_msgctl_args /* {
- syscallarg(int) msqid;
- syscallarg(int) cmd;
- syscallarg(struct msqid_ds *) buf;
- } */ *uap = v;
- int msqid = SCARG(uap, msqid);
- int cmd = SCARG(uap, cmd);
- struct msqid_ds *user_msqptr = SCARG(uap, buf);
- struct ucred *cred = p->p_ucred;
- int rval, eval;
- struct omsqid_ds omsqbuf;
- register struct msqid_ds *msqptr;
-
-#ifdef MSG_DEBUG_OK
- printf("call to msgctl(%d, %d, %p)\n", msqid, cmd, user_msqptr);
-#endif
-
- msqid = IPCID_TO_IX(msqid);
-
- if (msqid < 0 || msqid >= msginfo.msgmni) {
-#ifdef MSG_DEBUG_OK
- printf("msqid (%d) out of range (0<=msqid<%d)\n", msqid,
- msginfo.msgmni);
-#endif
- return(EINVAL);
- }
-
- msqptr = &msqids[msqid];
-
- if (msqptr->msg_qbytes == 0) {
-#ifdef MSG_DEBUG_OK
- printf("no such msqid\n");
-#endif
- return(EINVAL);
- }
- if (msqptr->msg_perm.seq != IPCID_TO_SEQ(SCARG(uap, msqid))) {
-#ifdef MSG_DEBUG_OK
- printf("wrong sequence number\n");
-#endif
- return(EINVAL);
- }
-
- eval = 0;
- rval = 0;
-
- switch (cmd) {
-
- case IPC_RMID:
- {
- struct msg *msghdr;
- if ((eval = ipcperm(cred, &msqptr->msg_perm, IPC_M)) != 0)
- return(eval);
- /* Free the message headers */
- msghdr = msqptr->msg_first;
- while (msghdr != NULL) {
- struct msg *msghdr_tmp;
-
- /* Free the segments of each message */
- msqptr->msg_cbytes -= msghdr->msg_ts;
- msqptr->msg_qnum--;
- msghdr_tmp = msghdr;
- msghdr = msghdr->msg_next;
- msg_freehdr(msghdr_tmp);
- }
-
-#ifdef DIAGNOSTIC
- if (msqptr->msg_cbytes != 0)
- panic("sys_omsgctl: msg_cbytes is screwed up");
- if (msqptr->msg_qnum != 0)
- panic("sys_omsgctl: msg_qnum is screwed up");
-#endif
-
- msqptr->msg_qbytes = 0; /* Mark it as free */
-
- wakeup((caddr_t)msqptr);
- }
-
- break;
-
- case IPC_SET:
- if ((eval = ipcperm(cred, &msqptr->msg_perm, IPC_M)))
- return(eval);
- if ((eval = copyin(user_msqptr, &omsqbuf, sizeof(omsqbuf))) != 0)
- return(eval);
- if (omsqbuf.msg_qbytes > msqptr->msg_qbytes && cred->cr_uid != 0)
- return(EPERM);
- if (omsqbuf.msg_qbytes > msginfo.msgmnb) {
-#ifdef MSG_DEBUG_OK
- printf("can't increase msg_qbytes beyond %d (truncating)\n",
- msginfo.msgmnb);
-#endif
- omsqbuf.msg_qbytes = msginfo.msgmnb; /* silently restrict qbytes to system limit */
- }
- if (omsqbuf.msg_qbytes == 0) {
-#ifdef MSG_DEBUG_OK
- printf("can't reduce msg_qbytes to 0\n");
-#endif
- return(EINVAL); /* non-standard errno! */
- }
- msqptr->msg_perm.uid = omsqbuf.msg_perm.uid; /* change the owner */
- msqptr->msg_perm.gid = omsqbuf.msg_perm.gid; /* change the owner */
- msqptr->msg_perm.mode = (msqptr->msg_perm.mode & ~0777) |
- (omsqbuf.msg_perm.mode & 0777);
- msqptr->msg_qbytes = omsqbuf.msg_qbytes;
- msqptr->msg_ctime = time.tv_sec;
- break;
-
- case IPC_STAT:
- if ((eval = ipcperm(cred, &msqptr->msg_perm, IPC_R))) {
-#ifdef MSG_DEBUG_OK
- printf("requester doesn't have read access\n");
-#endif
- return(eval);
- }
- msqid_n2o(msqptr, &omsqbuf);
- eval = copyout((caddr_t)&omsqbuf, user_msqptr, sizeof omsqbuf);
- break;
-
- default:
-#ifdef MSG_DEBUG_OK
- printf("invalid command %d\n", cmd);
-#endif
- return(EINVAL);
- }
-
- if (eval == 0)
- *retval = rval;
- return(eval);
-}
-
-int
sys_msgctl(p, v, retval)
struct proc *p;
void *v;
diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c
index 08ee386ece7..cef45295d38 100644
--- a/sys/kern/sysv_sem.c
+++ b/sys/kern/sysv_sem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysv_sem.c,v 1.4 2000/05/01 23:12:30 deraadt Exp $ */
+/* $OpenBSD: sysv_sem.c,v 1.5 2001/05/16 17:14:35 millert Exp $ */
/* $NetBSD: sysv_sem.c,v 1.26 1996/02/09 19:00:25 christos Exp $ */
/*
@@ -232,169 +232,6 @@ semid_n2o(n, o)
}
int
-sys___osemctl(p, v, retval)
- struct proc *p;
- register void *v;
- register_t *retval;
-{
- register struct sys___semctl_args /* {
- syscallarg(int) semid;
- syscallarg(int) semnum;
- syscallarg(int) cmd;
- syscallarg(union semun *) arg;
- } */ *uap = v;
- int semid = SCARG(uap, semid);
- int semnum = SCARG(uap, semnum);
- int cmd = SCARG(uap, cmd);
- union semun *arg = SCARG(uap, arg);
- union semun real_arg;
- struct ucred *cred = p->p_ucred;
- int i, rval, eval;
- struct semid_ds *semaptr;
- struct osemid_ds osbuf;
-
-#ifdef SEM_DEBUG
- printf("call to semctl(%d, %d, %d, %p)\n", semid, semnum, cmd, arg);
-#endif
-
- semid = IPCID_TO_IX(semid);
- if (semid < 0 || semid >= seminfo.semmsl)
- return(EINVAL);
-
- semaptr = &sema[semid];
- if ((semaptr->sem_perm.mode & SEM_ALLOC) == 0 ||
- semaptr->sem_perm.seq != IPCID_TO_SEQ(SCARG(uap, semid)))
- return(EINVAL);
-
- eval = 0;
- rval = 0;
-
- switch (cmd) {
- case IPC_RMID:
- if ((eval = ipcperm(cred, &semaptr->sem_perm, IPC_M)) != 0)
- return(eval);
- semaptr->sem_perm.cuid = cred->cr_uid;
- semaptr->sem_perm.uid = cred->cr_uid;
- semtot -= semaptr->sem_nsems;
- for (i = semaptr->sem_base - sem; i < semtot; i++)
- sem[i] = sem[i + semaptr->sem_nsems];
- for (i = 0; i < seminfo.semmni; i++) {
- if ((sema[i].sem_perm.mode & SEM_ALLOC) &&
- sema[i].sem_base > semaptr->sem_base)
- sema[i].sem_base -= semaptr->sem_nsems;
- }
- semaptr->sem_perm.mode = 0;
- semundo_clear(semid, -1);
- wakeup((caddr_t)semaptr);
- break;
-
- case IPC_SET:
- if ((eval = ipcperm(cred, &semaptr->sem_perm, IPC_M)))
- return(eval);
- if ((eval = copyin(arg, &real_arg, sizeof(real_arg))) != 0)
- return(eval);
- if ((eval = copyin(real_arg.buf, (caddr_t)&osbuf,
- sizeof(osbuf))) != 0)
- return(eval);
- semaptr->sem_perm.uid = osbuf.sem_perm.uid;
- semaptr->sem_perm.gid = osbuf.sem_perm.gid;
- semaptr->sem_perm.mode = (semaptr->sem_perm.mode & ~0777) |
- (osbuf.sem_perm.mode & 0777);
- semaptr->sem_ctime = time.tv_sec;
- break;
-
- case IPC_STAT:
- if ((eval = ipcperm(cred, &semaptr->sem_perm, IPC_R)))
- return(eval);
- if ((eval = copyin(arg, &real_arg, sizeof(real_arg))) != 0)
- return(eval);
- semid_n2o(semaptr, &osbuf);
- eval = copyout((caddr_t)&osbuf, real_arg.buf, sizeof osbuf);
- break;
-
- case GETNCNT:
- if ((eval = ipcperm(cred, &semaptr->sem_perm, IPC_R)))
- return(eval);
- if (semnum < 0 || semnum >= semaptr->sem_nsems)
- return(EINVAL);
- rval = semaptr->sem_base[semnum].semncnt;
- break;
-
- case GETPID:
- if ((eval = ipcperm(cred, &semaptr->sem_perm, IPC_R)))
- return(eval);
- if (semnum < 0 || semnum >= semaptr->sem_nsems)
- return(EINVAL);
- rval = semaptr->sem_base[semnum].sempid;
- break;
-
- case GETVAL:
- if ((eval = ipcperm(cred, &semaptr->sem_perm, IPC_R)))
- return(eval);
- if (semnum < 0 || semnum >= semaptr->sem_nsems)
- return(EINVAL);
- rval = semaptr->sem_base[semnum].semval;
- break;
-
- case GETALL:
- if ((eval = ipcperm(cred, &semaptr->sem_perm, IPC_R)))
- return(eval);
- if ((eval = copyin(arg, &real_arg, sizeof(real_arg))) != 0)
- return(eval);
- for (i = 0; i < semaptr->sem_nsems; i++) {
- eval = copyout((caddr_t)&semaptr->sem_base[i].semval,
- &real_arg.array[i], sizeof(real_arg.array[0]));
- if (eval != 0)
- break;
- }
- break;
-
- case GETZCNT:
- if ((eval = ipcperm(cred, &semaptr->sem_perm, IPC_R)))
- return(eval);
- if (semnum < 0 || semnum >= semaptr->sem_nsems)
- return(EINVAL);
- rval = semaptr->sem_base[semnum].semzcnt;
- break;
-
- case SETVAL:
- if ((eval = ipcperm(cred, &semaptr->sem_perm, IPC_W)))
- return(eval);
- if (semnum < 0 || semnum >= semaptr->sem_nsems)
- return(EINVAL);
- if ((eval = copyin(arg, &real_arg, sizeof(real_arg))) != 0)
- return(eval);
- semaptr->sem_base[semnum].semval = real_arg.val;
- semundo_clear(semid, semnum);
- wakeup((caddr_t)semaptr);
- break;
-
- case SETALL:
- if ((eval = ipcperm(cred, &semaptr->sem_perm, IPC_W)))
- return(eval);
- if ((eval = copyin(arg, &real_arg, sizeof(real_arg))) != 0)
- return(eval);
- for (i = 0; i < semaptr->sem_nsems; i++) {
- eval = copyin(&real_arg.array[i],
- (caddr_t)&semaptr->sem_base[i].semval,
- sizeof(real_arg.array[0]));
- if (eval != 0)
- break;
- }
- semundo_clear(semid, -1);
- wakeup((caddr_t)semaptr);
- break;
-
- default:
- return(EINVAL);
- }
-
- if (eval == 0)
- *retval = rval;
- return(eval);
-}
-
-int
sys___semctl(p, v, retval)
struct proc *p;
register void *v;
diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c
index b1232d4253f..d508b6e96ab 100644
--- a/sys/kern/sysv_shm.c
+++ b/sys/kern/sysv_shm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysv_shm.c,v 1.16 2001/05/05 21:26:44 art Exp $ */
+/* $OpenBSD: sysv_shm.c,v 1.17 2001/05/16 17:14:36 millert Exp $ */
/* $NetBSD: sysv_shm.c,v 1.50 1998/10/21 22:24:29 tron Exp $ */
/*
@@ -89,15 +89,15 @@ struct shmmap_state {
int shmid;
};
-static int shm_find_segment_by_key __P((key_t));
-static void shm_deallocate_segment __P((struct shmid_ds *));
-static int shm_delete_mapping __P((struct vmspace *, struct shmmap_state *));
-static int shmget_existing __P((struct proc *, struct sys_shmget_args *,
- int, int, register_t *));
-static int shmget_allocate_segment __P((struct proc *, struct sys_shmget_args *,
- int, register_t *));
+int shm_find_segment_by_key __P((key_t));
+void shm_deallocate_segment __P((struct shmid_ds *));
+int shm_delete_mapping __P((struct vmspace *, struct shmmap_state *));
+int shmget_existing __P((struct proc *, struct sys_shmget_args *,
+ int, int, register_t *));
+int shmget_allocate_segment __P((struct proc *, struct sys_shmget_args *,
+ int, register_t *));
-static int
+int
shm_find_segment_by_key(key)
key_t key;
{
@@ -128,7 +128,7 @@ shm_find_segment_by_shmid(shmid)
return shmseg;
}
-static void
+void
shm_deallocate_segment(shmseg)
struct shmid_ds *shmseg;
{
@@ -149,7 +149,7 @@ shm_deallocate_segment(shmseg)
shm_nused--;
}
-static int
+int
shm_delete_mapping(vm, shmmap_s)
struct vmspace *vm;
struct shmmap_state *shmmap_s;
@@ -359,7 +359,7 @@ sys_shmctl(p, v, retval)
return 0;
}
-static int
+int
shmget_existing(p, uap, mode, segnum, retval)
struct proc *p;
struct sys_shmget_args /* {
@@ -399,7 +399,7 @@ shmget_existing(p, uap, mode, segnum, retval)
return 0;
}
-static int
+int
shmget_allocate_segment(p, uap, mode, retval)
struct proc *p;
struct sys_shmget_args /* {
@@ -606,65 +606,3 @@ shmid_n2o(n, o)
o->shm_internal = n->shm_internal;
ipc_n2o(&n->shm_perm, &o->shm_perm);
}
-
-
-int
-sys_oshmctl(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
-{
- struct sys_shmctl_args /* {
- syscallarg(int) shmid;
- syscallarg(int) cmd;
- syscallarg(struct shmid_ds *) buf;
- } */ *uap = v;
- int error;
- struct ucred *cred = p->p_ucred;
- struct oshmid_ds oinbuf;
- struct shmid_ds *shmseg;
-
- shmseg = shm_find_segment_by_shmid(SCARG(uap, shmid));
- if (shmseg == NULL)
- return EINVAL;
- switch (SCARG(uap, cmd)) {
- case IPC_STAT:
- if ((error = ipcperm(cred, &shmseg->shm_perm, IPC_R)) != 0)
- return error;
- shmid_n2o(shmseg, &oinbuf);
- error = copyout((caddr_t)&oinbuf, SCARG(uap, buf),
- sizeof(oinbuf));
- if (error)
- return error;
- break;
- case IPC_SET:
- if ((error = ipcperm(cred, &shmseg->shm_perm, IPC_M)) != 0)
- return error;
- error = copyin(SCARG(uap, buf), (caddr_t)&oinbuf,
- sizeof(oinbuf));
- if (error)
- return error;
- shmseg->shm_perm.uid = oinbuf.shm_perm.uid;
- shmseg->shm_perm.gid = oinbuf.shm_perm.gid;
- shmseg->shm_perm.mode =
- (shmseg->shm_perm.mode & ~ACCESSPERMS) |
- (oinbuf.shm_perm.mode & ACCESSPERMS);
- shmseg->shm_ctime = time.tv_sec;
- break;
- case IPC_RMID:
- if ((error = ipcperm(cred, &shmseg->shm_perm, IPC_M)) != 0)
- return error;
- shmseg->shm_perm.key = IPC_PRIVATE;
- shmseg->shm_perm.mode |= SHMSEG_REMOVED;
- if (shmseg->shm_nattch <= 0) {
- shm_deallocate_segment(shmseg);
- shm_last_free = IPCID_TO_IX(SCARG(uap, shmid));
- }
- break;
- case SHM_LOCK:
- case SHM_UNLOCK:
- default:
- return EINVAL;
- }
- return 0;
-}
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index a6bbdee1d73..dcdf5ed9ff5 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_syscalls.c,v 1.74 2001/05/16 05:07:52 millert Exp $ */
+/* $OpenBSD: vfs_syscalls.c,v 1.75 2001/05/16 17:14:36 millert Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
/*
@@ -70,7 +70,6 @@ int usermount = 0; /* sysctl: by default, users may not mount */
static int change_dir __P((struct nameidata *, struct proc *));
void checkdirs __P((struct vnode *));
-void statfs_to_ostatfs __P((struct proc *, struct mount *, struct statfs *, struct ostatfs *));
/*
* Redirection info so we don't have to include the union fs routines in
@@ -2626,179 +2625,6 @@ getvnode(fdp, fd, fpp)
}
/*
- * At some point (before 2.6 is released), these will move to
- * sys/compat/vfs_syscalls_25.c
- */
-
-/*
- * Convert struct statfs -> struct ostatfs
- */
-void
-statfs_to_ostatfs(p, mp, sp, osp)
- struct proc *p;
- struct mount *mp;
- struct statfs *sp;
- struct ostatfs *osp;
-{
-#ifdef COMPAT_43
- osp->f_type = mp->mnt_vfc->vfc_typenum;
-#else
- osp->f_type = 0;
-#endif
- osp->f_flags = mp->mnt_flag & 0xffff;
- osp->f_bsize = sp->f_bsize;
- osp->f_iosize = sp->f_iosize;
- osp->f_blocks = sp->f_blocks;
- osp->f_bfree = sp->f_bfree;
- osp->f_bavail = sp->f_bavail;
- osp->f_files = sp->f_files;
- osp->f_ffree = sp->f_ffree;
- /* Don't let non-root see filesystem id (for NFS security) */
- if (suser(p->p_ucred, &p->p_acflag))
- osp->f_fsid.val[0] = osp->f_fsid.val[1] = 0;
- else
- bcopy(&sp->f_fsid, &osp->f_fsid, sizeof(osp->f_fsid));
- osp->f_owner = sp->f_owner;
- osp->f_syncwrites = sp->f_syncwrites;
- osp->f_asyncwrites = sp->f_asyncwrites;
- bcopy(sp->f_fstypename, osp->f_fstypename, MFSNAMELEN);
- bcopy(sp->f_mntonname, osp->f_mntonname, MNAMELEN);
- bcopy(sp->f_mntfromname, osp->f_mntfromname, MNAMELEN);
-}
-
-/*
- * Get filesystem statistics.
- */
-/* ARGSUSED */
-int
-sys_ostatfs(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
-{
- register struct sys_ostatfs_args /* {
- syscallarg(char *) path;
- syscallarg(struct ostatfs *) buf;
- } */ *uap = v;
- register struct mount *mp;
- register struct statfs *sp;
- struct ostatfs osb;
- int error;
- struct nameidata nd;
-
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- mp = nd.ni_vp->v_mount;
- sp = &mp->mnt_stat;
- vrele(nd.ni_vp);
- if ((error = VFS_STATFS(mp, sp, p)) != 0)
- return (error);
-
- statfs_to_ostatfs(p, mp, sp, &osb);
- return (copyout((caddr_t)&osb, (caddr_t)SCARG(uap, buf), sizeof(osb)));
-}
-
-/*
- * Get filesystem statistics.
- */
-/* ARGSUSED */
-int
-sys_ofstatfs(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
-{
- register struct sys_ofstatfs_args /* {
- syscallarg(int) fd;
- syscallarg(struct ostatfs *) buf;
- } */ *uap = v;
- struct file *fp;
- struct mount *mp;
- register struct statfs *sp;
- struct ostatfs osb;
- int error;
-
- if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
- return (error);
- mp = ((struct vnode *)fp->f_data)->v_mount;
- sp = &mp->mnt_stat;
- if ((error = VFS_STATFS(mp, sp, p)) != 0)
- return (error);
-
- statfs_to_ostatfs(p, mp, sp, &osb);
- return (copyout((caddr_t)&osb, (caddr_t)SCARG(uap, buf), sizeof(osb)));
-}
-
-/*
- * Get statistics on all filesystems.
- */
-int
-sys_ogetfsstat(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
-{
- register struct sys_ogetfsstat_args /* {
- syscallarg(struct ostatfs *) buf;
- syscallarg(long) bufsize;
- syscallarg(int) flags;
- } */ *uap = v;
- register struct mount *mp, *nmp;
- register struct statfs *sp;
- struct ostatfs osb;
- caddr_t sfsp;
- long count, maxcount;
- int error, flags = SCARG(uap, flags);
-
- maxcount = SCARG(uap, bufsize) / sizeof(struct ostatfs);
- sfsp = (caddr_t)SCARG(uap, buf);
- count = 0;
- simple_lock(&mountlist_slock);
- for (mp = CIRCLEQ_FIRST(&mountlist); mp != CIRCLEQ_END(&mountlist);
- mp = nmp) {
- if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) {
- nmp = CIRCLEQ_NEXT(mp, mnt_list);
- continue;
- }
- if (sfsp && count < maxcount) {
- sp = &mp->mnt_stat;
-
- /* Refresh stats unless MNT_NOWAIT is specified */
- if (flags != MNT_NOWAIT &&
- flags != MNT_LAZY &&
- (flags == MNT_WAIT ||
- flags == 0) &&
- (error = VFS_STATFS(mp, sp, p))) {
- simple_lock(&mountlist_slock);
- nmp = CIRCLEQ_NEXT(mp, mnt_list);
- vfs_unbusy(mp, p);
- continue;
- }
-
- statfs_to_ostatfs(p, mp, sp, &osb);
- error = copyout((caddr_t)&osb, sfsp, sizeof(osb));
- if (error) {
- vfs_unbusy(mp, p);
- return (error);
- }
- sfsp += sizeof(osb);
- }
- count++;
- simple_lock(&mountlist_slock);
- nmp = CIRCLEQ_NEXT(mp, mnt_list);
- vfs_unbusy(mp, p);
- }
- simple_unlock(&mountlist_slock);
- if (sfsp && count > maxcount)
- *retval = maxcount;
- else
- *retval = count;
- return (0);
-}
-
-
-/*
* Positional read system call.
*/
int