Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/vfs_extattr.c
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Syscall to push extended attribute configuration information into the VFS. | * Syscall to push extended attribute configuration information into the VFS. | ||||
* Accepts a path, which it converts to a mountpoint, as well as a command | * Accepts a path, which it converts to a mountpoint, as well as a command | ||||
* (int cmd), and attribute name and misc data. | * (int cmd), and attribute name and misc data. | ||||
* | * | ||||
* Currently this is used only by UFS1 extended attributes. | * Currently this is used only by UFS1 extended attributes. | ||||
*/ | */ | ||||
int | #ifndef _SYS_SYSPROTO_H_ | ||||
sys_extattrctl(td, uap) | struct extattrctl_args { | ||||
struct thread *td; | |||||
struct extattrctl_args /* { | |||||
const char *path; | const char *path; | ||||
int cmd; | int cmd; | ||||
const char *filename; | const char *filename; | ||||
int attrnamespace; | int attrnamespace; | ||||
const char *attrname; | const char *attrname; | ||||
} */ *uap; | }; | ||||
#endif | |||||
int | |||||
sys_extattrctl(struct thread *td, struct extattrctl_args *uap) | |||||
{ | { | ||||
struct vnode *filename_vp; | struct vnode *filename_vp; | ||||
struct nameidata nd; | struct nameidata nd; | ||||
struct mount *mp, *mp_writable; | struct mount *mp, *mp_writable; | ||||
char attrname[EXTATTR_MAXNAMELEN]; | char attrname[EXTATTR_MAXNAMELEN]; | ||||
int error; | int error; | ||||
AUDIT_ARG_CMD(uap->cmd); | AUDIT_ARG_CMD(uap->cmd); | ||||
▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | |||||
#ifdef MAC | #ifdef MAC | ||||
done: | done: | ||||
#endif | #endif | ||||
VOP_UNLOCK(vp, 0); | VOP_UNLOCK(vp, 0); | ||||
vn_finished_write(mp); | vn_finished_write(mp); | ||||
return (error); | return (error); | ||||
} | } | ||||
int | #ifndef _SYS_SYSPROTO_H_ | ||||
sys_extattr_set_fd(td, uap) | struct extattr_set_fd_args { | ||||
struct thread *td; | |||||
struct extattr_set_fd_args /* { | |||||
int fd; | int fd; | ||||
int attrnamespace; | int attrnamespace; | ||||
const char *attrname; | const char *attrname; | ||||
void *data; | void *data; | ||||
size_t nbytes; | size_t nbytes; | ||||
} */ *uap; | }; | ||||
#endif | |||||
int | |||||
sys_extattr_set_fd(struct thread *td, struct extattr_set_fd_args *uap) | |||||
{ | { | ||||
struct file *fp; | struct file *fp; | ||||
char attrname[EXTATTR_MAXNAMELEN]; | char attrname[EXTATTR_MAXNAMELEN]; | ||||
cap_rights_t rights; | cap_rights_t rights; | ||||
int error; | int error; | ||||
AUDIT_ARG_FD(uap->fd); | AUDIT_ARG_FD(uap->fd); | ||||
AUDIT_ARG_VALUE(uap->attrnamespace); | AUDIT_ARG_VALUE(uap->attrnamespace); | ||||
Show All 9 Lines | sys_extattr_set_fd(struct thread *td, struct extattr_set_fd_args *uap) | ||||
error = extattr_set_vp(fp->f_vnode, uap->attrnamespace, | error = extattr_set_vp(fp->f_vnode, uap->attrnamespace, | ||||
attrname, uap->data, uap->nbytes, td); | attrname, uap->data, uap->nbytes, td); | ||||
fdrop(fp, td); | fdrop(fp, td); | ||||
return (error); | return (error); | ||||
} | } | ||||
int | #ifndef _SYS_SYSPROTO_H_ | ||||
sys_extattr_set_file(td, uap) | struct extattr_set_file_args { | ||||
struct thread *td; | |||||
struct extattr_set_file_args /* { | |||||
const char *path; | const char *path; | ||||
int attrnamespace; | int attrnamespace; | ||||
const char *attrname; | const char *attrname; | ||||
void *data; | void *data; | ||||
size_t nbytes; | size_t nbytes; | ||||
} */ *uap; | }; | ||||
#endif | |||||
int | |||||
sys_extattr_set_file(struct thread *td, struct extattr_set_file_args *uap) | |||||
{ | { | ||||
struct nameidata nd; | struct nameidata nd; | ||||
char attrname[EXTATTR_MAXNAMELEN]; | char attrname[EXTATTR_MAXNAMELEN]; | ||||
int error; | int error; | ||||
AUDIT_ARG_VALUE(uap->attrnamespace); | AUDIT_ARG_VALUE(uap->attrnamespace); | ||||
error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL); | error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL); | ||||
if (error) | if (error) | ||||
Show All 9 Lines | sys_extattr_set_file(struct thread *td, struct extattr_set_file_args *uap) | ||||
error = extattr_set_vp(nd.ni_vp, uap->attrnamespace, attrname, | error = extattr_set_vp(nd.ni_vp, uap->attrnamespace, attrname, | ||||
uap->data, uap->nbytes, td); | uap->data, uap->nbytes, td); | ||||
vrele(nd.ni_vp); | vrele(nd.ni_vp); | ||||
return (error); | return (error); | ||||
} | } | ||||
int | #ifndef _SYS_SYSPROTO_H_ | ||||
sys_extattr_set_link(td, uap) | struct extattr_set_link_args { | ||||
struct thread *td; | |||||
struct extattr_set_link_args /* { | |||||
const char *path; | const char *path; | ||||
int attrnamespace; | int attrnamespace; | ||||
const char *attrname; | const char *attrname; | ||||
void *data; | void *data; | ||||
size_t nbytes; | size_t nbytes; | ||||
} */ *uap; | }; | ||||
#endif | |||||
int | |||||
sys_extattr_set_link(struct thread *td, struct extattr_set_link_args *uap) | |||||
{ | { | ||||
struct nameidata nd; | struct nameidata nd; | ||||
char attrname[EXTATTR_MAXNAMELEN]; | char attrname[EXTATTR_MAXNAMELEN]; | ||||
int error; | int error; | ||||
AUDIT_ARG_VALUE(uap->attrnamespace); | AUDIT_ARG_VALUE(uap->attrnamespace); | ||||
error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL); | error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL); | ||||
if (error) | if (error) | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | if (auiop != NULL) { | ||||
td->td_retval[0] = size; | td->td_retval[0] = size; | ||||
#ifdef MAC | #ifdef MAC | ||||
done: | done: | ||||
#endif | #endif | ||||
VOP_UNLOCK(vp, 0); | VOP_UNLOCK(vp, 0); | ||||
return (error); | return (error); | ||||
} | } | ||||
int | #ifndef _SYS_SYSPROTO_H_ | ||||
sys_extattr_get_fd(td, uap) | struct extattr_get_fd_args { | ||||
struct thread *td; | |||||
struct extattr_get_fd_args /* { | |||||
int fd; | int fd; | ||||
int attrnamespace; | int attrnamespace; | ||||
const char *attrname; | const char *attrname; | ||||
void *data; | void *data; | ||||
size_t nbytes; | size_t nbytes; | ||||
} */ *uap; | }; | ||||
#endif | |||||
int | |||||
sys_extattr_get_fd(struct thread *td, struct extattr_get_fd_args *uap) | |||||
{ | { | ||||
struct file *fp; | struct file *fp; | ||||
char attrname[EXTATTR_MAXNAMELEN]; | char attrname[EXTATTR_MAXNAMELEN]; | ||||
cap_rights_t rights; | cap_rights_t rights; | ||||
int error; | int error; | ||||
AUDIT_ARG_FD(uap->fd); | AUDIT_ARG_FD(uap->fd); | ||||
AUDIT_ARG_VALUE(uap->attrnamespace); | AUDIT_ARG_VALUE(uap->attrnamespace); | ||||
Show All 9 Lines | sys_extattr_get_fd(struct thread *td, struct extattr_get_fd_args *uap) | ||||
error = extattr_get_vp(fp->f_vnode, uap->attrnamespace, | error = extattr_get_vp(fp->f_vnode, uap->attrnamespace, | ||||
attrname, uap->data, uap->nbytes, td); | attrname, uap->data, uap->nbytes, td); | ||||
fdrop(fp, td); | fdrop(fp, td); | ||||
return (error); | return (error); | ||||
} | } | ||||
int | #ifndef _SYS_SYSPROTO_H_ | ||||
sys_extattr_get_file(td, uap) | struct extattr_get_file_args { | ||||
struct thread *td; | |||||
struct extattr_get_file_args /* { | |||||
const char *path; | const char *path; | ||||
int attrnamespace; | int attrnamespace; | ||||
const char *attrname; | const char *attrname; | ||||
void *data; | void *data; | ||||
size_t nbytes; | size_t nbytes; | ||||
} */ *uap; | }; | ||||
#endif | |||||
int | |||||
sys_extattr_get_file(struct thread *td, struct extattr_get_file_args *uap) | |||||
{ | { | ||||
struct nameidata nd; | struct nameidata nd; | ||||
char attrname[EXTATTR_MAXNAMELEN]; | char attrname[EXTATTR_MAXNAMELEN]; | ||||
int error; | int error; | ||||
AUDIT_ARG_VALUE(uap->attrnamespace); | AUDIT_ARG_VALUE(uap->attrnamespace); | ||||
error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL); | error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
AUDIT_ARG_TEXT(attrname); | AUDIT_ARG_TEXT(attrname); | ||||
NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->path, td); | NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->path, td); | ||||
error = namei(&nd); | error = namei(&nd); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
NDFREE(&nd, NDF_ONLY_PNBUF); | NDFREE(&nd, NDF_ONLY_PNBUF); | ||||
error = extattr_get_vp(nd.ni_vp, uap->attrnamespace, attrname, | error = extattr_get_vp(nd.ni_vp, uap->attrnamespace, attrname, | ||||
uap->data, uap->nbytes, td); | uap->data, uap->nbytes, td); | ||||
vrele(nd.ni_vp); | vrele(nd.ni_vp); | ||||
return (error); | return (error); | ||||
} | } | ||||
int | #ifndef _SYS_SYSPROTO_H_ | ||||
sys_extattr_get_link(td, uap) | struct extattr_get_link_args { | ||||
struct thread *td; | |||||
struct extattr_get_link_args /* { | |||||
const char *path; | const char *path; | ||||
int attrnamespace; | int attrnamespace; | ||||
const char *attrname; | const char *attrname; | ||||
void *data; | void *data; | ||||
size_t nbytes; | size_t nbytes; | ||||
} */ *uap; | }; | ||||
#endif | |||||
int | |||||
sys_extattr_get_link(struct thread *td, struct extattr_get_link_args *uap) | |||||
{ | { | ||||
struct nameidata nd; | struct nameidata nd; | ||||
char attrname[EXTATTR_MAXNAMELEN]; | char attrname[EXTATTR_MAXNAMELEN]; | ||||
int error; | int error; | ||||
AUDIT_ARG_VALUE(uap->attrnamespace); | AUDIT_ARG_VALUE(uap->attrnamespace); | ||||
error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL); | error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL); | ||||
if (error) | if (error) | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
#ifdef MAC | #ifdef MAC | ||||
done: | done: | ||||
#endif | #endif | ||||
VOP_UNLOCK(vp, 0); | VOP_UNLOCK(vp, 0); | ||||
vn_finished_write(mp); | vn_finished_write(mp); | ||||
return (error); | return (error); | ||||
} | } | ||||
int | #ifndef _SYS_SYSPROTO_H_ | ||||
sys_extattr_delete_fd(td, uap) | struct extattr_delete_fd_args { | ||||
struct thread *td; | |||||
struct extattr_delete_fd_args /* { | |||||
int fd; | int fd; | ||||
int attrnamespace; | int attrnamespace; | ||||
const char *attrname; | const char *attrname; | ||||
} */ *uap; | }; | ||||
#endif | |||||
int | |||||
sys_extattr_delete_fd(struct thread *td, struct extattr_delete_fd_args *uap) | |||||
{ | { | ||||
struct file *fp; | struct file *fp; | ||||
char attrname[EXTATTR_MAXNAMELEN]; | char attrname[EXTATTR_MAXNAMELEN]; | ||||
cap_rights_t rights; | cap_rights_t rights; | ||||
int error; | int error; | ||||
AUDIT_ARG_FD(uap->fd); | AUDIT_ARG_FD(uap->fd); | ||||
AUDIT_ARG_VALUE(uap->attrnamespace); | AUDIT_ARG_VALUE(uap->attrnamespace); | ||||
error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL); | error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
AUDIT_ARG_TEXT(attrname); | AUDIT_ARG_TEXT(attrname); | ||||
error = getvnode(td, uap->fd, | error = getvnode(td, uap->fd, | ||||
cap_rights_init(&rights, CAP_EXTATTR_DELETE), &fp); | cap_rights_init(&rights, CAP_EXTATTR_DELETE), &fp); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
error = extattr_delete_vp(fp->f_vnode, uap->attrnamespace, | error = extattr_delete_vp(fp->f_vnode, uap->attrnamespace, | ||||
attrname, td); | attrname, td); | ||||
fdrop(fp, td); | fdrop(fp, td); | ||||
return (error); | return (error); | ||||
} | } | ||||
int | #ifndef _SYS_SYSPROTO_H_ | ||||
sys_extattr_delete_file(td, uap) | struct extattr_delete_file_args { | ||||
struct thread *td; | |||||
struct extattr_delete_file_args /* { | |||||
const char *path; | const char *path; | ||||
int attrnamespace; | int attrnamespace; | ||||
const char *attrname; | const char *attrname; | ||||
} */ *uap; | }; | ||||
#endif | |||||
int | |||||
sys_extattr_delete_file(struct thread *td, struct extattr_delete_file_args *uap) | |||||
{ | { | ||||
struct nameidata nd; | struct nameidata nd; | ||||
char attrname[EXTATTR_MAXNAMELEN]; | char attrname[EXTATTR_MAXNAMELEN]; | ||||
int error; | int error; | ||||
AUDIT_ARG_VALUE(uap->attrnamespace); | AUDIT_ARG_VALUE(uap->attrnamespace); | ||||
error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL); | error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL); | ||||
if (error) | if (error) | ||||
return(error); | return(error); | ||||
AUDIT_ARG_TEXT(attrname); | AUDIT_ARG_TEXT(attrname); | ||||
NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->path, td); | NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->path, td); | ||||
error = namei(&nd); | error = namei(&nd); | ||||
if (error) | if (error) | ||||
return(error); | return(error); | ||||
NDFREE(&nd, NDF_ONLY_PNBUF); | NDFREE(&nd, NDF_ONLY_PNBUF); | ||||
error = extattr_delete_vp(nd.ni_vp, uap->attrnamespace, attrname, td); | error = extattr_delete_vp(nd.ni_vp, uap->attrnamespace, attrname, td); | ||||
vrele(nd.ni_vp); | vrele(nd.ni_vp); | ||||
return(error); | return(error); | ||||
} | } | ||||
int | #ifndef _SYS_SYSPROTO_H_ | ||||
sys_extattr_delete_link(td, uap) | struct extattr_delete_link_args { | ||||
struct thread *td; | |||||
struct extattr_delete_link_args /* { | |||||
const char *path; | const char *path; | ||||
int attrnamespace; | int attrnamespace; | ||||
const char *attrname; | const char *attrname; | ||||
} */ *uap; | }; | ||||
#endif | |||||
int | |||||
sys_extattr_delete_link(struct thread *td, struct extattr_delete_link_args *uap) | |||||
{ | { | ||||
struct nameidata nd; | struct nameidata nd; | ||||
char attrname[EXTATTR_MAXNAMELEN]; | char attrname[EXTATTR_MAXNAMELEN]; | ||||
int error; | int error; | ||||
AUDIT_ARG_VALUE(uap->attrnamespace); | AUDIT_ARG_VALUE(uap->attrnamespace); | ||||
error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL); | error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL); | ||||
if (error) | if (error) | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | |||||
#ifdef MAC | #ifdef MAC | ||||
done: | done: | ||||
#endif | #endif | ||||
VOP_UNLOCK(vp, 0); | VOP_UNLOCK(vp, 0); | ||||
return (error); | return (error); | ||||
} | } | ||||
int | #ifndef _SYS_SYSPROTO_H_ | ||||
sys_extattr_list_fd(td, uap) | struct extattr_list_fd_args { | ||||
struct thread *td; | |||||
struct extattr_list_fd_args /* { | |||||
int fd; | int fd; | ||||
int attrnamespace; | int attrnamespace; | ||||
void *data; | void *data; | ||||
size_t nbytes; | size_t nbytes; | ||||
} */ *uap; | }; | ||||
#endif | |||||
int | |||||
sys_extattr_list_fd(struct thread *td, struct extattr_list_fd_args *uap) | |||||
{ | { | ||||
struct file *fp; | struct file *fp; | ||||
cap_rights_t rights; | cap_rights_t rights; | ||||
int error; | int error; | ||||
AUDIT_ARG_FD(uap->fd); | AUDIT_ARG_FD(uap->fd); | ||||
AUDIT_ARG_VALUE(uap->attrnamespace); | AUDIT_ARG_VALUE(uap->attrnamespace); | ||||
error = getvnode(td, uap->fd, | error = getvnode(td, uap->fd, | ||||
cap_rights_init(&rights, CAP_EXTATTR_LIST), &fp); | cap_rights_init(&rights, CAP_EXTATTR_LIST), &fp); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
error = extattr_list_vp(fp->f_vnode, uap->attrnamespace, uap->data, | error = extattr_list_vp(fp->f_vnode, uap->attrnamespace, uap->data, | ||||
uap->nbytes, td); | uap->nbytes, td); | ||||
fdrop(fp, td); | fdrop(fp, td); | ||||
return (error); | return (error); | ||||
} | } | ||||
int | #ifndef _SYS_SYSPROTO_H_ | ||||
sys_extattr_list_file(td, uap) | struct extattr_list_file_args { | ||||
struct thread*td; | |||||
struct extattr_list_file_args /* { | |||||
const char *path; | const char *path; | ||||
int attrnamespace; | int attrnamespace; | ||||
void *data; | void *data; | ||||
size_t nbytes; | size_t nbytes; | ||||
} */ *uap; | } | ||||
#endif | |||||
int | |||||
sys_extattr_list_file(struct thread *td, struct extattr_list_file_args *uap) | |||||
{ | { | ||||
struct nameidata nd; | struct nameidata nd; | ||||
int error; | int error; | ||||
AUDIT_ARG_VALUE(uap->attrnamespace); | AUDIT_ARG_VALUE(uap->attrnamespace); | ||||
NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->path, td); | NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->path, td); | ||||
error = namei(&nd); | error = namei(&nd); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
NDFREE(&nd, NDF_ONLY_PNBUF); | NDFREE(&nd, NDF_ONLY_PNBUF); | ||||
error = extattr_list_vp(nd.ni_vp, uap->attrnamespace, uap->data, | error = extattr_list_vp(nd.ni_vp, uap->attrnamespace, uap->data, | ||||
uap->nbytes, td); | uap->nbytes, td); | ||||
vrele(nd.ni_vp); | vrele(nd.ni_vp); | ||||
return (error); | return (error); | ||||
} | } | ||||
int | #ifndef _SYS_SYSPROTO_H_ | ||||
sys_extattr_list_link(td, uap) | struct extattr_list_link_args { | ||||
struct thread*td; | |||||
struct extattr_list_link_args /* { | |||||
const char *path; | const char *path; | ||||
int attrnamespace; | int attrnamespace; | ||||
void *data; | void *data; | ||||
size_t nbytes; | size_t nbytes; | ||||
} */ *uap; | }; | ||||
#endif | |||||
int | |||||
sys_extattr_list_link(struct thread *td, struct extattr_list_link_args *uap) | |||||
{ | { | ||||
struct nameidata nd; | struct nameidata nd; | ||||
int error; | int error; | ||||
AUDIT_ARG_VALUE(uap->attrnamespace); | AUDIT_ARG_VALUE(uap->attrnamespace); | ||||
NDINIT(&nd, LOOKUP, NOFOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->path, | NDINIT(&nd, LOOKUP, NOFOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->path, | ||||
td); | td); | ||||
error = namei(&nd); | error = namei(&nd); | ||||
Show All 10 Lines |