154803Srwatson/*-
285845Srwatson * Copyright (c) 1999-2001 Robert N. M. Watson
354803Srwatson * All rights reserved.
454803Srwatson *
585845Srwatson * This software was developed by Robert Watson for the TrustedBSD Project.
685845Srwatson *
754803Srwatson * Redistribution and use in source and binary forms, with or without
854803Srwatson * modification, are permitted provided that the following conditions
954803Srwatson * are met:
1054803Srwatson * 1. Redistributions of source code must retain the above copyright
1154803Srwatson *    notice, this list of conditions and the following disclaimer.
1254803Srwatson * 2. Redistributions in binary form must reproduce the above copyright
1354803Srwatson *    notice, this list of conditions and the following disclaimer in the
1454803Srwatson *    documentation and/or other materials provided with the distribution.
1554803Srwatson *
1654803Srwatson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1754803Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1854803Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1954803Srwatson * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2054803Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2154803Srwatson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2254803Srwatson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2354803Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2454803Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2554803Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2654803Srwatson * SUCH DAMAGE.
2754803Srwatson *
2854803Srwatson * $FreeBSD$
2954803Srwatson */
3054803Srwatson/*
3185845Srwatson * Developed by the TrustedBSD Project.
3296755Strhodes * Support for extended filesystem attributes.
3354803Srwatson */
3454803Srwatson
3554803Srwatson#ifndef _SYS_EXTATTR_H_
3656272Srwatson#define	_SYS_EXTATTR_H_
3774273Srwatson
38160596Srwatson/*
39160596Srwatson * Defined name spaces for extended attributes.  Numeric constants are passed
40160596Srwatson * via system calls, but a user-friendly string is also defined.
41160596Srwatson */
42167010Smckusick#define	EXTATTR_NAMESPACE_EMPTY		0x00000000
43167010Smckusick#define	EXTATTR_NAMESPACE_EMPTY_STRING	"empty"
4474273Srwatson#define	EXTATTR_NAMESPACE_USER		0x00000001
4574273Srwatson#define	EXTATTR_NAMESPACE_USER_STRING	"user"
4674273Srwatson#define	EXTATTR_NAMESPACE_SYSTEM	0x00000002
4774273Srwatson#define	EXTATTR_NAMESPACE_SYSTEM_STRING	"system"
4874273Srwatson
49167010Smckusick/*
50167650Srwatson * The following macro is designed to initialize an array that maps
51167650Srwatson * extended-attribute namespace values to their names, e.g.:
52167650Srwatson *
53167650Srwatson * char *extattr_namespace_names[] = EXTATTR_NAMESPACE_NAMES;
54167010Smckusick */
55167010Smckusick#define EXTATTR_NAMESPACE_NAMES { \
56167010Smckusick	EXTATTR_NAMESPACE_EMPTY_STRING, \
57167010Smckusick	EXTATTR_NAMESPACE_USER_STRING, \
58167010Smckusick	EXTATTR_NAMESPACE_SYSTEM_STRING }
59167010Smckusick
6056272Srwatson#ifdef _KERNEL
61184413Strasz#include <sys/types.h>
6254803Srwatson
6356272Srwatson#define	EXTATTR_MAXNAMELEN	NAME_MAX
64102987Sphkstruct thread;
65102987Sphkstruct ucred;
66102987Sphkstruct vnode;
67102987Sphkint	extattr_check_cred(struct vnode *vp, int attrnamespace,
68184413Strasz	    struct ucred *cred, struct thread *td, accmode_t accmode);
6954803Srwatson
7056272Srwatson#else
7156272Srwatson#include <sys/cdefs.h>
7254803Srwatson
7356272Srwatsonstruct iovec;
7454803Srwatson
7556272Srwatson__BEGIN_DECLS
7675038Srwatsonint	extattrctl(const char *_path, int _cmd, const char *_filename,
7775038Srwatson	    int _attrnamespace, const char *_attrname);
7875038Srwatsonint	extattr_delete_fd(int _fd, int _attrnamespace, const char *_attrname);
7975038Srwatsonint	extattr_delete_file(const char *_path, int _attrnamespace,
8075038Srwatson	    const char *_attrname);
81104733Srwatsonint	extattr_delete_link(const char *_path, int _attrnamespace,
82104733Srwatson	    const char *_attrname);
8390448Srwatsonssize_t	extattr_get_fd(int _fd, int _attrnamespace, const char *_attrname,
8490448Srwatson	    void *_data, size_t _nbytes);
8590448Srwatsonssize_t	extattr_get_file(const char *_path, int _attrnamespace,
8690448Srwatson	    const char *_attrname, void *_data, size_t _nbytes);
87104733Srwatsonssize_t	extattr_get_link(const char *_path, int _attrnamespace,
88104733Srwatson	    const char *_attrname, void *_data, size_t _nbytes);
89115805Srwatsonssize_t	extattr_list_fd(int _fd, int _attrnamespace, void *_data,
90115805Srwatson	    size_t _nbytes);
91115805Srwatsonssize_t	extattr_list_file(const char *_path, int _attrnamespace, void *_data,
92115805Srwatson	    size_t _nbytes);
93115805Srwatsonssize_t	extattr_list_link(const char *_path, int _attrnamespace, void *_data,
94115805Srwatson	    size_t _nbytes);
95248995Smdfssize_t	extattr_set_fd(int _fd, int _attrnamespace, const char *_attrname,
9690448Srwatson	    const void *_data, size_t _nbytes);
97248995Smdfssize_t	extattr_set_file(const char *_path, int _attrnamespace,
9890448Srwatson	    const char *_attrname, const void *_data, size_t _nbytes);
99248995Smdfssize_t	extattr_set_link(const char *_path, int _attrnamespace,
100104733Srwatson	    const char *_attrname, const void *_data, size_t _nbytes);
10156272Srwatson__END_DECLS
10256272Srwatson
10356272Srwatson#endif /* !_KERNEL */
10456272Srwatson#endif /* !_SYS_EXTATTR_H_ */
105