Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Apr 2007 20:40:34 GMT
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 117977 for review
Message-ID:  <200704122040.l3CKeY7b006943@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=117977

Change 117977 by peter@peter_overcee on 2007/04/12 20:39:33

	Add working forward compatability stubs for __xstat family.

Affected files ...

.. //depot/projects/hammer/sys/kern/init_sysent.c#59 edit
.. //depot/projects/hammer/sys/kern/kern_descrip.c#65 edit
.. //depot/projects/hammer/sys/kern/syscalls.c#57 edit
.. //depot/projects/hammer/sys/kern/syscalls.master#58 edit
.. //depot/projects/hammer/sys/kern/systrace_args.c#3 edit
.. //depot/projects/hammer/sys/kern/vfs_syscalls.c#66 edit
.. //depot/projects/hammer/sys/sys/_types.h#16 edit
.. //depot/projects/hammer/sys/sys/stat.h#12 edit
.. //depot/projects/hammer/sys/sys/syscall.h#56 edit
.. //depot/projects/hammer/sys/sys/syscall.mk#56 edit
.. //depot/projects/hammer/sys/sys/sysproto.h#57 edit
.. //depot/projects/hammer/sys/sys/vnode.h#70 edit

Differences ...

==== //depot/projects/hammer/sys/kern/init_sysent.c#59 (text+ko) ====

@@ -447,9 +447,9 @@
 	{ AS(__mac_execve_args), (sy_call_t *)__mac_execve, AUE_NULL, NULL, 0, 0 },	/* 415 = __mac_execve */
 	{ AS(sigaction_args), (sy_call_t *)sigaction, AUE_SIGACTION, NULL, 0, 0 },	/* 416 = sigaction */
 	{ AS(sigreturn_args), (sy_call_t *)sigreturn, AUE_SIGRETURN, NULL, 0, 0 },	/* 417 = sigreturn */
-	{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 },			/* 418 = __xstat */
-	{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 },			/* 419 = __xfstat */
-	{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 },			/* 420 = __xlstat */
+	{ AS(__xstat_args), (sy_call_t *)__xstat, AUE_STAT, NULL, 0, 0 },	/* 418 = __xstat */
+	{ AS(__xfstat_args), (sy_call_t *)__xfstat, AUE_FSTAT, NULL, 0, 0 },	/* 419 = __xfstat */
+	{ AS(__xlstat_args), (sy_call_t *)__xlstat, AUE_LSTAT, NULL, 0, 0 },	/* 420 = __xlstat */
 	{ AS(getcontext_args), (sy_call_t *)getcontext, AUE_NULL, NULL, 0, 0 },	/* 421 = getcontext */
 	{ AS(setcontext_args), (sy_call_t *)setcontext, AUE_NULL, NULL, 0, 0 },	/* 422 = setcontext */
 	{ AS(swapcontext_args), (sy_call_t *)swapcontext, AUE_NULL, NULL, 0, 0 },	/* 423 = swapcontext */

==== //depot/projects/hammer/sys/kern/kern_descrip.c#65 (text+ko) ====

@@ -1080,6 +1080,31 @@
 	return (error);
 }
 
+#ifndef _SYS_SYSPROTO_H_
+struct __xfstat_args {
+	int	ver;
+	int	fd;
+	struct	_new_stat *sb;
+};
+#endif
+/* ARGSUSED */
+int
+__xfstat(struct thread *td, struct __xfstat_args *uap)
+{
+	struct stat ub;
+	struct _new_stat nub;
+	int error;
+
+	if (uap->ver != __STATVER)
+		return (EOPNOTSUPP);
+	error = kern_fstat(td, uap->fd, &ub);
+	if (error == 0) {
+		cvtnewstat(&ub, &nub);
+		error = copyout(&nub, uap->sb, sizeof(nub));
+	}
+	return (error);
+}
+
 int
 kern_fstat(struct thread *td, int fd, struct stat *sbp)
 {

==== //depot/projects/hammer/sys/kern/syscalls.c#57 (text+ko) ====

@@ -425,9 +425,9 @@
 	"__mac_execve",			/* 415 = __mac_execve */
 	"sigaction",			/* 416 = sigaction */
 	"sigreturn",			/* 417 = sigreturn */
-	"#418",			/* 418 = __xstat */
-	"#419",			/* 419 = __xfstat */
-	"#420",			/* 420 = __xlstat */
+	"__xstat",			/* 418 = __xstat */
+	"__xfstat",			/* 419 = __xfstat */
+	"__xlstat",			/* 420 = __xlstat */
 	"getcontext",			/* 421 = getcontext */
 	"setcontext",			/* 422 = setcontext */
 	"swapcontext",			/* 423 = swapcontext */

==== //depot/projects/hammer/sys/kern/syscalls.master#58 (text+ko) ====

@@ -735,9 +735,12 @@
 				    struct sigaction *oact); }
 417	AUE_SIGRETURN	STD	{ int sigreturn( \
 				    const struct __ucontext *sigcntxp); }
-418	AUE_NULL	UNIMPL	__xstat
-419	AUE_NULL	UNIMPL	__xfstat
-420	AUE_NULL	UNIMPL	__xlstat
+418	AUE_STAT	STD	{ int __xstat(int ver, char *path, \
+				    struct _new_stat *ub); }
+419	AUE_FSTAT	STD	{ int __xfstat(int ver, int fd, \
+				    struct _new_stat *sb); }
+420	AUE_LSTAT	STD	{ int __xlstat(int ver, char *path, \
+				    struct _new_stat *ub); }
 421	AUE_NULL	STD	{ int getcontext(struct __ucontext *ucp); }
 422	AUE_NULL	STD	{ int setcontext( \
 				    const struct __ucontext *ucp); }

==== //depot/projects/hammer/sys/kern/systrace_args.c#3 (text+ko) ====

@@ -2380,6 +2380,33 @@
 		*n_args = 1;
 		break;
 	}
+	/* __xstat */
+	case 418: {
+		struct __xstat_args *p = params;
+		iarg[0] = p->ver; /* int */
+		uarg[1] = (intptr_t) p->path; /* char * */
+		uarg[2] = (intptr_t) p->ub; /* struct _new_stat * */
+		*n_args = 3;
+		break;
+	}
+	/* __xfstat */
+	case 419: {
+		struct __xfstat_args *p = params;
+		iarg[0] = p->ver; /* int */
+		iarg[1] = p->fd; /* int */
+		uarg[2] = (intptr_t) p->sb; /* struct _new_stat * */
+		*n_args = 3;
+		break;
+	}
+	/* __xlstat */
+	case 420: {
+		struct __xlstat_args *p = params;
+		iarg[0] = p->ver; /* int */
+		uarg[1] = (intptr_t) p->path; /* char * */
+		uarg[2] = (intptr_t) p->ub; /* struct _new_stat * */
+		*n_args = 3;
+		break;
+	}
 	/* getcontext */
 	case 421: {
 		struct getcontext_args *p = params;

==== //depot/projects/hammer/sys/kern/vfs_syscalls.c#66 (text+ko) ====

@@ -2033,6 +2033,33 @@
 #endif /* COMPAT_43 */
 
 /*
+ * Convert from a current to new stat structure.
+ */
+void
+cvtnewstat(st, nst)
+	struct stat *st;
+	struct _new_stat *nst;
+{
+	bzero(nst, sizeof *nst);
+	nst->st_dev = st->st_dev;
+	nst->st_ino = st->st_ino;
+	nst->st_mode = st->st_mode;
+	nst->st_nlink = st->st_nlink;
+	nst->st_uid = st->st_uid;
+	nst->st_gid = st->st_gid;
+	nst->st_rdev = st->st_rdev;
+	nst->st_atimespec = st->st_atimespec;
+	nst->st_mtimespec = st->st_mtimespec;
+	nst->st_ctimespec = st->st_ctimespec;
+	nst->st_size = st->st_size;
+	nst->st_blocks = st->st_blocks;
+	nst->st_blksize = st->st_blksize;
+	nst->st_flags = st->st_flags;
+	nst->st_gen = st->st_gen;
+	nst->st_birthtimespec = st->st_birthtimespec;
+}
+
+/*
  * Get file status; this version follows links.
  */
 #ifndef _SYS_SYSPROTO_H_
@@ -2058,7 +2085,31 @@
 	return (error);
 }
 
+#ifndef _SYS_SYSPROTO_H_
+struct __xstat_args {
+	int	ver;
+	char	*path;
+	struct _new_stat *ub;
+};
+#endif
 int
+__xstat(struct thread *td, struct __xstat_args *uap)
+{
+	struct stat sb;
+	struct _new_stat nsb;
+	int error;
+
+	if (uap->ver != __STATVER)
+		return (EOPNOTSUPP);
+	error = kern_stat(td, uap->path, UIO_USERSPACE, &sb);
+	if (error == 0) {
+		cvtnewstat(&sb, &nsb);
+		error = copyout(&nsb, uap->ub, sizeof (nsb));
+	}
+	return (error);
+}
+
+int
 kern_stat(struct thread *td, char *path, enum uio_seg pathseg, struct stat *sbp)
 {
 	struct nameidata nd;
@@ -2109,6 +2160,30 @@
 	return (error);
 }
 
+#ifndef _SYS_SYSPROTO_H_
+struct __xlstat_args {
+	int	ver;
+	char	*path;
+	struct _new_stat *ub;
+};
+#endif
+int
+__xlstat(struct thread *td, struct __xlstat_args *uap)
+{
+	struct stat sb;
+	struct _new_stat nsb;
+	int error;
+
+	if (uap->ver != __STATVER)
+		return (EOPNOTSUPP);
+	error = kern_lstat(td, uap->path, UIO_USERSPACE, &sb);
+	if (error == 0) {
+		cvtnewstat(&sb, &nsb);
+		error = copyout(&nsb, uap->ub, sizeof (nsb));
+	}
+	return (error);
+}
+
 int
 kern_lstat(struct thread *td, char *path, enum uio_seg pathseg, struct stat *sbp)
 {

==== //depot/projects/hammer/sys/sys/_types.h#16 (text+ko) ====

@@ -62,6 +62,11 @@
 typedef	__uint32_t	__uid_t;
 typedef	unsigned int	__useconds_t;	/* microseconds (unsigned) */
 
+/* New types for 64 bit inode number support (forward compat only) */
+typedef	__uint64_t	__new_ino_t;	/* inode number */
+typedef	__uint32_t	__new_mode_t;	/* permissions */
+typedef	__uint32_t	__new_nlink_t;	/* link count */
+
 /*
  * Unusual type definitions.
  */

==== //depot/projects/hammer/sys/sys/stat.h#12 (text+ko) ====

@@ -174,6 +174,40 @@
 #endif
 };
 
+/* New 64 bit inode number support forward compatability */
+struct _new_stat {
+	__dev_t	  st_dev;		/* inode's device */
+	__dev_t	  st_rdev;		/* device type */
+	__new_mode_t st_mode;		/* inode protection mode */
+	__new_nlink_t st_nlink;		/* number of hard links */
+	uid_t	  st_uid;		/* user ID of the file's owner */
+	gid_t	  st_gid;		/* group ID of the file's group */
+	__new_ino_t st_ino;		/* inode's number */
+#if __BSD_VISIBLE
+	struct	timespec st_atimespec;	/* time of last access */
+	struct	timespec st_mtimespec;	/* time of last data modification */
+	struct	timespec st_ctimespec;	/* time of last file status change */
+	struct	timespec st_birthtimespec; /* time of file creation */
+#else
+	time_t	  st_atime;		/* time of last access */
+	long	  st_atimensec;		/* nsec of last access */
+	time_t	  st_mtime;		/* time of last data modification */
+	long	  st_mtimensec;		/* nsec of last data modification */
+	time_t	  st_ctime;		/* time of last file status change */
+	long	  st_ctimensec;		/* nsec of last file status change */
+	time_t	  st_birthtime;		/* time of file creation */
+	long	  st_birthtimensec;	/* nsec of file creation */
+#endif
+	off_t	  st_size;		/* file size, in bytes */
+	__int64_t st_blocks;		/* blocks allocated for file */
+	__uint32_t st_blksize;		/* optimal blocksize for I/O */
+	fflags_t  st_flags;		/* user defined flags for file */
+	__uint32_t st_gen;		/* file generation number */
+	__int32_t  __pad2;		/* pad to 64 bit alignment */
+	__int64_t  __pad3[4];		/* spare */
+};
+#define __STATVER 700	/* FreeBSD 7.0 */
+
 #if __BSD_VISIBLE
 struct nstat {
 	__dev_t   st_dev;		/* inode's device */

==== //depot/projects/hammer/sys/sys/syscall.h#56 (text+ko) ====

@@ -344,6 +344,9 @@
 #define	SYS___mac_execve	415
 #define	SYS_sigaction	416
 #define	SYS_sigreturn	417
+#define	SYS___xstat	418
+#define	SYS___xfstat	419
+#define	SYS___xlstat	420
 #define	SYS_getcontext	421
 #define	SYS_setcontext	422
 #define	SYS_swapcontext	423

==== //depot/projects/hammer/sys/sys/syscall.mk#56 (text+ko) ====

@@ -286,6 +286,9 @@
 	__mac_execve.o \
 	sigaction.o \
 	sigreturn.o \
+	__xstat.o \
+	__xfstat.o \
+	__xlstat.o \
 	getcontext.o \
 	setcontext.o \
 	swapcontext.o \

==== //depot/projects/hammer/sys/sys/sysproto.h#57 (text+ko) ====

@@ -1257,6 +1257,21 @@
 struct sigreturn_args {
 	char sigcntxp_l_[PADL_(const struct __ucontext *)]; const struct __ucontext * sigcntxp; char sigcntxp_r_[PADR_(const struct __ucontext *)];
 };
+struct __xstat_args {
+	char ver_l_[PADL_(int)]; int ver; char ver_r_[PADR_(int)];
+	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
+	char ub_l_[PADL_(struct _new_stat *)]; struct _new_stat * ub; char ub_r_[PADR_(struct _new_stat *)];
+};
+struct __xfstat_args {
+	char ver_l_[PADL_(int)]; int ver; char ver_r_[PADR_(int)];
+	char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)];
+	char sb_l_[PADL_(struct _new_stat *)]; struct _new_stat * sb; char sb_r_[PADR_(struct _new_stat *)];
+};
+struct __xlstat_args {
+	char ver_l_[PADL_(int)]; int ver; char ver_r_[PADR_(int)];
+	char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)];
+	char ub_l_[PADL_(struct _new_stat *)]; struct _new_stat * ub; char ub_r_[PADR_(struct _new_stat *)];
+};
 struct getcontext_args {
 	char ucp_l_[PADL_(struct __ucontext *)]; struct __ucontext * ucp; char ucp_r_[PADR_(struct __ucontext *)];
 };
@@ -1797,6 +1812,9 @@
 int	__mac_execve(struct thread *, struct __mac_execve_args *);
 int	sigaction(struct thread *, struct sigaction_args *);
 int	sigreturn(struct thread *, struct sigreturn_args *);
+int	__xstat(struct thread *, struct __xstat_args *);
+int	__xfstat(struct thread *, struct __xfstat_args *);
+int	__xlstat(struct thread *, struct __xlstat_args *);
 int	getcontext(struct thread *, struct getcontext_args *);
 int	setcontext(struct thread *, struct setcontext_args *);
 int	swapcontext(struct thread *, struct swapcontext_args *);
@@ -2354,6 +2372,9 @@
 #define	SYS_AUE___mac_execve	AUE_NULL
 #define	SYS_AUE_sigaction	AUE_SIGACTION
 #define	SYS_AUE_sigreturn	AUE_SIGRETURN
+#define	SYS_AUE___xstat	AUE_STAT
+#define	SYS_AUE___xfstat	AUE_FSTAT
+#define	SYS_AUE___xlstat	AUE_LSTAT
 #define	SYS_AUE_getcontext	AUE_NULL
 #define	SYS_AUE_setcontext	AUE_NULL
 #define	SYS_AUE_swapcontext	AUE_NULL

==== //depot/projects/hammer/sys/sys/vnode.h#70 (text+ko) ====

@@ -550,6 +550,7 @@
 struct thread;
 struct proc;
 struct stat;
+struct _new_stat;
 struct nstat;
 struct ucred;
 struct uio;
@@ -569,6 +570,7 @@
 int	change_dir(struct vnode *vp, struct thread *td);
 int	change_root(struct vnode *vp, struct thread *td);
 void	cvtstat(struct stat *st, struct ostat *ost);
+void	cvtnewstat(struct stat *st, struct _new_stat *ost);
 void	cvtnstat(struct stat *sb, struct nstat *nsb);
 int	getnewvnode(const char *tag, struct mount *mp, struct vop_vector *vops,
 	    struct vnode **vpp);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200704122040.l3CKeY7b006943>