PERFORCE change 18355 for review

Robert Watson rwatson at freebsd.org
Mon Sep 30 03:37:16 GMT 2002


http://people.freebsd.org/~peter/p4db/chv.cgi?CH=18355

Change 18355 by rwatson at rwatson_tislabs on 2002/09/29 20:36:50

	Introduce extattr_{delete,get,set}_link(), which are the same
	as extattr_{delete,get,set}_file() except that they don't
	follow symbolic links.  Restore FOLLOW behavior to the _file()
	calls as present in the main tree, and use NOFOLLOW for _link().
	This will permit user applications to directly manipulate
	extended attributes on symlinks.  This is a rapid merge-to-
	main-tree target.  Follow-up modifications to user extattr
	tools expected also.

Affected files ...

.. //depot/projects/trustedbsd/mac/sys/kern/init_sysent.c#32 edit
.. //depot/projects/trustedbsd/mac/sys/kern/syscalls.c#32 edit
.. //depot/projects/trustedbsd/mac/sys/kern/syscalls.master#28 edit
.. //depot/projects/trustedbsd/mac/sys/kern/vfs_syscalls.c#83 edit
.. //depot/projects/trustedbsd/mac/sys/sys/extattr.h#6 edit
.. //depot/projects/trustedbsd/mac/sys/sys/syscall.h#32 edit
.. //depot/projects/trustedbsd/mac/sys/sys/syscall.mk#32 edit
.. //depot/projects/trustedbsd/mac/sys/sys/sysproto.h#33 edit

Differences ...

==== //depot/projects/trustedbsd/mac/sys/kern/init_sysent.c#32 (text+ko) ====

@@ -427,4 +427,7 @@
 	{ SYF_MPSAFE | AS(macctl_args), (sy_call_t *)macctl },	/* 396 = macctl */
 	{ SYF_MPSAFE | AS(__mac_get_link_args), (sy_call_t *)__mac_get_link },	/* 397 = __mac_get_link */
 	{ SYF_MPSAFE | AS(__mac_set_link_args), (sy_call_t *)__mac_set_link },	/* 398 = __mac_set_link */
+	{ AS(extattr_set_link_args), (sy_call_t *)extattr_set_link },	/* 399 = extattr_set_link */
+	{ AS(extattr_get_link_args), (sy_call_t *)extattr_get_link },	/* 400 = extattr_get_link */
+	{ AS(extattr_delete_link_args), (sy_call_t *)extattr_delete_link },	/* 401 = extattr_delete_link */
 };

==== //depot/projects/trustedbsd/mac/sys/kern/syscalls.c#32 (text+ko) ====

@@ -406,4 +406,7 @@
 	"macctl",			/* 396 = macctl */
 	"__mac_get_link",			/* 397 = __mac_get_link */
 	"__mac_set_link",			/* 398 = __mac_set_link */
+	"extattr_set_link",			/* 399 = extattr_set_link */
+	"extattr_get_link",			/* 400 = extattr_get_link */
+	"extattr_delete_link",			/* 401 = extattr_delete_link */
 };

==== //depot/projects/trustedbsd/mac/sys/kern/syscalls.master#28 (text+ko) ====

@@ -576,3 +576,11 @@
 			    struct mac *mac_p); }
 398	MSTD	BSD	{ int __mac_set_link(const char *path_p, \
 			    struct mac *mac_p); }
+399	STD	BSD	{ int extattr_set_link(const char *path, \
+			    int attrnamespace, const char *attrname, \
+			    void *data, size_t nbytes); }
+400	STD	BSD	{ ssize_t extattr_get_link(const char *path, \
+			    int attrnamespace, const char *attrname, \
+			    void *data, size_t nbytes); }
+401	STD	BSD	{ int extattr_delete_link(const char *path, \
+			    int attrnamespace, const char *attrname); }

==== //depot/projects/trustedbsd/mac/sys/kern/vfs_syscalls.c#83 (text+ko) ====

@@ -3902,6 +3902,35 @@
 }
 
 int
+extattr_set_fd(td, uap)
+	struct thread *td;
+	struct extattr_set_fd_args /* {
+		syscallarg(int) fd;
+		syscallarg(int) attrnamespace;
+		syscallarg(const char *) attrname;
+		syscallarg(void *) data;
+		syscallarg(size_t) nbytes;
+	} */ *uap;
+{
+	struct file *fp;
+	char attrname[EXTATTR_MAXNAMELEN];
+	int error;
+
+	error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL);
+	if (error)
+		return (error);
+
+	if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
+		return (error);
+
+	error = extattr_set_vp((struct vnode *)fp->f_data, uap->attrnamespace,
+	    attrname, uap->data, uap->nbytes, td);
+	fdrop(fp, td);
+
+	return (error);
+}
+
+int
 extattr_set_file(td, uap)
 	struct thread *td;
 	struct extattr_set_file_args /* {
@@ -3920,7 +3949,7 @@
 	if (error)
 		return (error);
 
-	NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, td);
+	NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, td);
 	if ((error = namei(&nd)) != 0)
 		return (error);
 	NDFREE(&nd, NDF_ONLY_PNBUF);
@@ -3933,17 +3962,17 @@
 }
 
 int
-extattr_set_fd(td, uap)
+extattr_set_link(td, uap)
 	struct thread *td;
-	struct extattr_set_fd_args /* {
-		syscallarg(int) fd;
+	struct extattr_set_link_args /* {
+		syscallarg(const char *) path;
 		syscallarg(int) attrnamespace;
 		syscallarg(const char *) attrname;
 		syscallarg(void *) data;
 		syscallarg(size_t) nbytes;
 	} */ *uap;
 {
-	struct file *fp;
+	struct nameidata nd;
 	char attrname[EXTATTR_MAXNAMELEN];
 	int error;
 
@@ -3951,13 +3980,15 @@
 	if (error)
 		return (error);
 
-	if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
+	NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, td);
+	if ((error = namei(&nd)) != 0)
 		return (error);
+	NDFREE(&nd, NDF_ONLY_PNBUF);
 
-	error = extattr_set_vp((struct vnode *)fp->f_data, uap->attrnamespace,
-	    attrname, uap->data, uap->nbytes, td);
-	fdrop(fp, td);
+	error = extattr_set_vp(nd.ni_vp, uap->attrnamespace, attrname,
+	    uap->data, uap->nbytes, td);
 
+	vrele(nd.ni_vp);
 	return (error);
 }
 
@@ -4032,6 +4063,35 @@
 }
 
 int
+extattr_get_fd(td, uap)
+	struct thread *td;
+	struct extattr_get_fd_args /* {
+		syscallarg(int) fd;
+		syscallarg(int) attrnamespace;
+		syscallarg(const char *) attrname;
+		syscallarg(void *) data;
+		syscallarg(size_t) nbytes;
+	} */ *uap;
+{
+	struct file *fp;
+	char attrname[EXTATTR_MAXNAMELEN];
+	int error;
+
+	error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL);
+	if (error)
+		return (error);
+
+	if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
+		return (error);
+
+	error = extattr_get_vp((struct vnode *)fp->f_data, uap->attrnamespace,
+	    attrname, uap->data, uap->nbytes, td);
+
+	fdrop(fp, td);
+	return (error);
+}
+
+int
 extattr_get_file(td, uap)
 	struct thread *td;
 	struct extattr_get_file_args /* {
@@ -4050,7 +4110,7 @@
 	if (error)
 		return (error);
 
-	NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, td);
+	NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, td);
 	if ((error = namei(&nd)) != 0)
 		return (error);
 	NDFREE(&nd, NDF_ONLY_PNBUF);
@@ -4063,17 +4123,17 @@
 }
 
 int
-extattr_get_fd(td, uap)
+extattr_get_link(td, uap)
 	struct thread *td;
-	struct extattr_get_fd_args /* {
-		syscallarg(int) fd;
+	struct extattr_get_link_args /* {
+		syscallarg(const char *) path;
 		syscallarg(int) attrnamespace;
 		syscallarg(const char *) attrname;
 		syscallarg(void *) data;
 		syscallarg(size_t) nbytes;
 	} */ *uap;
 {
-	struct file *fp;
+	struct nameidata nd;
 	char attrname[EXTATTR_MAXNAMELEN];
 	int error;
 
@@ -4081,13 +4141,15 @@
 	if (error)
 		return (error);
 
-	if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
+	NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, td);
+	if ((error = namei(&nd)) != 0)
 		return (error);
+	NDFREE(&nd, NDF_ONLY_PNBUF);
 
-	error = extattr_get_vp((struct vnode *)fp->f_data, uap->attrnamespace,
-	    attrname, uap->data, uap->nbytes, td);
+	error = extattr_get_vp(nd.ni_vp, uap->attrnamespace, attrname,
+	    uap->data, uap->nbytes, td);
 
-	fdrop(fp, td);
+	vrele(nd.ni_vp);
 	return (error);
 }
 
@@ -4127,6 +4189,34 @@
 }
 
 int
+extattr_delete_fd(td, uap)
+	struct thread *td;
+	struct extattr_delete_fd_args /* {
+		syscallarg(int) fd;
+		syscallarg(int) attrnamespace;
+		syscallarg(const char *) attrname;
+	} */ *uap;
+{
+	struct file *fp;
+	struct vnode *vp;
+	char attrname[EXTATTR_MAXNAMELEN];
+	int error;
+
+	error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL);
+	if (error)
+		return (error);
+
+	if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
+		return (error);
+	vp = (struct vnode *)fp->f_data;
+
+	error = extattr_delete_vp(vp, uap->attrnamespace, attrname, td);
+
+	fdrop(fp, td);
+	return (error);
+}
+
+int
 extattr_delete_file(td, uap)
 	struct thread *td;
 	struct extattr_delete_file_args /* {
@@ -4143,7 +4233,7 @@
 	if (error)
 		return(error);
 
-	NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, td);
+	NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, td);
 	if ((error = namei(&nd)) != 0)
 		return(error);
 	NDFREE(&nd, NDF_ONLY_PNBUF);
@@ -4155,29 +4245,29 @@
 }
 
 int
-extattr_delete_fd(td, uap)
+extattr_delete_link(td, uap)
 	struct thread *td;
-	struct extattr_delete_fd_args /* {
-		syscallarg(int) fd;
+	struct extattr_delete_link_args /* {
+		syscallarg(const char *) path;
 		syscallarg(int) attrnamespace;
 		syscallarg(const char *) attrname;
 	} */ *uap;
 {
-	struct file *fp;
-	struct vnode *vp;
+	struct nameidata nd;
 	char attrname[EXTATTR_MAXNAMELEN];
 	int error;
 
 	error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL);
 	if (error)
-		return (error);
+		return(error);
 
-	if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
-		return (error);
-	vp = (struct vnode *)fp->f_data;
+	NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, td);
+	if ((error = namei(&nd)) != 0)
+		return(error);
+	NDFREE(&nd, NDF_ONLY_PNBUF);
 
-	error = extattr_delete_vp(vp, uap->attrnamespace, attrname, td);
+	error = extattr_delete_vp(nd.ni_vp, uap->attrnamespace, attrname, td);
 
-	fdrop(fp, td);
-	return (error);
+	vrele(nd.ni_vp);
+	return(error);
 }

==== //depot/projects/trustedbsd/mac/sys/sys/extattr.h#6 (text+ko) ====

@@ -60,14 +60,20 @@
 int	extattr_delete_fd(int _fd, int _attrnamespace, const char *_attrname);
 int	extattr_delete_file(const char *_path, int _attrnamespace,
 	    const char *_attrname);
+int	extattr_delete_link(const char *_path, int _attrnamespace,
+	    const char *_attrname);
 ssize_t	extattr_get_fd(int _fd, int _attrnamespace, const char *_attrname,
 	    void *_data, size_t _nbytes);
 ssize_t	extattr_get_file(const char *_path, int _attrnamespace,
 	    const char *_attrname, void *_data, size_t _nbytes);
+ssize_t	extattr_get_link(const char *_path, int _attrnamespace,
+	    const char *_attrname, void *_data, size_t _nbytes);
 int	extattr_set_fd(int _fd, int _attrnamespace, const char *_attrname,
 	    const void *_data, size_t _nbytes);
 int	extattr_set_file(const char *_path, int _attrnamespace,
 	    const char *_attrname, const void *_data, size_t _nbytes);
+int	extattr_set_link(const char *_path, int _attrnamespace,
+	    const char *_attrname, const void *_data, size_t _nbytes);
 __END_DECLS
 
 #endif /* !_KERNEL */

==== //depot/projects/trustedbsd/mac/sys/sys/syscall.h#32 (text+ko) ====

@@ -312,4 +312,7 @@
 #define	SYS_macctl	396
 #define	SYS___mac_get_link	397
 #define	SYS___mac_set_link	398
-#define	SYS_MAXSYSCALL	399
+#define	SYS_extattr_set_link	399
+#define	SYS_extattr_get_link	400
+#define	SYS_extattr_delete_link	401
+#define	SYS_MAXSYSCALL	402

==== //depot/projects/trustedbsd/mac/sys/sys/syscall.mk#32 (text+ko) ====

@@ -260,4 +260,7 @@
 	__mac_get_pid.o \
 	macctl.o \
 	__mac_get_link.o \
-	__mac_set_link.o
+	__mac_set_link.o \
+	extattr_set_link.o \
+	extattr_get_link.o \
+	extattr_delete_link.o

==== //depot/projects/trustedbsd/mac/sys/sys/sysproto.h#33 (text+ko) ====

@@ -1145,6 +1145,25 @@
 	char path_p_l_[PADL_(const char *)]; const char * path_p; char path_p_r_[PADR_(const char *)];
 	char mac_p_l_[PADL_(struct mac *)]; struct mac * mac_p; char mac_p_r_[PADR_(struct mac *)];
 };
+struct extattr_set_link_args {
+	char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
+	char attrnamespace_l_[PADL_(int)]; int attrnamespace; char attrnamespace_r_[PADR_(int)];
+	char attrname_l_[PADL_(const char *)]; const char * attrname; char attrname_r_[PADR_(const char *)];
+	char data_l_[PADL_(void *)]; void * data; char data_r_[PADR_(void *)];
+	char nbytes_l_[PADL_(size_t)]; size_t nbytes; char nbytes_r_[PADR_(size_t)];
+};
+struct extattr_get_link_args {
+	char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
+	char attrnamespace_l_[PADL_(int)]; int attrnamespace; char attrnamespace_r_[PADR_(int)];
+	char attrname_l_[PADL_(const char *)]; const char * attrname; char attrname_r_[PADR_(const char *)];
+	char data_l_[PADL_(void *)]; void * data; char data_r_[PADR_(void *)];
+	char nbytes_l_[PADL_(size_t)]; size_t nbytes; char nbytes_r_[PADR_(size_t)];
+};
+struct extattr_delete_link_args {
+	char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
+	char attrnamespace_l_[PADL_(int)]; int attrnamespace; char attrnamespace_r_[PADR_(int)];
+	char attrname_l_[PADL_(const char *)]; const char * attrname; char attrname_r_[PADR_(const char *)];
+};
 int	nosys(struct thread *, struct nosys_args *);
 void	sys_exit(struct thread *, struct sys_exit_args *);
 int	fork(struct thread *, struct fork_args *);
@@ -1402,6 +1421,9 @@
 int	macctl(struct thread *, struct macctl_args *);
 int	__mac_get_link(struct thread *, struct __mac_get_link_args *);
 int	__mac_set_link(struct thread *, struct __mac_set_link_args *);
+int	extattr_set_link(struct thread *, struct extattr_set_link_args *);
+int	extattr_get_link(struct thread *, struct extattr_get_link_args *);
+int	extattr_delete_link(struct thread *, struct extattr_delete_link_args *);
 
 #ifdef COMPAT_43
 
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message



More information about the trustedbsd-cvs mailing list