PERFORCE change 70564 for review
John Baldwin
jhb at FreeBSD.org
Mon Feb 7 14:32:23 PST 2005
http://perforce.freebsd.org/chv.cgi?CH=70564
Change 70564 by jhb at jhb_slimer on 2005/02/07 22:31:33
IFC @70562 (more loopback).
Affected files ...
.. //depot/projects/smpng/sys/compat/svr4/svr4_fcntl.c#19 integrate
.. //depot/projects/smpng/sys/compat/svr4/svr4_ipc.c#6 integrate
.. //depot/projects/smpng/sys/compat/svr4/svr4_misc.c#39 integrate
.. //depot/projects/smpng/sys/compat/svr4/svr4_stat.c#14 integrate
.. //depot/projects/smpng/sys/compat/svr4/svr4_stream.c#22 integrate
.. //depot/projects/smpng/sys/compat/svr4/svr4_sysvec.c#19 integrate
.. //depot/projects/smpng/sys/compat/svr4/svr4_util.h#6 integrate
.. //depot/projects/smpng/sys/i386/ibcs2/ibcs2_fcntl.c#12 integrate
.. //depot/projects/smpng/sys/i386/ibcs2/ibcs2_misc.c#19 integrate
.. //depot/projects/smpng/sys/i386/ibcs2/ibcs2_msg.c#5 integrate
.. //depot/projects/smpng/sys/i386/ibcs2/ibcs2_other.c#7 integrate
.. //depot/projects/smpng/sys/i386/ibcs2/ibcs2_stat.c#13 integrate
.. //depot/projects/smpng/sys/i386/ibcs2/ibcs2_util.c#9 integrate
.. //depot/projects/smpng/sys/i386/ibcs2/ibcs2_util.h#7 integrate
.. //depot/projects/smpng/sys/i386/ibcs2/ibcs2_xenix.c#11 integrate
.. //depot/projects/smpng/sys/kern/kern_time.c#33 integrate
.. //depot/projects/smpng/sys/kern/vfs_syscalls.c#84 integrate
.. //depot/projects/smpng/sys/sys/syscallsubr.h#17 integrate
Differences ...
==== //depot/projects/smpng/sys/compat/svr4/svr4_fcntl.c#19 (text+ko) ====
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/compat/svr4/svr4_fcntl.c,v 1.34 2005/01/05 22:34:36 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/compat/svr4/svr4_fcntl.c,v 1.35 2005/02/07 21:53:41 jhb Exp $");
#include "opt_mac.h"
@@ -41,6 +41,7 @@
/*#include <sys/ioctl.h>*/
#include <sys/lock.h>
#include <sys/mac.h>
+#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/mutex.h>
#include <sys/namei.h>
@@ -366,16 +367,14 @@
struct svr4_sys_open_args *uap;
{
struct proc *p = td->td_proc;
- int error, retval;
- struct open_args cup;
+ char *newpath;
+ int bsd_flags, error, retval;
- caddr_t sg = stackgap_init();
- CHECKALTEXIST(td, &sg, uap->path);
+ CHECKALTEXIST(td, uap->path, &newpath);
- (&cup)->path = uap->path;
- (&cup)->flags = svr4_to_bsd_flags(uap->flags);
- (&cup)->mode = uap->mode;
- error = open(td, &cup);
+ bsd_flags = svr4_to_bsd_flags(uap->flags);
+ error = kern_open(td, newpath, UIO_SYSSPACE, bsd_flags, uap->mode);
+ free(newpath, M_TEMP);
if (error) {
/* uprintf("svr4_open(%s, 0x%0x, 0%o): %d\n", uap->path,
@@ -386,8 +385,8 @@
retval = td->td_retval[0];
PROC_LOCK(p);
- if (!(cup.flags & O_NOCTTY) && SESS_LEADER(p) &&
- !(td->td_proc->p_flag & P_CONTROLT)) {
+ if (!(bsd_flags & O_NOCTTY) && SESS_LEADER(p) &&
+ !(p->p_flag & P_CONTROLT)) {
#if defined(NOTYET)
struct file *fp;
@@ -427,16 +426,15 @@
register struct thread *td;
struct svr4_sys_creat_args *uap;
{
- struct open_args cup;
+ char *newpath;
+ int error;
- caddr_t sg = stackgap_init();
- CHECKALTEXIST(td, &sg, uap->path);
+ CHECKALTEXIST(td, uap->path, &newpath);
- cup.path = uap->path;
- cup.mode = uap->mode;
- cup.flags = O_WRONLY | O_CREAT | O_TRUNC;
-
- return open(td, &cup);
+ error = kern_open(td, newpath, UIO_SYSSPACE, O_WRONLY | O_CREAT |
+ O_TRUNC, uap->mode);
+ free(newpath, M_TEMP);
+ return (error);
}
int
@@ -473,18 +471,13 @@
register struct thread *td;
struct svr4_sys_access_args *uap;
{
- struct access_args cup;
- int *retval;
+ char *newpath;
+ int error;
- caddr_t sg = stackgap_init();
- CHECKALTEXIST(td, &sg, uap->path);
-
- retval = td->td_retval;
-
- cup.path = uap->path;
- cup.flags = uap->flags;
-
- return access(td, &cup);
+ CHECKALTEXIST(td, uap->path, &newpath);
+ error = kern_access(td, newpath, UIO_SYSSPACE, uap->flags);
+ free(newpath, M_TEMP);
+ return (error);
}
#if defined(NOTYET)
==== //depot/projects/smpng/sys/compat/svr4/svr4_ipc.c#6 (text+ko) ====
@@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/compat/svr4/svr4_ipc.c,v 1.14 2005/01/05 22:34:36 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/compat/svr4/svr4_ipc.c,v 1.15 2005/02/07 21:53:41 jhb Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -527,49 +527,32 @@
void *v;
register_t *retval;
{
- int error;
struct svr4_sys_msgctl_args *uap = v;
- struct sys_msgctl_args ap;
struct svr4_msqid_ds ss;
struct msqid_ds bs;
- caddr_t sg = stackgap_init();
-
- ap.msqid = uap->msqid;
- ap.cmd = uap->cmd;
- ap.buf = stackgap_alloc(&sg, sizeof(bs));
+ int error;
switch (uap->cmd) {
case SVR4_IPC_STAT:
- ap.cmd = IPC_STAT;
- if ((error = sys_msgctl(p, &ap, retval)) != 0)
- return error;
- error = copyin(&bs, ap.buf, sizeof bs);
+ error = kern_msgctl(td, uap->msqid, IPC_STAT, &bs);
if (error)
return error;
bsd_to_svr4_msqid_ds(&bs, &ss);
return copyout(&ss, uap->buf, sizeof ss);
case SVR4_IPC_SET:
- ap.cmd = IPC_SET;
error = copyin(uap->buf, &ss, sizeof ss);
if (error)
return error;
svr4_to_bsd_msqid_ds(&ss, &bs);
- error = copyout(&bs, ap.buf, sizeof bs);
- if (error)
- return error;
- return sys_msgctl(p, &ap, retval);
+ return (kern_msgctl(td, uap->msqid, IPC_SET, &bs));
case SVR4_IPC_RMID:
- ap.cmd = IPC_RMID;
error = copyin(uap->buf, &ss, sizeof ss);
if (error)
return error;
svr4_to_bsd_msqid_ds(&ss, &bs);
- error = copyout(&bs, ap.buf, sizeof bs);
- if (error)
- return error;
- return sys_msgctl(p, &ap, retval);
+ return (kern_msgctl(td, uap->msqid, IPC_RMID, &bs));
default:
return EINVAL;
==== //depot/projects/smpng/sys/compat/svr4/svr4_misc.c#39 (text+ko) ====
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/compat/svr4/svr4_misc.c,v 1.78 2005/01/05 22:34:36 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/compat/svr4/svr4_misc.c,v 1.79 2005/02/07 21:53:41 jhb Exp $");
#include "opt_mac.h"
@@ -42,6 +42,7 @@
#include <sys/dirent.h>
#include <sys/fcntl.h>
#include <sys/filedesc.h>
+#include <sys/imgact.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/mac.h>
@@ -164,17 +165,18 @@
struct thread *td;
struct svr4_sys_execv_args *uap;
{
- struct execve_args ap;
- caddr_t sg;
+ struct image_args eargs;
+ char *path;
+ int error;
- sg = stackgap_init();
- CHECKALTEXIST(td, &sg, uap->path);
+ CHECKALTEXIST(td, uap->path, &path);
- ap.fname = uap->path;
- ap.argv = uap->argp;
- ap.envv = NULL;
-
- return execve(td, &ap);
+ error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, uap->argp, NULL);
+ free(path, M_TEMP);
+ if (error == 0)
+ error = kern_execve(td, &eargs, NULL);
+ exec_free_args(&eargs);
+ return (error);
}
int
@@ -182,17 +184,19 @@
struct thread *td;
struct svr4_sys_execve_args *uap;
{
- struct execve_args ap;
- caddr_t sg;
+ struct image_args eargs;
+ char *path;
+ int error;
- sg = stackgap_init();
- CHECKALTEXIST(td, &sg, uap->path);
+ CHECKALTEXIST(td, uap->path, &path);
- ap.fname = uap->path;
- ap.argv = uap->argp;
- ap.envv = uap->envp;
-
- return execve(td, &ap);
+ error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, uap->argp,
+ uap->envp);
+ free(path, M_TEMP);
+ if (error == 0)
+ error = kern_execve(td, &eargs, NULL);
+ exec_free_args(&eargs);
+ return (error);
}
int
@@ -638,22 +642,17 @@
svr4_mode_t mode;
svr4_dev_t dev;
{
- caddr_t sg = stackgap_init();
+ char *newpath;
+ int error;
- CHECKALTEXIST(td, &sg, path);
+ CHECKALTEXIST(td, path, &newpath);
- if (S_ISFIFO(mode)) {
- struct mkfifo_args ap;
- ap.path = path;
- ap.mode = mode;
- return mkfifo(td, &ap);
- } else {
- struct mknod_args ap;
- ap.path = path;
- ap.mode = mode;
- ap.dev = dev;
- return mknod(td, &ap);
- }
+ if (S_ISFIFO(mode))
+ error = kern_mkfifo(td, newpath, UIO_SYSSPACE, mode);
+ else
+ error = kern_mknod(td, newpath, UIO_SYSSPACE, mode, dev);
+ free(newpath, M_TEMP);
+ return (error);
}
@@ -1433,25 +1432,18 @@
struct thread *td;
struct svr4_sys_statvfs_args *uap;
{
- struct statfs_args fs_args;
- caddr_t sg = stackgap_init();
- struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs));
+ struct svr4_statvfs sfs;
struct statfs bfs;
- struct svr4_statvfs sfs;
+ char *path;
int error;
- CHECKALTEXIST(td, &sg, uap->path);
- fs_args.path = uap->path;
- fs_args.buf = fs;
+ CHECKALTEXIST(td, uap->path, &path);
- if ((error = statfs(td, &fs_args)) != 0)
- return error;
-
- if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0)
- return error;
-
+ error = kern_statfs(td, path, UIO_SYSSPACE, &bfs);
+ free(path, M_TEMP);
+ if (error)
+ return (error);
bsd_statfs_to_svr4_statvfs(&bfs, &sfs);
-
return copyout(&sfs, uap->fs, sizeof(sfs));
}
@@ -1461,24 +1453,14 @@
struct thread *td;
struct svr4_sys_fstatvfs_args *uap;
{
- struct fstatfs_args fs_args;
- caddr_t sg = stackgap_init();
- struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs));
+ struct svr4_statvfs sfs;
struct statfs bfs;
- struct svr4_statvfs sfs;
int error;
- fs_args.fd = uap->fd;
- fs_args.buf = fs;
-
- if ((error = fstatfs(td, &fs_args)) != 0)
- return error;
-
- if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0)
- return error;
-
+ error = kern_fstatfs(td, uap->fd, &bfs);
+ if (error)
+ return (error);
bsd_statfs_to_svr4_statvfs(&bfs, &sfs);
-
return copyout(&sfs, uap->fs, sizeof(sfs));
}
@@ -1488,25 +1470,18 @@
struct thread *td;
struct svr4_sys_statvfs64_args *uap;
{
- struct statfs_args fs_args;
- caddr_t sg = stackgap_init();
- struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs));
+ struct svr4_statvfs64 sfs;
struct statfs bfs;
- struct svr4_statvfs64 sfs;
+ char *path;
int error;
- CHECKALTEXIST(td, &sg, uap->path);
- fs_args.path = uap->path;
- fs_args.buf = fs;
+ CHECKALTEXIST(td, uap->path, &path);
- if ((error = statfs(td, &fs_args)) != 0)
- return error;
-
- if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0)
- return error;
-
+ error = kern_statfs(td, path, UIO_SYSSPACE, &bfs);
+ free(path, M_TEMP);
+ if (error)
+ return (error);
bsd_statfs_to_svr4_statvfs64(&bfs, &sfs);
-
return copyout(&sfs, uap->fs, sizeof(sfs));
}
@@ -1516,24 +1491,14 @@
struct thread *td;
struct svr4_sys_fstatvfs64_args *uap;
{
- struct fstatfs_args fs_args;
- caddr_t sg = stackgap_init();
- struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs));
+ struct svr4_statvfs64 sfs;
struct statfs bfs;
- struct svr4_statvfs64 sfs;
int error;
- fs_args.fd = uap->fd;
- fs_args.buf = fs;
-
- if ((error = fstatfs(td, &fs_args)) != 0)
- return error;
-
- if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0)
- return error;
-
+ error = kern_fstatfs(td, uap->fd, &bfs);
+ if (error)
+ return (error);
bsd_statfs_to_svr4_statvfs64(&bfs, &sfs);
-
return copyout(&sfs, uap->fs, sizeof(sfs));
}
@@ -1542,28 +1507,19 @@
struct thread *td;
struct svr4_sys_alarm_args *uap;
{
+ struct itimerval itv, oitv;
int error;
- struct itimerval *itp, *oitp;
- struct setitimer_args sa;
- caddr_t sg = stackgap_init();
- itp = stackgap_alloc(&sg, sizeof(*itp));
- oitp = stackgap_alloc(&sg, sizeof(*oitp));
- timevalclear(&itp->it_interval);
- itp->it_value.tv_sec = uap->sec;
- itp->it_value.tv_usec = 0;
-
- sa.which = ITIMER_REAL;
- sa.itv = itp;
- sa.oitv = oitp;
- error = setitimer(td, &sa);
+ timevalclear(&itv.it_interval);
+ itv.it_value.tv_sec = uap->sec;
+ itv.it_value.tv_usec = 0;
+ error = kern_setitimer(td, ITIMER_REAL, &itv, &oitv);
if (error)
- return error;
- if (oitp->it_value.tv_usec)
- oitp->it_value.tv_sec++;
- td->td_retval[0] = oitp->it_value.tv_sec;
- return 0;
-
+ return (error);
+ if (oitv.it_value.tv_usec != 0)
+ oitv.it_value.tv_sec++;
+ td->td_retval[0] = oitv.it_value.tv_sec;
+ return (0);
}
int
==== //depot/projects/smpng/sys/compat/svr4/svr4_stat.c#14 (text+ko) ====
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/compat/svr4/svr4_stat.c,v 1.19 2005/01/05 22:34:36 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/compat/svr4/svr4_stat.c,v 1.20 2005/02/07 21:53:42 jhb Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -36,8 +36,10 @@
#include <sys/filedesc.h>
#include <sys/jail.h>
#include <sys/kernel.h>
+#include <sys/malloc.h>
#include <sys/unistd.h>
#include <sys/time.h>
+#include <sys/syscallsubr.h>
#include <sys/sysctl.h>
#include <sys/sysproto.h>
#include <sys/un.h>
@@ -160,33 +162,23 @@
struct thread *td;
struct svr4_sys_stat_args *uap;
{
- struct stat st;
- struct svr4_stat svr4_st;
- struct stat_args cup;
- int error;
- caddr_t sg = stackgap_init();
+ struct svr4_stat svr4_st;
+ struct stat st;
+ char *path;
+ int error;
- CHECKALTEXIST(td, &sg, uap->path);
+ CHECKALTEXIST(td, uap->path, &path);
- cup.path = uap->path;
- cup.ub = stackgap_alloc(&sg, sizeof(struct stat));
-
-
- if ((error = stat(td, &cup)) != 0)
- return error;
-
- if ((error = copyin(cup.ub, &st, sizeof st)) != 0)
- return error;
-
+ error = kern_stat(td, path, UIO_SYSSPACE, &st);
+ free(path, M_TEMP);
+ if (error)
+ return (error);
bsd_to_svr4_stat(&st, &svr4_st);
if (S_ISSOCK(st.st_mode))
(void) svr4_add_socket(td, uap->path, &st);
- if ((error = copyout(&svr4_st, uap->ub, sizeof svr4_st)) != 0)
- return error;
-
- return 0;
+ return (copyout(&svr4_st, uap->ub, sizeof svr4_st));
}
@@ -195,32 +187,23 @@
register struct thread *td;
struct svr4_sys_lstat_args *uap;
{
- struct stat st;
- struct svr4_stat svr4_st;
- struct lstat_args cup;
- int error;
- caddr_t sg = stackgap_init();
+ struct svr4_stat svr4_st;
+ struct stat st;
+ char *path;
+ int error;
- CHECKALTEXIST(td, &sg, uap->path);
+ CHECKALTEXIST(td, uap->path, &path);
- cup.path = uap->path;
- cup.ub = stackgap_alloc(&sg, sizeof(struct stat));
-
- if ((error = lstat(td, &cup)) != 0)
- return error;
-
- if ((error = copyin(cup.ub, &st, sizeof st)) != 0)
- return error;
-
+ error = kern_lstat(td, path, UIO_SYSSPACE, &st);
+ free(path, M_TEMP);
+ if (error)
+ return (error);
bsd_to_svr4_stat(&st, &svr4_st);
if (S_ISSOCK(st.st_mode))
(void) svr4_add_socket(td, uap->path, &st);
- if ((error = copyout(&svr4_st, uap->ub, sizeof svr4_st)) != 0)
- return error;
-
- return 0;
+ return (copyout(&svr4_st, uap->ub, sizeof svr4_st));
}
@@ -229,27 +212,16 @@
register struct thread *td;
struct svr4_sys_fstat_args *uap;
{
- struct stat st;
- struct svr4_stat svr4_st;
- struct fstat_args cup;
- int error;
- caddr_t sg = stackgap_init();
+ struct svr4_stat svr4_st;
+ struct stat st;
+ int error;
- cup.fd = uap->fd;
- cup.sb = stackgap_alloc(&sg, sizeof(struct stat));
- if ((error = fstat(td, &cup)) != 0)
- return error;
-
- if ((error = copyin(cup.sb, &st, sizeof st)) != 0)
- return error;
-
+ error = kern_fstat(td, uap->fd, &st);
+ if (error)
+ return (error);
bsd_to_svr4_stat(&st, &svr4_st);
-
- if ((error = copyout(&svr4_st, uap->sb, sizeof svr4_st)) != 0)
- return error;
-
- return 0;
+ return (copyout(&svr4_st, uap->sb, sizeof svr4_st));
}
@@ -258,22 +230,17 @@
register struct thread *td;
struct svr4_sys_xstat_args *uap;
{
- struct stat st;
- struct svr4_xstat svr4_st;
- struct stat_args cup;
- int error;
+ struct svr4_xstat svr4_st;
+ struct stat st;
+ char *path;
+ int error;
- caddr_t sg = stackgap_init();
- CHECKALTEXIST(td, &sg, uap->path);
+ CHECKALTEXIST(td, uap->path, &path);
- cup.path = uap->path;
- cup.ub = stackgap_alloc(&sg, sizeof(struct stat));
-
- if ((error = stat(td, &cup)) != 0)
- return error;
-
- if ((error = copyin(cup.ub, &st, sizeof st)) != 0)
- return error;
+ error = kern_stat(td, path, UIO_SYSSPACE, &st);
+ free(path, M_TEMP);
+ if (error)
+ return (error);
bsd_to_svr4_xstat(&st, &svr4_st);
@@ -282,10 +249,7 @@
(void) svr4_add_socket(td, uap->path, &st);
#endif
- if ((error = copyout(&svr4_st, uap->ub, sizeof svr4_st)) != 0)
- return error;
-
- return 0;
+ return (copyout(&svr4_st, uap->ub, sizeof svr4_st));
}
int
@@ -293,32 +257,25 @@
register struct thread *td;
struct svr4_sys_lxstat_args *uap;
{
- struct stat st;
- struct svr4_xstat svr4_st;
- struct lstat_args cup;
- int error;
- caddr_t sg = stackgap_init();
- CHECKALTEXIST(td, &sg, uap->path);
+ struct svr4_xstat svr4_st;
+ struct stat st;
+ char *path;
+ int error;
- cup.path = uap->path;
- cup.ub = stackgap_alloc(&sg, sizeof(struct stat));
+ CHECKALTEXIST(td, uap->path, &path);
- if ((error = lstat(td, &cup)) != 0)
- return error;
+ error = kern_lstat(td, path, UIO_SYSSPACE, &st);
+ free(path, M_TEMP);
+ if (error)
+ return (error);
- if ((error = copyin(cup.ub, &st, sizeof st)) != 0)
- return error;
-
bsd_to_svr4_xstat(&st, &svr4_st);
#if defined(SOCKET_NOTYET)
if (S_ISSOCK(st.st_mode))
(void) svr4_add_socket(td, uap->path, &st);
#endif
- if ((error = copyout(&svr4_st, uap->ub, sizeof svr4_st)) != 0)
- return error;
-
- return 0;
+ return (copyout(&svr4_st, uap->ub, sizeof svr4_st));
}
@@ -327,28 +284,16 @@
register struct thread *td;
struct svr4_sys_fxstat_args *uap;
{
- struct stat st;
- struct svr4_xstat svr4_st;
- struct fstat_args cup;
- int error;
+ struct svr4_xstat svr4_st;
+ struct stat st;
+ int error;
- caddr_t sg = stackgap_init();
- cup.fd = uap->fd;
- cup.sb = stackgap_alloc(&sg, sizeof(struct stat));
-
- if ((error = fstat(td, &cup)) != 0)
- return error;
-
- if ((error = copyin(cup.sb, &st, sizeof st)) != 0)
- return error;
-
+ error = kern_fstat(td, uap->fd, &st);
+ if (error)
+ return (error);
bsd_to_svr4_xstat(&st, &svr4_st);
-
- if ((error = copyout(&svr4_st, uap->sb, sizeof svr4_st)) != 0)
- return error;
-
- return 0;
+ return (copyout(&svr4_st, uap->sb, sizeof svr4_st));
}
int
@@ -356,32 +301,24 @@
register struct thread *td;
struct svr4_sys_stat64_args *uap;
{
- struct stat st;
- struct svr4_stat64 svr4_st;
- struct stat_args cup;
- int error;
- caddr_t sg = stackgap_init();
+ struct svr4_stat64 svr4_st;
+ struct stat st;
+ char *path;
+ int error;
- CHECKALTEXIST(td, &sg, uap->path);
+ CHECKALTEXIST(td, uap->path, &path);
- cup.path = uap->path;
- cup.ub = stackgap_alloc(&sg, sizeof(struct stat));
-
- if ((error = stat(td, &cup)) != 0)
- return error;
+ error = kern_stat(td, path, UIO_SYSSPACE, &st);
+ free(path, M_TEMP);
+ if (error)
+ return (error);
- if ((error = copyin(cup.ub, &st, sizeof st)) != 0)
- return error;
-
bsd_to_svr4_stat64(&st, &svr4_st);
if (S_ISSOCK(st.st_mode))
(void) svr4_add_socket(td, uap->path, &st);
- if ((error = copyout(&svr4_st, uap->sb, sizeof svr4_st)) != 0)
- return error;
-
- return 0;
+ return (copyout(&svr4_st, uap->sb, sizeof svr4_st));
}
@@ -390,32 +327,24 @@
register struct thread *td;
struct svr4_sys_lstat64_args *uap;
{
- struct stat st;
- struct svr4_stat64 svr4_st;
- struct stat_args cup;
- int error;
- caddr_t sg = stackgap_init();
+ struct svr4_stat64 svr4_st;
+ struct stat st;
+ char *path;
+ int error;
- CHECKALTEXIST(td, &sg, (char *) uap->path);
+ CHECKALTEXIST(td, uap->path, &path);
- cup.path = uap->path;
- cup.ub = stackgap_alloc(&sg, sizeof(struct stat));
+ error = kern_lstat(td, path, UIO_SYSSPACE, &st);
+ free(path, M_TEMP);
+ if (error)
+ return (error);
- if ((error = lstat(td, (struct lstat_args *)&cup)) != 0)
- return error;
-
- if ((error = copyin(cup.ub, &st, sizeof st)) != 0)
- return error;
-
bsd_to_svr4_stat64(&st, &svr4_st);
if (S_ISSOCK(st.st_mode))
(void) svr4_add_socket(td, uap->path, &st);
- if ((error = copyout(&svr4_st, uap->sb, sizeof svr4_st)) != 0)
- return error;
-
- return 0;
+ return (copyout(&svr4_st, uap->sb, sizeof svr4_st));
}
@@ -424,27 +353,15 @@
register struct thread *td;
struct svr4_sys_fstat64_args *uap;
{
- struct stat st;
- struct svr4_stat64 svr4_st;
- struct fstat_args cup;
- int error;
- caddr_t sg = stackgap_init();
+ struct svr4_stat64 svr4_st;
+ struct stat st;
+ int error;
- cup.fd = uap->fd;
- cup.sb = stackgap_alloc(&sg, sizeof(struct stat));
-
- if ((error = fstat(td, &cup)) != 0)
- return error;
-
- if ((error = copyin(cup.sb, &st, sizeof st)) != 0)
- return error;
-
+ error = kern_fstat(td, uap->fd, &st);
+ if (error)
+ return (error);
bsd_to_svr4_stat64(&st, &svr4_st);
-
- if ((error = copyout(&svr4_st, uap->sb, sizeof svr4_st)) != 0)
- return error;
-
- return 0;
+ return (copyout(&svr4_st, uap->sb, sizeof svr4_st));
}
@@ -636,30 +553,26 @@
struct svr4_sys_utime_args *uap;
{
struct svr4_utimbuf ub;
- struct timeval tbuf[2];
- struct utimes_args ap;
+ struct timeval tbuf[2], *tp;
+ char *path;
int error;
- caddr_t sg = stackgap_init();
- void *ttp;
-
- CHECKALTEXIST(td, &sg, uap->path);
- ap.path = uap->path;
+
if (uap->ubuf != NULL) {
- if ((error = copyin(uap->ubuf, &ub, sizeof(ub))) != 0)
- return error;
+ error = copyin(uap->ubuf, &ub, sizeof(ub));
+ if (error)
+ return (error);
tbuf[0].tv_sec = ub.actime;
tbuf[0].tv_usec = 0;
tbuf[1].tv_sec = ub.modtime;
tbuf[1].tv_usec = 0;
- ttp = stackgap_alloc(&sg, sizeof(tbuf));
- error = copyout(tbuf, ttp, sizeof(tbuf));
- if (error)
- return error;
- ap.tptr = ttp;
- }
- else
- ap.tptr = NULL;
- return utimes(td, &ap);
+ tp = tbuf;
+ } else
+ tp = NULL;
+
+ CHECKALTEXIST(td, uap->path, &path);
+ error = kern_utimes(td, path, UIO_SYSSPACE, tp, UIO_SYSSPACE);
+ free(path, M_TEMP);
+ return (error);
}
@@ -668,9 +581,13 @@
register struct thread *td;
struct svr4_sys_utimes_args *uap;
{
- caddr_t sg = stackgap_init();
- CHECKALTEXIST(td, &sg, uap->path);
- return utimes(td, (struct utimes_args *)uap);
+ char *path;
+ int error;
+
+ CHECKALTEXIST(td, uap->path, &path);
+ error = kern_utimes(td, path, UIO_SYSSPACE, uap->tptr, UIO_USERSPACE);
+ free(path, M_TEMP);
+ return (error);
}
static int
@@ -727,22 +644,23 @@
register struct thread *td;
struct svr4_sys_pathconf_args *uap;
{
- caddr_t sg = stackgap_init();
- register_t *retval = td->td_retval;
+ char *path;
+ int error, name;
- CHECKALTEXIST(td, &sg, uap->path);
+ name = svr4_to_bsd_pathconf(uap->name);
- uap->name = svr4_to_bsd_pathconf(uap->name);
-
- switch (uap->name) {
+ switch (name) {
case -1:
- *retval = -1;
- return EINVAL;
+ td->td_retval[0] = -1;
+ return (EINVAL);
case 0:
- *retval = 0;
- return 0;
+ td->td_retval[0] = 0;
+ return (0);
default:
- return pathconf(td, (struct pathconf_args *)uap);
+ CHECKALTEXIST(td, uap->path, &path);
+ error = kern_pathconf(td, path, UIO_SYSSPACE, name);
+ free(path, M_TEMP);
+ return (error);
}
}
==== //depot/projects/smpng/sys/compat/svr4/svr4_stream.c#22 (text+ko) ====
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/compat/svr4/svr4_stream.c,v 1.51 2005/01/05 22:34:37 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/compat/svr4/svr4_stream.c,v 1.52 2005/02/07 21:53:42 jhb Exp $");
#define COMPAT_43 1
@@ -80,7 +80,7 @@
#include <compat/svr4/svr4_socket.h>
/* Utils */
-static int clean_pipe(struct thread *, const char *);
+static int clean_pipe(struct thread *, char *);
static void getparm(struct file *, struct svr4_si_sockparms *);
static int svr4_do_putmsg(struct thread *, struct svr4_sys_putmsg_args *,
struct file *);
@@ -509,48 +509,26 @@
static int
clean_pipe(td, path)
struct thread *td;
- const char *path;
+ char *path;
{
- struct lstat_args la;
- struct unlink_args ua;
struct stat st;
int error;
- caddr_t sg = stackgap_init();
- size_t l = strlen(path) + 1;
- void *tpath;
- if ((tpath = stackgap_alloc(&sg, l)) == NULL)
- return ENAMETOOLONG;
- la.ub = stackgap_alloc(&sg, sizeof(struct stat));
-
- if ((error = copyout(path, tpath, l)) != 0)
- return error;
-
- la.path = tpath;
+ error = kern_lstat(td, path, UIO_SYSSPACE, &st);
- if ((error = lstat(td, &la)) != 0)
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list