Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ attr_multi(2) — IRIX 6.5.3f

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

attr(1)

attr_get(2)

attr_getf(2)

attr_list(2)

attr_remove(2)

attr_removef(2)

attr_set(2)



ATTRMULTI(2)                                                    ATTRMULTI(2)



NAME
     attr_multi, attr_multif - manipulate multiple user attributes on a
     filesystem object at once

C SYNOPSIS
     #include <sys/attributes.h>

     int attrmulti (const char *path, attrmultiopt *oplist,
                     int count, int flags);

     int attrmultif (int fd, attrmultiopt *oplist,
                      int count, int flags);

OVERVIEW
     The attr group of system calls implement the ability for a user to attach
     name/value pairs to objects within the filesystem.

     They could be used to store meta-information about the file.  For example
     "character-set=kanji" could tell a document browser to use the Kanji
     character set when displaying that document and "thumbnail=..." could
     provide a reduced resolution overview of a high resolution graphic image.

     The names 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.

     The values can be up to ATTR_MAX_VALUELEN (currently 64KB) of arbitrary
     binary data.

     Attributes can be attached to all types of inodes:  regular files,
     directories, symbolic links, device nodes, etc.

     There are 2 disjoint attribute name spaces associated with every
     filesystem object.  They are the root and user address spaces.  The root
     address space is accessable only to the super-user, and then only by
     specifying a flag argument to the function call.  Other users will not
     see or be able to modify attributes in the root address space.  The user
     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.

     Attributes are currently supported only in the XFS filesystem type.

DESCRIPTION
     The attr_multi and attr_multif functions provide a way to operate on
     multiple attributes of a filesystem object at once.

     Path points to a path name for a filesystem object, and fd refers to the
     file descriptor associated with a file.  The oplist is an array of
     attrmultiopt structures.  Each element in that array describes a single
     attribute operation and provides all the information required to carry
     out that operation and to check for success or failure of that operation.



                                                                        Page 1





ATTRMULTI(2)                                                    ATTRMULTI(2)



     Count tells how many elements are in the oplist array.

     The contents of an attrmultiopt structure include the following
     members:

        int amopcode; /* which operation to perform (see below) */
        int amerror; /* [out arg] result of this sub-op (an errno) */
        char *amattrname; /* attribute name to work with */
        char *amattrvalue; /* [in/out arg] attribute value (raw bytes) */
        int amlength; /* [in/out arg] length of value */
        int amflags; /* flags (bit-wise OR of #defines below) */

     The am_opcode field defines how the remaining fields are to be
     interpreted and can take on one of the following values:

        ATTROPGET /* return the indicated attr's value */
        ATTROPSET /* set/create the indicated attr/value pair */
        ATTROPREMOVE /* remove the indicated attr */

     The am_error field will contain the appropriate error result code if that
     sub-operation fails.  The result codes for a given sub-operation are a
     subset of the result codes that are possible from the corresponding
     single-attribute function call.  For example, the result code possible
     from an ATTROPGET sub-operation are a subset of those that can be
     returned from an attr_get function call.

     The am_attrname field is a pointer to a NULL terminated string giving the
     attribute name that the sub-operation should operate on.

     The am_attrvalue, am_length and am_flags fields are used to store the
     value of the named attribute, and some control flags for that sub-
     operation, respectively.  Their use varies depending on the value of the
     am_opcode field.

     ATTROPGET
          The am_attrvalue field is a pointer to a empty buffer that will be
          overwritten with the value of the named attribute.  The am_length
          field is initially the total size of the memory buffer that the
          am_attrvalue field points to.  After the operation, the am_length
          field contains the actual size of the attribute's value.  The
          am_flags field may be set to the ATTRROOT flag.  If the process has
          appropriate priviledges, the ROOT namespace will be searched for the
          named attribute, otherwise the USER namespace will be searched.

     ATTROPSET
          The am_attrvalue and am_length fields contain the new value for the
          given attribute name and its length.  The ATTRROOT flag may be set
          in the am_flags field.  If the process has appropriate priviledges,
          the ROOT namespace will be searched for the named attribute,
          otherwise the USER namespace will be searched.  The ATTRCREATE and
          the ATTRREPLACE flags may also be set in the am_flags field (but
          not simultaneously).  If the ATTRCREATE flag is set, the sub-



                                                                        Page 2





ATTRMULTI(2)                                                    ATTRMULTI(2)



          operation will set the am_error field to EEXIST if the named
          attribute already exists.  If the ATTRREPLACE flag is set, the
          sub-operation will set the am_error field to ENOATTR if the named
          attribute does not already exist.  If neither of those two flags are
          set and the attribute does not exist, then the attribute will be
          created with the given value.  If neither of those two flags are set
          and the attribute already exists, then the value will be replaced
          with the given value.

     ATTROPREMOVE
          The am_attrvalue and am_length fields are not used and are ignored.
          The am_flags field may be set to the ATTRROOT flag.  If the process
          has appropriate priviledges, the ROOT namespace will be searched for
          the named attribute, otherwise the USER namespace will be searched.

     The flags argument to the attr_multi call is used to control following of
     symbolic links in the path argument.  The default is to follow symbolic
     links, flags should be set to ATTR_DONTFOLLOW to not follow symbolic
     links.

     attr_multi will fail if one or more of the following are true:

     [ENOENT]         The named file does not exist.

     [EPERM]          The effective user ID does not match the owner of the
                      file and the effective user ID is not super-user.

     [ENOTDIR]        A component of the path prefix is not a directory.

     [EACCES]         Search permission is denied on a component of the path
                      prefix.

     [EINVAL]         A bit other than ATTR_DONTFOLLOW was set in the flag
                      argument.

     [EFAULT]         Path, or oplist points outside the allocated address
                      space of the process.

     [ELOOP]          A path name lookup involved too many symbolic links.

     [ENAMETOOLONG]   The length of path exceeds {MAXPATHLEN}, or a pathname
                      component is longer than {MAXNAMELEN}.

     attr_multif will fail if:

     [EINVAL]       A bit was set in the flag argument, or fd refers to a
                    socket, not a file.

     [EFAULT]       Oplist points outside the allocated address space of the
                    process.





                                                                        Page 3





ATTRMULTI(2)                                                    ATTRMULTI(2)



     [EBADF]        Fd does not refer to a valid descriptor.

SEE ALSO
     attr(1),
     attr_get(2), attr_getf(2),
     attr_list(2), attr_list(2)
     attr_remove(2), attr_removef(2),
     attr_set(2), attr_set(2)

DIAGNOSTICS
     Upon successful completion of the attr_multi call, a value of 0 is
     returned.  Otherwise, a value of -1 is returned and errno is set to
     indicate the error.  Note that the individual operations listed in the
     oplist array each have their own error return fields.  The errno variable
     only records the result of the attr_multi call itself, not the result of
     any of the sub-operations.







































                                                                        Page 4



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026