[BACK]Return to attrctl.html CVS log [TXT][DIR] Up to [Development] / xfs-website.orig / manpages

File: [Development] / xfs-website.orig / manpages / attrctl.html (download) (as text)

Revision 1.1, Thu Jan 25 19:55:30 2001 UTC (16 years, 8 months ago) by xfs
Branch: MAIN
CVS Tags: HEAD

Man pages update.

<html>
<head>
<meta name="Content-Style" content="text/css">
</head>
<body>
<a href="#NAME">NAME</a><br>
<a href="#C SYNOPSIS">C SYNOPSIS</a><br>
<a href="##include &lt;attr/attributes.h&gt;">#include &lt;attr/attributes.h&gt;</a><br>
<a href="#int attrctl (attr_obj_t obj, int type, attr_op_t *ops,">int attrctl (attr_obj_t obj, int type, attr_op_t *ops,</a><br>
<a href="#OVERVIEW">OVERVIEW</a><br>
<a href="#DESCRIPTION">DESCRIPTION</a><br>
<a href="#DIAGNOSTICS">DIAGNOSTICS</a><br>
<a href="#SEE ALSO">SEE ALSO</a><br>
<!-- Creator     : groff version 1.16.1  -->
<!-- CreationDate: Wed Jan 24 01:42:49 2001
 -->
<!-- Total number of pages: 3 -->
<!-- Page: 1 -->
<!-- left  margin: 220 -->
<!-- right margin: 750 -->
<a name="NAME"></a><h2>NAME</h2><p style="margin-left: 18%"><font size=3>attrctl - manipulate (extended) attributes of system objects</font></p>
<a name="C SYNOPSIS"></a><h2>C SYNOPSIS</h2><a name="#include &lt;attr/attributes.h&gt;"></a><h2>#include &lt;attr/attributes.h&gt;</h2><a name="int attrctl (attr_obj_t obj, int type, attr_op_t *ops,"></a><h2>int attrctl (attr_obj_t obj, int type, attr_op_t *ops,</h2>
<table width="99%" rules="none" frame="none" cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td valign="top" align="left" width="24%">
</td>
<td valign="top" align="left" width="75%">
<p><font size=3><B>int count);</B></font></p>
</td>
</tr>
</table>
<a name="OVERVIEW"></a><h2>OVERVIEW</h2><p style="margin-left: 18%"><font size=3>The</font> <font size=3><I>attrctl</I></font> <font size=3>system call allows a user to attach name/value pairs to system objects &shy; typically filesystem objects (inodes).</font></p>
<p style="margin-left: 18%"><font size=3>This is a first draft proposal which may well *not* be the final interface &shy; it has been implemented to address some immediate issues with the current XFS implementation and is the first attempt at an interface which could allow both XFS and EXT2 extended attributes implementations to coexist.</font></p>
<p style="margin-left: 18%"><font size=3>Extended attributes can be used to store meta&shy;information about a file, for example &quot;character&shy;set=kanji&quot; could tell a document browser to use the Kanji character set when displaying that document and &quot;thumbnail=...&quot; could provide a reduced resolution overview of a high resolution graphic image.</font></p>
<p style="margin-left: 18%"><font size=3>The</font> <font size=3><B>names</B></font> <font size=3>can be up to MAXNAMELEN bytes in length, terminated by the first 0 byte. The intent is that they be printable ASCII (or other character set) names for the attribute.</font></p>
<p style="margin-left: 18%"><font size=3>The</font> <font size=3><B>values</B></font> <font size=3>can be up to ATTR_MAX_VALUELEN (currently 64KB) of arbitrary binary data.</font></p>
<p style="margin-left: 18%"><font size=3>Attributes can be attached to all types of inodes: regular files, directories, symbolic links, device nodes, etc.</font></p>
<p style="margin-left: 18%"><font size=3>There are 2 disjoint attribute name spaces associated with every filesystem object. They are the</font> <font size=3><B>root</B></font> <font size=3>and</font> <font size=3><B>user</B></font> <font size=3>address spaces. The</font> <font size=3><B>root</B></font> <font size=3>address space is accessible only to the super&shy;user, and then only by specifying a flag to the operation request. Non&shy;root users will not see or be able to modify attributes in the</font> <font size=3><B>root</B></font> <font size=3>address space. The</font> <font size=3><B>user</B></font> <font size=3>address space is protected by the normal file permissions mechanism, so the owner of the file can decide who is able to see and/or modify the value of attributes on any particular file. The attribute get/list operations require read permission, and attribute set/remove require write permission.</font></p>
<p style="margin-left: 18%"><font size=3>Attributes are currently supported only in the XFS and EXT2 filesystem types. However, this system call has been designed to be generic and extensible, such that other filesystems should be able to make use of it.</font></p>
<a name="DESCRIPTION"></a><h2>DESCRIPTION</h2><p style="margin-left: 18%"><font size=3>The</font> <font size=3><I>attrctl</I></font> <font size=3>system call provides a way to access arbitrary extended attributes.</font></p>
<p style="margin-left: 18%"><font size=3><I>Obj</I></font> <font size=3>indicates the system object whose extended attributes are to be manipulated. The contents of the</font> <font size=3><EM>attr_obj_t</EM></font> <font size=3>union are as follows:</font></p>
<p style="margin-left: 18%"><font size=3>typedef union {</font>
<table width="99%" rules="none" frame="none" cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td valign="top" align="left" width="21%">
</p>
</td>
<td valign="top" align="left" width="78%">
<p><font size=3><EM>char *path;</EM></font></p>
</td>
</tr>
</table>

<table width="99%" rules="none" frame="none" cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td valign="top" align="left" width="21%">
</p>
</td>
<td valign="top" align="left" width="78%">
<p><font size=3><EM>int fd;<br>
pid_t pid;</EM></font></p>
</td>
</tr>
</table>
<br>
<font size=3>} attr_obj_t;</font></p>
<p style="margin-left: 18%"><font size=3><I>type</I></font> <font size=3>identifies the type of</font> <font size=3><I>obj</I></font> <font size=3>&shy; currently only file descriptors and path names are implemented (ATTR_TYPE_NAME and ATTR_TYPE_FD), but processes have also been proposed (ATTR_TYPE_PID).</font></p>
<p style="margin-left: 18%"><font size=3><I>Ops</I></font> <font size=3>refers to an array of one or more input/output structures containing control information related to attribute operations and those operations' results.</font></p>
<p style="margin-left: 18%"><font size=3>The</font> <font size=3><I>count</I></font> <font size=3>argument indicates the number of structures in the</font> <font size=3><I>ops</I></font> <font size=3>array.</font></p>
<p style="margin-left: 18%"><font size=3>The contents of an</font> <font size=3><EM>attr_op_t</EM></font> <font size=3>structure are as follows:</font></p>
<p style="margin-left: 18%"><font size=3>typedef struct {</font>
<table width="99%" rules="none" frame="none" cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td valign="top" align="left" width="21%">
</p>
</td>
<td valign="top" align="left" width="78%">
<p><font size=3><EM>int opcode; /* which operation to perform (see below) */</EM></font></p>
</td>
</tr>
</table>

<table width="99%" rules="none" frame="none" cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td valign="top" align="left" width="21%">
</p>
</td>
<td valign="top" align="left" width="78%">
<p><font size=3><EM>int error; /* [out arg] result of this sub&shy;op (an errno) */</EM></font></p>
</td>
</tr>
</table>

<table width="99%" rules="none" frame="none" cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td valign="top" align="left" width="21%">
</p>
</td>
<td valign="top" align="left" width="78%">
<p><font size=3><EM>char *name; /* attribute name to work with */</EM></font></p>
</td>
</tr>
</table>

<table width="99%" rules="none" frame="none" cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td valign="top" align="left" width="21%">
</p>
</td>
<td valign="top" align="left" width="78%">
<p><font size=3><EM>char *value; /* [in/out arg] attribute value (raw bytes) */<br>
int length; /* [in/out arg] length of value */</EM></font></p>
</td>
</tr>
</table>
<br>
</p>

<!-- Page: 2  -->
<!-- left  margin: 220 -->
<!-- right margin: 750 -->

<table width="99%" rules="none" frame="none" cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td valign="top" align="left" width="21%">
</td>
<td valign="top" align="left" width="78%">
<p><font size=3><EM>int flags; /* flags (bit&shy;wise OR of #defines below) */</EM></font></p>
</td>
</tr>
</table>
<br>
<p style="margin-left: 18%"><span style=" text-indent: 2%;"></span><font size=3><EM>void *aux; /* optional command&shy;specific data */<br>
</EM>} attr_op_t;</font></p>
<p style="margin-left: 18%"><font size=3>The</font> <font size=3><I>opcode</I></font> <font size=3>field defines how the remaining fields are to be interpreted and can take on one of the following</font> <font size=3><B>ATTR_OP</B></font> <font size=3>values.</font></p>
<p style="margin-left: 18%"><font size=3><B>ATTR_OP_GET</B></font> <font size=3>returns the</font> <font size=3><I>value</I></font> <font size=3>associated with attribute</font> <font size=3><I>name</I></font><font size=3>. The size of the user buffer is passed in as</font> <font size=3><I>length</I></font><font size=3>, and the size of the attribute value is returned in the same field. Valid flags are ATTR_ROOT and ATTR_DONTFOLLOW.</font></p>
<p style="margin-left: 18%"><font size=3><B>ATTR_OP_SET</B></font> <font size=3>sets (possibly creating a new attribute) the value of the attribute specified by</font> <font size=3><I>name</I></font> <font size=3>to</font> <font size=3><I>value</I></font><font size=3>. The</font> <font size=3><I>length</I></font> <font size=3>parameter specifies the size of the new value, and the valid</font> <font size=3><I>flags</I></font> <font size=3>are ATTR_ROOT, ATTR_DONTFOLLOW, ATTR_CREATE, and ATTR_REPLACE.</font></p>
<p style="margin-left: 18%"><font size=3><B>ATTR_OP_REMOVE</B></font> <font size=3>provides a way to remove previously created attributes. If the attribute</font> <font size=3><I>name</I></font> <font size=3>exists, the attribute name and its associated value will be removed. Valid</font> <font size=3><I>flags</I></font> <font size=3>are ATTR_ROOT and ATTR_DONTFOLLOW.</font></p>
<p style="margin-left: 18%"><font size=3><B>ATTR_OP_LIST</B></font> <font size=3>is used to list the existing attributes associated with an object. The</font> <font size=3><I>name</I></font> <font size=3>field is ignored -</font> <font size=3><I>value</I></font> <font size=3>and</font> <font size=3><I>size</I></font> <font size=3>specify the buffer to be filled with at least a portion of the attributes associated with the given object. An</font> <font size=3><B>attrlist_t</B></font> <font size=3>structure will be written into the</font> <font size=3><I>value</I></font> <font size=3>buffer, containing a list of the attributes associated with the object, up to a maximum of</font> <font size=3><I>size</I></font> <font size=3>bytes. The</font> <font size=3><B>attrlist_t</B></font> <font size=3>structure contains the following elements:</font></p>
<p style="margin-left: 18%"><font size=3>typedef struct {<br>
<span style=" text-indent: 2%;"></span><EM>__s32 count; /* number of entries in attribute list */<br>
<span style=" text-indent: 2%;"></span>__s32 more; /* [in/out arg] more attrs (call again) */</EM></font>
<table width="99%" rules="none" frame="none" cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td valign="top" align="left" width="21%">
</p>
</td>
<td valign="top" align="left" width="78%">
<p><font size=3><EM>__s32 offset[1]; /* byte offsets of attrs [var&shy;sized] */</EM></font></p>
</td>
</tr>
</table>
<br>
<font size=3>} attrlist_t;</font></p>
<p style="margin-left: 18%"><font size=3>The</font> <font size=3><I>count</I></font> <font size=3>field shows the number of attributes represented in this buffer, which is also the number of elements in the</font> <font size=3><I>offset</I></font> <font size=3>array. The</font> <font size=3><I>more</I></font> <font size=3>field will be non&shy;zero if another</font> <font size=3><B>ATTR_OP_LIST</B></font> <font size=3>call would retrieve more attributes. The</font> <font size=3><I>offset</I></font> <font size=3>array contains the byte offset within the</font> <font size=3><I>value</I></font> <font size=3>buffer of the structure describing each of the attributes, an</font> <font size=3><B>attrlist_ent_t</B></font> <font size=3>structure. The</font> <font size=3><B>ATTR_ENTRY(buffer, index)</B></font> <font size=3>macro will help with decoding the list. It takes a pointer to the</font> <font size=3><I>value</I></font> <font size=3>and an index into the</font> <font size=3><I>offset</I></font> <font size=3>array, and returns a pointer to the corresponding</font> <font size=3><I>attrlist_ent_t</I></font> <font size=3>structure.</font></p>
<p style="margin-left: 18%"><font size=3>typedef struct {</font>
<table width="99%" rules="none" frame="none" cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td valign="top" align="left" width="21%">
</p>
</td>
<td valign="top" align="left" width="78%">
<p><font size=3><EM>__u32 valuelen; /* number of bytes in attribute value */</EM></font></p>
</td>
</tr>
</table>
<br>
<span style=" text-indent: 2%;"></span><font size=3><EM>char name[]; /* attribute name (NULL terminated) */<br>
</EM>} attrlist_ent_t;</font></p>
<p style="margin-left: 18%"><font size=3>The</font> <font size=3><I>valuelen</I></font> <font size=3>field shows the size in bytes of the value associated with the attribute whose name is stored in the</font> <font size=3><I>name</I></font> <font size=3>field.</font></p>
<p style="margin-left: 18%"><font size=3>Valid</font> <font size=3><I>flags</I></font> <font size=3>for the</font> <font size=3><B>ATTR_LIST</B></font> <font size=3>command are ATTR_ROOT and ATTR_DONTFOLLOW. The</font> <font size=3><I>aux</I></font> <font size=3>pointer is used to reference an opaque cursor (type</font> <font size=3><B>attrlist_cursor_t</B></font><font size=3>), which the kernel uses to track the calling process's position in the attribute list. The only valid operations on this cursor are to pass it into the operation or to zero it out (it should be zeroed before the first</font> <font size=3><B>attrctl</B></font> <font size=3>call. Note that multi&shy;threaded applications may keep more than one cursor in order to serve multiple contexts (i.e. the</font> <font size=3><B>ATTR_LIST</B></font> <font size=3>operation is &quot;thread&shy;safe&quot;).</font></p>
<p style="margin-left: 18%"><font size=3>All operations will set</font> <font size=3><I>error</I></font> <font size=3>to an error code if the operation fails, otherwise it will contain zero indicating success. The set of valid</font> <font size=3><I>flags</I></font> <font size=3>field values (combined using bitwise OR) is as follows:</font>
<table width="99%" rules="none" frame="none" cols="3" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td valign="top" align="left" width="18%">
</p>
</td>
<td valign="top" align="left" width="18%">
<p><font size=2>ATTR_ROOT</font></p>
</td>
<td valign="top" align="left" width="63%">
<p><font size=3>Look for attribute</font> <font size=3><I>name</I></font> <font size=3>in the</font> <font size=3><B>root</B></font> <font size=3>address space, not in the</font> <font size=3><B>user</B></font></p>
</td>
</tr>
</table>
<br>
<span style=" text-indent: 18%;"></span><font size=3>address space (limited to use by the super&shy;user only).</font></p>
<p style="margin-left: 18%"><font size=2>ATTR_DONTFOLLOW</font> <font size=3>Do not follow symbolic links when resolving a</font> <font size=3><I>path</I></font> <font size=3>on an</font> <font size=3><I>attr_set<br>
<span style=" text-indent: 18%;"></span></I>function call. The default is to follow symbolic links.</font>
<table width="99%" rules="none" frame="none" cols="3" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td valign="top" align="left" width="18%">
</p>
</td>
<td valign="top" align="left" width="18%">
<p><font size=2>ATTR_CREATE</font></p>
</td>
<td valign="top" align="left" width="63%">
<p><font size=3>Set</font> <font size=3><I>error</I></font> <font size=3>field (EEXIST) if an attribute of the given name already exists on the indicated object. This flag is used to implement a pure create operation, without this flag</font> <font size=3><B>ATTR_SET</B></font> <font size=3>will create the attribute if it does not already exist.</font></p>
</td>
</tr>
</table>
<br>
</p>

<!-- Page: 3  -->
<!-- left  margin: 220 -->
<!-- right margin: 750 -->

<table width="99%" rules="none" frame="none" cols="3" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td valign="top" align="left" width="18%">
</td>
<td valign="top" align="left" width="18%">
<p><font size=2>ATTR_REPLACE</font></p>
</td>
<td valign="top" align="left" width="63%">
<p><font size=3>Set</font> <font size=3><I>error</I></font> <font size=3>field (ENOENT) if an attribute of the given name does not already exist on the indicated object, otherwise replace the existing attribute&acute;s value with the given value. This flag is used to implement a pure replacement operation, without this flag</font> <font size=3><B>ATTR_SET</B></font> <font size=3>will create the attribute if it does not already exist.</font></p>
</td>
</tr>
</table>
<p style="margin-left: 18%"><font size=3>The</font> <font size=3><I>error</I></font> <font size=3>field will be set (EINVAL) if both ATTR_CREATE and ATTR_REPLACE are requested in the same operation.</font></p>
<a name="DIAGNOSTICS"></a><h2>DIAGNOSTICS</h2><p style="margin-left: 18%"><font size=3><I>attrctl</I></font> <font size=3>will return 0 on success, and an error code on any failure. Since the</font> <font size=3><I>attrctl</I></font> <font size=3>system call is arbitrarily extensible, and the intention is that it will always be used through an overlying API, refer to the manual pages for overlying API calls for specific error code values.</font></p>
<p style="margin-left: 18%"><font size=3><I>attrctl</I></font> <font size=3>will always attempt to perform all operations, and a set of operations are not atomic (failure of one operation does not necessarily cause prior successful operations to be undone).</font></p>
<a name="SEE ALSO"></a><h2>SEE ALSO</h2><p style="margin-left: 18%"><font size=3>attr(1),<br>
attr_list(3), attr_listf(3),<br>
attr_multi(3), attr_multif(3),<br>
attr_remove(3), attr_removef(3),<br>
attr_set(3), attr_setf(3).</font><br>
</p>
</body>
</html>