Spring cleanup

Remove old versions of system calls and system calls that didn't have
and libc api interface anymore (dup, dup2, creat).

Change-Id: I721779b58a50c7eeae20669de24658d55d69b25b
This commit is contained in:
Thomas Veerman 2013-02-28 14:44:23 +00:00
parent 2ea6149f7c
commit 0f80a025be
19 changed files with 34 additions and 478 deletions

View File

@ -8,7 +8,6 @@
#define OPEN 5
#define CLOSE 6
#define WAIT 7
#define CREAT 8
#define LINK 9
#define UNLINK 10
#define WAITPID 11
@ -18,7 +17,6 @@
#define CHMOD 15
#define CHOWN 16
#define BRK 17
#define PREV_STAT 18
#define LSEEK 19
#define MINIX_GETPID 20
#define MOUNT 21
@ -28,7 +26,6 @@
#define STIME 25
#define PTRACE 26
#define ALARM 27
#define PREV_FSTAT 28
#define PAUSE 29
#define UTIME 30
#define GETEPINFO 31
@ -40,7 +37,6 @@
#define RENAME 38
#define MKDIR 39
#define RMDIR 40
#define DUP 41
#define PIPE 42
#define TIMES 43
#define SYMLINK 45
@ -48,7 +44,6 @@
#define GETGID 47
#define SIGNAL 48
#define RDLNK 49
#define PREV_LSTAT 50
#define STAT 51
#define FSTAT 52
#define LSTAT 53
@ -61,8 +56,6 @@
#define SETSID 62
#define GETPGRP 63
#define ITIMER 64
#define GETGROUPS_O 65
#define SETGROUPS_O 66
#define GETMCONTEXT 67
#define SETMCONTEXT 68

View File

@ -81,16 +81,6 @@ typedef struct {
gid_t vu_sgroups[NGROUPS_MAX];
} vfs_ucred_t;
#define NGROUPS_MAX_OLD 8
/* User credential structure before increasing
* uid_t and gid_t u8_t */
typedef struct {
short vu_uid;
char vu_gid;
int vu_ngroups;
char vu_sgroups[NGROUPS_MAX_OLD];
} vfs_ucred_old_t;
/* Request numbers */
#define REQ_GETNODE (VFS_BASE + 1) /* Should be removed */
#define REQ_PUTNODE (VFS_BASE + 2)

View File

@ -77,7 +77,6 @@ struct msg_control
#define NWIOSUDSCONN _IOW ('n', 74, struct sockaddr_un) /* connect() */
#define NWIOSUDSSHUT _IOW ('n', 75, int) /* shutdown() */
#define NWIOSUDSPAIR _IOW ('n', 76, dev_t) /* socketpair() */
#define NWIOSUDSPAIROLD _IOW ('n', 76, short) /* socketpair() */
#define NWIOSUDSACCEPT _IOW ('n', 77, struct sockaddr_un) /* accept() */
#define NWIOSUDSCTRL _IOW ('n', 78, struct msg_control) /* sendmsg() */
#define NWIOGUDSCTRL _IORW('n', 79, struct msg_control) /* recvmsg() */
@ -88,7 +87,6 @@ struct msg_control
/* setsockopt/setsockopt for unix domain sockets */
#define NWIOGUDSSOTYPE _IOR('n', 90, int) /* SO_TYPE */
#define NWIOGUDSPEERCRED _IOR('n', 91, struct ucred) /* SO_PEERCRED */
#define NWIOGUDSPEERCREDOLD _IOR('n', 91, struct ucred_old) /* SO_PEERCRED */
#define NWIOGUDSSNDBUF _IOR('n', 92, size_t) /* SO_SNDBUF */
#define NWIOSUDSSNDBUF _IOW('n', 93, size_t) /* SO_SNDBUF */
#define NWIOGUDSRCVBUF _IOR('n', 94, size_t) /* SO_RCVBUF */

View File

@ -5,31 +5,6 @@
#include <sys/stat.h>
#include <string.h>
/* XXX until that st_Xtime macroses used, we have to undefine them,
* because of minix_prev_stat
*/
#undef st_atime
#undef st_ctime
#undef st_mtime
static void prev_stat2new_stat(struct stat *new, struct minix_prev_stat *prev)
{
/* Copy field by field because of st_gid type mismath and
* difference in order after atime.
*/
new->st_dev = prev->st_dev;
new->st_ino = prev->st_ino;
new->st_mode = prev->st_mode;
new->st_nlink = prev->st_nlink;
new->st_uid = prev->st_uid;
new->st_gid = prev->st_gid;
new->st_rdev = prev->st_rdev;
new->st_size = prev->st_size;
new->st_atimespec.tv_sec = prev->st_atime;
new->st_mtimespec.tv_sec = prev->st_mtime;
new->st_ctimespec.tv_sec = prev->st_ctime;
}
int _stat(const char *name, struct stat *buffer);
int _lstat(const char *name, struct stat *buffer);
int _fstat(int fd, struct stat *buffer);
@ -47,32 +22,12 @@ __weak_alias(fstat, __fstat50);
int stat(const char *name, struct stat *buffer)
{
message m;
int r;
struct minix_prev_stat old_sb;
m.m1_i1 = strlen(name) + 1;
m.m1_p1 = (char *) __UNCONST(name);
m.m1_p2 = (char *) buffer;
if((r = _syscall(VFS_PROC_NR, STAT, &m)) >= 0 || errno != ENOSYS)
return r;
errno = 0;
/* ENOSYS: new binary and old VFS, fallback to PREV_STAT.
* User has struct stat (buffer), VFS still fills minix_prev_stat.
*/
m.m1_i1 = strlen(name) + 1;
m.m1_p1 = (char *) __UNCONST(name);
m.m1_p2 = (char *) &old_sb;
if((r = _syscall(VFS_PROC_NR, PREV_STAT, &m)) < 0)
return r;
memset(buffer, 0, sizeof(struct stat));
prev_stat2new_stat(buffer, &old_sb);
return r;
return _syscall(VFS_PROC_NR, STAT, &m);
}
int _fstat(int fd, struct stat *buffer) { return fstat(fd, buffer); }
@ -80,30 +35,11 @@ int _fstat(int fd, struct stat *buffer) { return fstat(fd, buffer); }
int fstat(int fd, struct stat *buffer)
{
message m;
int r;
struct minix_prev_stat old_sb;
m.m1_i1 = fd;
m.m1_p1 = (char *) buffer;
if((r = _syscall(VFS_PROC_NR, FSTAT, &m)) >= 0 || errno != ENOSYS)
return r;
errno = 0;
/* ENOSYS: new binary and old VFS, fallback to PREV_STAT.
* User has struct stat (buffer), VFS still fills minix_prev_stat.
*/
m.m1_i1 = fd;
m.m1_p1 = (char *) &old_sb;
if((r = _syscall(VFS_PROC_NR, PREV_FSTAT, &m)) < 0)
return r;
memset(buffer, 0, sizeof(struct stat));
prev_stat2new_stat(buffer, &old_sb);
return r;
return _syscall(VFS_PROC_NR, FSTAT, &m);
}
int _lstat(const char *name, struct stat *buffer) { return lstat(name, buffer); }
@ -111,30 +47,10 @@ int _lstat(const char *name, struct stat *buffer) { return lstat(name, buffer);
int lstat(const char *name, struct stat *buffer)
{
message m;
int r;
struct minix_prev_stat old_sb;
m.m1_i1 = strlen(name) + 1;
m.m1_p1 = (char *) __UNCONST(name);
m.m1_p2 = (char *) buffer;
if((r = _syscall(VFS_PROC_NR, LSTAT, &m)) >= 0 || errno != ENOSYS)
return r;
errno = 0;
/* ENOSYS: new binary and old VFS, fallback to PREV_STAT.
* User has struct stat (buffer), VFS still fills minix_prev_stat.
*/
m.m1_i1 = strlen(name) + 1;
m.m1_p1 = (char *) __UNCONST(name);
m.m1_p2 = (char *) &old_sb;
if((r = _syscall(VFS_PROC_NR, PREV_LSTAT, &m)) < 0)
return r;
memset(buffer, 0, sizeof(struct stat));
prev_stat2new_stat(buffer, &old_sb);
return r;
return _syscall(VFS_PROC_NR, LSTAT, &m);
}

View File

@ -10,44 +10,22 @@
int fs_lookup_credentials(vfs_ucred_t *credentials,
uid_t *caller_uid, gid_t *caller_gid, cp_grant_id_t grant2, size_t cred_size)
{
vfs_ucred_old_t old_cred;
int r;
memset(credentials, 0, sizeof(*credentials));
if(cred_size == sizeof(*credentials)) {
r = sys_safecopyfrom(VFS_PROC_NR, grant2, (vir_bytes) 0,
(vir_bytes) credentials, cred_size);
if (r != OK) {
printf("FS: cred copy (regular) failed.\n");
return(r);
}
} else if(cred_size == sizeof(old_cred)) {
int g;
r = sys_safecopyfrom(VFS_PROC_NR, grant2, (vir_bytes) 0,
(vir_bytes) &old_cred, sizeof(old_cred));
if (r != OK) {
printf("FS: cred copy (fallback) failed.\n");
return(r);
}
credentials->vu_ngroups = old_cred.vu_ngroups;
credentials->vu_uid = old_cred.vu_uid;
credentials->vu_gid = old_cred.vu_gid;
for(g = 0; g < NGROUPS_MAX_OLD; g++) {
assert(g < NGROUPS_MAX);
credentials->vu_sgroups[g] = old_cred.vu_sgroups[g];
}
} else {
static int w = 0;
if(!w) { printf("FS: cred size incompatible with VFS.\n"); w = 1; }
return(EINVAL); /* Wrong size. */
r = sys_safecopyfrom(VFS_PROC_NR, grant2, (vir_bytes) 0,
(vir_bytes) credentials, cred_size);
if (r != OK) {
printf("FS: cred copy failed\n");
return(r);
}
assert(credentials->vu_ngroups <= NGROUPS_MAX);
assert(credentials->vu_ngroups <= NGROUPS_MAX);
*caller_uid = credentials->vu_uid;
*caller_gid = credentials->vu_gid;
*caller_uid = credentials->vu_uid;
*caller_gid = credentials->vu_gid;
return OK;
return OK;
}

View File

@ -858,13 +858,6 @@ int uds_ioctl(message *dev_m_in, message *dev_m_out)
break;
case NWIOSUDSPAIROLD:
/* connect two sockets -- socketpair() */
rc = do_socketpair_old(dev_m_in, dev_m_out);
break;
case NWIOGUDSSOTYPE:
/* get socket type -- getsockopt(SO_TYPE) */
@ -879,13 +872,6 @@ int uds_ioctl(message *dev_m_in, message *dev_m_out)
break;
case NWIOGUDSPEERCREDOLD:
/* get peer endpoint -- getsockopt(SO_PEERCRED) */
rc = do_getsockopt_peercred_old(dev_m_in, dev_m_out);
break;
case NWIOSUDSTADDR:
/* set target address -- sendto() */

View File

@ -80,10 +80,8 @@ int do_getsockname(message *dev_m_in, message *dev_m_out);
int do_getpeername(message *dev_m_in, message *dev_m_out);
int do_shutdown(message *dev_m_in, message *dev_m_out);
int do_socketpair(message *dev_m_in, message *dev_m_out);
int do_socketpair_old(message *dev_m_in, message *dev_m_out);
int do_getsockopt_sotype(message *dev_m_in, message *dev_m_out);
int do_getsockopt_peercred(message *dev_m_in, message *dev_m_out);
int do_getsockopt_peercred_old(message *dev_m_in, message *dev_m_out);
int do_getsockopt_sndbuf(message *dev_m_in, message *dev_m_out);
int do_setsockopt_sndbuf(message *dev_m_in, message *dev_m_out);
int do_getsockopt_rcvbuf(message *dev_m_in, message *dev_m_out);

View File

@ -880,53 +880,6 @@ int do_shutdown(message *dev_m_in, message *dev_m_out)
return OK;
}
int do_socketpair_old(message *dev_m_in, message *dev_m_out)
{
int rc;
short minorin;
int minorx, minory;
struct sockaddr_un addr;
#if DEBUG == 1
static int call_count = 0;
printf("(uds) [%d] do_socketpair() call_count=%d\n",
uds_minor(dev_m_in), ++call_count);
#endif
/* first ioctl param is the first socket */
minorx = uds_minor_old(dev_m_in);
/* third ioctl param is the minor number of the second socket */
rc = sys_safecopyfrom(VFS_PROC_NR, (cp_grant_id_t) dev_m_in->IO_GRANT,
(vir_bytes) 0, (vir_bytes) &minorin, sizeof(short));
if (rc != OK) {
return EIO;
}
minory = minor(minorin);
#if DEBUG == 1
printf("socketpair() %d - %d\n", minorx, minory);
#endif
/* security check - both sockets must have the same endpoint (owner) */
if (uds_fd_table[minorx].owner != uds_fd_table[minory].owner) {
/* we won't allow you to magically connect your socket to
* someone elses socket
*/
return EPERM;
}
addr.sun_family = AF_UNIX;
addr.sun_path[0] = 'X';
addr.sun_path[1] = '\0';
uds_fd_table[minorx].syscall_done = 1;
return perform_connection(dev_m_in, dev_m_out, &addr, minorx, minory);
}
int do_socketpair(message *dev_m_in, message *dev_m_out)
{
int rc;
@ -1043,53 +996,6 @@ int do_getsockopt_peercred(message *dev_m_in, message *dev_m_out)
return rc ? EIO : OK;
}
int do_getsockopt_peercred_old(message *dev_m_in, message *dev_m_out)
{
int minor;
int peer_minor;
int rc;
struct ucred cred;
struct ucred_old cred_old;
#if DEBUG == 1
static int call_count = 0;
printf("(uds) [%d] do_getsockopt_peercred() call_count=%d\n",
uds_minor(dev_m_in), ++call_count);
#endif
minor = uds_minor(dev_m_in);
if (uds_fd_table[minor].peer == -1) {
if (uds_fd_table[minor].err == ECONNRESET) {
uds_fd_table[minor].err = 0;
return ECONNRESET;
} else {
return ENOTCONN;
}
}
peer_minor = uds_fd_table[minor].peer;
/* obtain the peer's credentials */
rc = getnucred(uds_fd_table[peer_minor].owner, &cred);
if (rc == -1) {
/* likely error: invalid endpoint / proc doesn't exist */
return errno;
}
/* copy to old structure */
cred_old.pid = cred.pid;
cred_old.uid = (short) cred.uid;
cred_old.gid = (char) cred.gid;
rc = sys_safecopyto(VFS_PROC_NR, (cp_grant_id_t) dev_m_in->IO_GRANT,
(vir_bytes) 0, (vir_bytes) &cred_old, sizeof(struct ucred_old));
return rc ? EIO : OK;
}
int do_getsockopt_sndbuf(message *dev_m_in, message *dev_m_out)
{
int rc;

View File

@ -225,7 +225,6 @@ EXTERN uds_fd_t uds_fd_table[NR_FDS];
* Take message m and get the index in uds_fd_table.
*/
#define uds_minor(m) (minor((dev_t) m->DEVICE))
#define uds_minor_old(m) (minor((short) m->DEVICE))
/*
* Fill in a reply message.

View File

@ -18,41 +18,15 @@
*===========================================================================*/
int do_get()
{
/* Handle GETUID, GETGID, GETGROUPS, GETGROUPS_O, GETPID, GETPGRP, GETSID,
/* Handle GETUID, GETGID, GETGROUPS, MINIX_GETPID, GETPGRP, GETSID,
ISSETUGID.
*/
register struct mproc *rmp = mp;
int r, i;
int ngroups;
char sgroups[NGROUPS_MAX]; /* XXX: Temp storage for GETGROUPS_O */
switch(call_nr) {
case GETGROUPS_O:
ngroups = m_in.grp_no;
if (ngroups > NGROUPS_MAX || ngroups < 0)
return(EINVAL);
if (ngroups == 0) {
r = rmp->mp_ngroups;
break;
}
if (ngroups < rmp->mp_ngroups)
/* Asking for less groups than available */
return(EINVAL);
for (i = 0; i < ngroups; i++)
sgroups[i] = (char) rmp->mp_sgroups[i];
r = sys_datacopy(SELF, (vir_bytes) &sgroups, who_e,
(vir_bytes) m_in.groupsp, ngroups * sizeof(char));
if (r != OK)
return(r);
r = rmp->mp_ngroups;
break;
case GETGROUPS:
ngroups = m_in.grp_no;
if (ngroups > NGROUPS_MAX || ngroups < 0)
@ -120,15 +94,13 @@ int do_get()
*===========================================================================*/
int do_set()
{
/* Handle SETUID, SETEUID, SETGID, SETEGID, SETSID. These calls have in common
* that, if successful, they will be forwarded to VFS as well.
/* Handle SETUID, SETEUID, SETGID, SETGROUPS, SETEGID, and SETSID. These calls
* have in common that, if successful, they will be forwarded to VFS as well.
*/
register struct mproc *rmp = mp;
message m;
int r, i;
int ngroups;
char sgroups[NGROUPS_MAX]; /* XXX: Temp storage for SETGROUPS_O */
switch(call_nr) {
case SETUID:
@ -192,35 +164,6 @@ int do_set()
m.PM_GROUP_NO = rmp->mp_ngroups;
m.PM_GROUP_ADDR = (char *) rmp->mp_sgroups;
break;
case SETGROUPS_O:
if (rmp->mp_effuid != SUPER_USER)
return(EPERM);
ngroups = m_in.grp_no;
if (ngroups > NGROUPS_MAX || ngroups < 0)
return(EINVAL);
if (m_in.groupsp == NULL)
return(EFAULT);
r = sys_datacopy(who_e, (vir_bytes) m_in.groupsp, SELF,
(vir_bytes) &sgroups, ngroups * sizeof(char));
if (r != OK)
return(r);
for (i = 0; i < ngroups; i++)
rmp->mp_sgroups[i] = (gid_t) sgroups[i];
for (i = ngroups; i < NGROUPS_MAX; i++)
rmp->mp_sgroups[i] = 0;
rmp->mp_ngroups = ngroups;
m.m_type = PM_SETGROUPS;
m.PM_PROC = rmp->mp_endpoint;
m.PM_GROUP_NO = rmp->mp_ngroups;
m.PM_GROUP_ADDR = (char *) rmp->mp_sgroups;
break;
case SETSID:
if (rmp->mp_procgrp == rmp->mp_pid) return(EPERM);

View File

@ -156,7 +156,7 @@ static int get_read_vp(struct vfs_exec_info *execi,
return r;
else
r = req_stat(execi->vp->v_fs_e, execi->vp->v_inode_nr,
VFS_PROC_NR, (vir_bytes) &(execi->sb), 0);
VFS_PROC_NR, (vir_bytes) &(execi->sb));
if (r != OK) return r;

View File

@ -3,7 +3,6 @@
* that are mostly performed by the Memory Manager.
*
* The entry points into this file are
* do_dup: perform the DUP system call
* do_fcntl: perform the FCNTL system call
* do_sync: perform the SYNC system call
* do_fsync: perform the FSYNC system call
@ -106,59 +105,6 @@ int do_getsysinfo()
return sys_datacopy(SELF, src_addr, who_e, dst_addr, len);
}
/*===========================================================================*
* do_dup *
*===========================================================================*/
int do_dup()
{
/* Perform the dup(fd) or dup2(fd,fd2) system call. These system calls are
* obsolete. In fact, it is not even possible to invoke them using the
* current library because the library routines call fcntl(). They are
* provided to permit old binary programs to continue to run.
*/
int rfd, rfd2;
struct filp *f;
int r = OK;
scratch(fp).file.fd_nr = job_m_in.fd;
rfd2 = job_m_in.fd2;
/* Is the file descriptor valid? */
rfd = scratch(fp).file.fd_nr & ~DUP_MASK; /* kill off dup2 bit, if on */
if ((f = get_filp(rfd, VNODE_READ)) == NULL) return(err_code);
/* Distinguish between dup and dup2. */
if (!(scratch(fp).file.fd_nr & DUP_MASK)) { /* bit not on */
/* dup(fd) */
r = get_fd(0, 0, &rfd2, NULL);
} else {
/* dup2(old_fd, new_fd) */
if (rfd2 < 0 || rfd2 >= OPEN_MAX) {
r = EBADF;
} else if (rfd == rfd2) { /* ignore the call: dup2(x, x) */
r = rfd2;
} else {
/* All is fine, close new_fd if necessary */
unlock_filp(f); /* or it might deadlock on do_close */
(void) close_fd(fp, rfd2); /* cannot fail */
f = get_filp(rfd, VNODE_READ); /* lock old_fd again */
if (f == NULL) return(err_code);
}
}
if (r == OK) {
/* Success. Set up new file descriptors. */
f->filp_count++;
fp->fp_filp[rfd2] = f;
FD_SET(rfd2, &fp->fp_filp_inuse);
r = rfd2;
}
unlock_filp(f);
return(r);
}
/*===========================================================================*
* do_fcntl *
*===========================================================================*/

View File

@ -2,7 +2,6 @@
* seeking on files.
*
* The entry points into this file are
* do_creat: perform the CREAT system call
* do_open: perform the OPEN system call
* do_mknod: perform the MKNOD system call
* do_mkdir: perform the MKDIR system call
@ -38,34 +37,6 @@ static struct vnode *new_node(struct lookup *resolve, int oflags,
mode_t bits);
static int pipe_open(struct vnode *vp, mode_t bits, int oflags);
/*===========================================================================*
* do_creat *
*===========================================================================*/
int do_creat()
{
/* Perform the creat(name, mode) system call.
* syscall might provide 'name' embedded in the message.
*/
char fullpath[PATH_MAX];
vir_bytes vname;
size_t vname_length;
mode_t open_mode;
vname = (vir_bytes) job_m_in.name;
vname_length = (size_t) job_m_in.name_length;
open_mode = (mode_t) job_m_in.mode;
if (copy_name(vname_length, fullpath) != OK) {
/* Direct copy failed, try fetching from user space */
if (fetch_name(vname, vname_length, fullpath) != OK)
return(err_code);
}
return common_open(fullpath, O_WRONLY | O_CREAT | O_TRUNC, open_mode);
}
/*===========================================================================*
* do_open *
*===========================================================================*/
@ -518,7 +489,6 @@ static int pipe_open(struct vnode *vp, mode_t bits, int oflags)
}
} else if (susp_count > 0) { /* revive blocked processes */
release(vp, OPEN, susp_count);
release(vp, CREAT, susp_count);
}
return(OK);
}

View File

@ -360,7 +360,7 @@ void unsuspend_by_endpt(endpoint_t proc_e)
*===========================================================================*/
void release(vp, op, count)
register struct vnode *vp; /* inode of pipe */
int op; /* READ, WRITE, OPEN or CREAT */
int op; /* READ, WRITE, or OPEN */
int count; /* max number of processes to release */
{
/* Check to see if any process is hanging on vnode 'vp'. If one is, and it

View File

@ -130,7 +130,6 @@ void thread_cleanup(struct fproc *rfp);
void unlock_proc(struct fproc *rfp);
/* misc.c */
int do_dup(void);
void pm_exit(int proc);
int do_fcntl(void);
void pm_fork(int pproc, int cproc, int cpid);
@ -257,8 +256,7 @@ int req_rename(endpoint_t fs_e, ino_t old_dir, char *old_name, ino_t new_dir,
int req_rmdir(endpoint_t fs_e, ino_t inode_nr, char *lastc);
int req_slink(endpoint_t fs_e, ino_t inode_nr, char *lastc, endpoint_t proc_e,
vir_bytes path_addr, size_t path_length, uid_t uid, gid_t gid);
int req_stat(endpoint_t fs_e, ino_t inode_nr, endpoint_t proc_e, vir_bytes buf,
int old_stat);
int req_stat(endpoint_t fs_e, ino_t inode_nr, endpoint_t proc_e, vir_bytes buf);
int req_sync(endpoint_t fs_e);
int req_unlink(endpoint_t fs_e, ino_t inode_nr, char *lastc);
int req_unmount(endpoint_t fs_e);

View File

@ -922,26 +922,14 @@ int req_slink(
/*===========================================================================*
* req_stat *
*===========================================================================*/
int req_stat(endpoint_t fs_e, ino_t inode_nr, endpoint_t proc_e, vir_bytes buf,
int old_stat)
int req_stat(endpoint_t fs_e, ino_t inode_nr, endpoint_t proc_e, vir_bytes buf)
{
cp_grant_id_t grant_id;
int r;
message m;
struct stat sb;
struct minix_prev_stat old_sb; /* for backward compatibility */
if (old_stat == 1) {
/* We're dealing with the old stat() call. First copy stat structure
* to VFS so we can convert the new struct stat to the old version.
*/
grant_id = cpf_grant_direct(fs_e, (vir_bytes) &sb, sizeof(struct stat),
CPF_WRITE);
} else {
/* Grant FS access to copy straight into user provided buffer */
grant_id = cpf_grant_magic(fs_e, proc_e, buf, sizeof(struct stat),
CPF_WRITE);
}
/* Grant FS access to copy straight into user provided buffer */
grant_id = cpf_grant_magic(fs_e, proc_e, buf, sizeof(struct stat), CPF_WRITE);
if (grant_id < 0)
panic("req_stat: cpf_grant_* failed");
@ -955,39 +943,6 @@ int req_stat(endpoint_t fs_e, ino_t inode_nr, endpoint_t proc_e, vir_bytes buf,
r = fs_sendrec(fs_e, &m);
cpf_revoke(grant_id);
if (r != OK || old_stat == 0)
return(r);
#if defined(_NETBSD_SOURCE)
#undef st_atime
#undef st_ctime
#undef st_mtime
#endif
/* Copy field by field because of st_gid type mismatch and
* difference in order after atime.
*/
old_sb.st_dev = sb.st_dev;
old_sb.st_ino = sb.st_ino;
old_sb.st_mode = sb.st_mode;
old_sb.st_nlink = sb.st_nlink;
old_sb.st_uid = sb.st_uid;
old_sb.st_gid = sb.st_gid;
old_sb.st_rdev = sb.st_rdev;
old_sb.st_size = sb.st_size;
#if defined(_NETBSD_SOURCE)
old_sb.st_atime = sb.st_atimespec.tv_sec;
old_sb.st_mtime = sb.st_mtimespec.tv_sec;
old_sb.st_ctime = sb.st_ctimespec.tv_sec;
#else
old_sb.st_atime = sb.st_atime;
old_sb.st_mtime = sb.st_mtime;
old_sb.st_ctime = sb.st_ctime;
#endif
r = sys_vircopy(SELF, (vir_bytes) &old_sb, proc_e, buf,
sizeof(struct minix_prev_stat));
return(r);
}

View File

@ -164,7 +164,6 @@ int do_stat()
struct vmnt *vmp;
char fullpath[PATH_MAX];
struct lookup resolve;
int old_stat = 0;
vir_bytes vname1, statbuf;
size_t vname1_length;
@ -176,12 +175,9 @@ int do_stat()
resolve.l_vmnt_lock = VMNT_READ;
resolve.l_vnode_lock = VNODE_READ;
if (job_call_nr == PREV_STAT)
old_stat = 1;
if (fetch_name(vname1, vname1_length, fullpath) != OK) return(err_code);
if ((vp = eat_path(&resolve, fp)) == NULL) return(err_code);
r = req_stat(vp->v_fs_e, vp->v_inode_nr, who_e, statbuf, old_stat);
r = req_stat(vp->v_fs_e, vp->v_inode_nr, who_e, statbuf);
unlock_vnode(vp);
unlock_vmnt(vmp);
@ -197,20 +193,17 @@ int do_fstat()
{
/* Perform the fstat(fd, buf) system call. */
register struct filp *rfilp;
int r, old_stat = 0, rfd;
int r, rfd;
vir_bytes statbuf;
statbuf = (vir_bytes) job_m_in.buffer;
rfd = job_m_in.fd;
if (job_call_nr == PREV_FSTAT)
old_stat = 1;
/* Is the file descriptor valid? */
if ((rfilp = get_filp(rfd, VNODE_READ)) == NULL) return(err_code);
r = req_stat(rfilp->filp_vno->v_fs_e, rfilp->filp_vno->v_inode_nr,
who_e, statbuf, old_stat);
who_e, statbuf);
unlock_filp(rfilp);
@ -306,7 +299,6 @@ int do_lstat()
int r;
char fullpath[PATH_MAX];
struct lookup resolve;
int old_stat = 0;
vir_bytes vname1, statbuf;
size_t vname1_length;
@ -318,11 +310,9 @@ int do_lstat()
resolve.l_vmnt_lock = VMNT_READ;
resolve.l_vnode_lock = VNODE_READ;
if (job_call_nr == PREV_LSTAT)
old_stat = 1;
if (fetch_name(vname1, vname1_length, fullpath) != OK) return(err_code);
if ((vp = eat_path(&resolve, fp)) == NULL) return(err_code);
r = req_stat(vp->v_fs_e, vp->v_inode_nr, who_e, statbuf, old_stat);
r = req_stat(vp->v_fs_e, vp->v_inode_nr, who_e, statbuf);
unlock_vnode(vp);
unlock_vmnt(vmp);

View File

@ -23,7 +23,7 @@ int (*call_vec[])(void) = {
do_open, /* 5 = open */
do_close, /* 6 = close */
no_sys, /* 7 = wait */
do_creat, /* 8 = creat */
no_sys, /* 8 = unused (was creat) */
do_link, /* 9 = link */
do_unlink, /* 10 = unlink */
no_sys, /* 11 = waitpid */
@ -33,7 +33,7 @@ int (*call_vec[])(void) = {
do_chmod, /* 15 = chmod */
do_chown, /* 16 = chown */
no_sys, /* 17 = break */
do_stat, /* 18 = stat (prev)*/
no_sys, /* 18 = unused (was old stat)*/
do_lseek, /* 19 = lseek */
no_sys, /* 20 = getpid */
do_mount, /* 21 = mount */
@ -43,7 +43,7 @@ int (*call_vec[])(void) = {
no_sys, /* 25 = (stime) */
no_sys, /* 26 = ptrace */
no_sys, /* 27 = alarm */
do_fstat, /* 28 = fstat (prev)*/
no_sys, /* 28 = unused (was old fstat)*/
no_sys, /* 29 = pause */
do_utime, /* 30 = utime */
no_sys, /* 31 = (stty) */
@ -56,7 +56,7 @@ int (*call_vec[])(void) = {
do_rename, /* 38 = rename */
do_mkdir, /* 39 = mkdir */
do_unlink, /* 40 = rmdir */
do_dup, /* 41 = dup */
no_sys, /* 41 = unused (was dup) */
do_pipe, /* 42 = pipe */
no_sys, /* 43 = times */
no_sys, /* 44 = (prof) */
@ -65,7 +65,7 @@ int (*call_vec[])(void) = {
no_sys, /* 47 = getgid */
no_sys, /* 48 = (signal)*/
do_rdlink, /* 49 = readlink*/
do_lstat, /* 50 = lstat (prev)*/
no_sys, /* 50 = unused (was old lstat)*/
do_stat, /* 51 = stat */
do_fstat, /* 52 = fstat */
do_lstat, /* 53 = lstat */
@ -80,10 +80,10 @@ int (*call_vec[])(void) = {
no_sys, /* 62 = (setsid)*/
no_sys, /* 63 = (getpgrp)*/
no_sys, /* 64 = (itimer)*/
do_stat, /* 65 = stat - badly numbered, being phased out */
do_fstat, /* 66 = fstat - badly numbered, being phased out */
do_lstat, /* 67 = lstat - badly numbered, being phased out */
no_sys, /* 68 = unused */
no_sys, /* 65 = unused */
no_sys, /* 66 = unused */
no_sys, /* 67 = (getmcontext) */
no_sys, /* 68 = (setmcontext) */
no_sys, /* 69 = unused */
no_sys, /* 70 = unused */
no_sys, /* 71 = (sigaction) */

View File

@ -50,16 +50,6 @@ struct ucred
gid_t gid;
};
#ifdef __minix
/* LSC FIXME: Remove this! Compatibility thing, only used in pfs/uds.c */
struct ucred_old
{
pid_t pid;
short uid;
char gid;
};
#endif /* def __minix */
/* Userland's view of credentials. This should not change */
struct uucred {
unsigned short cr_unused; /* not used, compat */