MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


Standard C Library Functions                         fgetattr(3C)



NAME
     fgetattr, fsetattr, getattrat, setattrat - get and set  sys-
     tem attributes

SYNOPSIS
     #include 
     #include 
     #include 
     #include 

     int fgetattr(int fildes, xattrviewt view,nvlistt **response);


     int fsetattr(int fildes, xattrviewt view,nvlistt *request)


     int getattrat(int fildes, xattrviewt view, const char *filename,
          nvlistt **response);


     int setattrat(int fildes, xattrviewt view, const char *filename,
          nvlistt *request);


DESCRIPTION
     The fgetattr() function obtains an nvlist of  system  attri-
     bute  information about an open file object specified by the
     file descriptor fildes, obtained from a successful  open(2),
     creat(2), dup(2), fcntl(2), or pipe(2) function.


     The getattrat() function first opens the extended  attribute
     file specified by filename in the already opened file direc-
     tory object specified by fildes. It then retrieves an nvlist
     of system attributes and their values from filename.


     The response argument is allocated by either  fgetattr()  or
     getattrat().  The application must call nvlistfree(3NVPAIR)
     to deallocate the memory.


     Upon successful completion,  the  nvlist  will  contain  one
     nvpair  for  each  of  the system attributes associated with
     view.  The list of views and the attributes associated  with
     each view are listed below.  Not all underlying file systems
     support all views and all attributes. The  nvlist  will  not
     contain  an  nvpair  for  any attribute not supported by the
     underlying filesystem.






SunOS 5.11           Last change: 4 Aug 2008                    1






Standard C Library Functions                         fgetattr(3C)



     The fsetattr()  function  uses  the  nvlist  pointed  to  by
     request  to  update  one  or  more of the system attribute's
     information about an open file object specified by the  file
     descriptor   fildes,  obtained  from  a  successful  open(),
     creat(), dup(), fcntl(), or pipe() function. The setattrat()
     function  first  opens the extended attribute file specified
     by filename in the  already  opened  file  directory  object
     specified  by  fildes. It then uses the nvlist pointed to by
     request to update one or more of the  system  attributes  of
     filename.


     If completion is not successful  then  no  system  attribute
     information is updated.


     The following chart lists the supported  views,  attributes,
     and  data types for each view:



             View               Attribute             Data type
     
     XATRVIEWREADONLY    AFSID               uint64value
                            AOPAQUE             booleanvalue
                            AVSCANSTAMP       uint8array[]
     XATRVIEWREADWRITE   AREADONLY           booleanvalue
                            AHIDEN             booleanvalue
                            ASYSTEM             booleanvalue
                            ARCHIVE            booleanvalue
                            ACRTIME             uint64array[2]
                            ANOUNLINK           booleanvalue
                            AIMUTABLE          booleanvalue
                            APENDONLY         booleanvalue
                            ANODUMP             booleanvalue
                            AVQUARANTINED     booleanvalue
                            AVMODIFIED        booleanvalue
                            AOWNERSID           nvlist composed of
                                                 uint32value   and
                                                 string
                            AGROUPSID           nvlist composed of
                                                 uint32value   and
                                                 string


RETURN VALUES
     Upon successful completion, 0 is returned. Otherwise, -1  is
     returned and errno is set to indicate the error.

ERORS
     The fgetattr(), getattrat(),  fsetattr(),  and  setattrat(),
     functions will fail if:



SunOS 5.11           Last change: 4 Aug 2008                    2






Standard C Library Functions                         fgetattr(3C)



     EBADF     The fildes argument  is  not  a  valid  open  file
               descriptor.


     EINVAL    The  underlying  file  system  does  not   support
               extended file attributes.


     EIO       An error occurred while reading from the file sys-
               tem.



     The getattrat() and setattrat() functions will fail if:

     EACES    Search permission or write permission for filename
               is denied.


     ENOENT    The filename argument does not  name  an  existing
               file   in   the   extended   attribute   directory
               represented by fildes.


     EPERM     There are insufficient  privileges  to  manipulate
               attributes.


EXAMPLES
     Example 1 Obtain an nvlist of readonly system attributes for
     an open file object.


     Use fgetattr() to obtain an nvlist of  the  readonly  system
     attributes  for  the  open  file  object represented by file
     descriptor fildes.


       #include 
       #include 
       #include 
       #include 

       nvlistt *response;
       nvpairt *pair = NUL;

       if (fgetattr(fildes, XATRVIEWREADONLY, &response)) {
                    exit(1);
       }
       while (pair = nvlistnextnvpair(response, pair)) {
           .
           .



SunOS 5.11           Last change: 4 Aug 2008                    3






Standard C Library Functions                         fgetattr(3C)



           .
       }
       nvlistfree(response);


     Example 2 Set the AREADONLY system  attribute  on  an  open
     file object.


     Use fsetattr() to set the AOPAQUE system attribute  on  the
     open file object represented by file descriptor fildes.


       nvlistt *request;
       nvpairt *pair = NUL;

       if (nvlistalloc(&request, NVUNIQUENAME, 0) != 0) {
                   exit(1);
       }
       if (nvlistaddbooleanvalue(request, AREADONLY, 1) != 0) {
                   exit(1);
       }
       if (fsetattr(fildes, XATRVIEWREADWRITE, request)) {
                   exit(1);
       }


     Example 3 Obtain an nvlist of the read/write  system  attri-
     butes for a file.


     Use getattrat() to obtain an nvlist of the read/write system
     attributes  for  the  file  named  xattrfile in the extended
     attribute directory of the open  file  represented  by  file
     descriptor fildes.


       nvlistt *response;
       nvpairt *pair = NUL;

       if (getattrat(fildes, XATRVIEWREADWRITE, "file", &response)) {
                    exit(1);
       }
       while (pair = nvlistnextnvpair(response, pair)) {
           .
           .
           .
       }
       nvlistfree(response);






SunOS 5.11           Last change: 4 Aug 2008                    4






Standard C Library Functions                         fgetattr(3C)



     Example 4 Set the APENDONLY system attribute on a file.


     Use setattrat() to set the APENDONLY system attribute  on
     the  file  named file in the extended attribute directory of
     the open file represented by file descriptor fildes.


       nvlistt *request;
       nvpairt *pair = NUL;

       if (nvlistalloc(&request, NVUNIQUENAME, 0) != 0) {
                   exit(1);
       }
       if (nvlistaddbooleanvalue(request, APENDONLY, 1) != 0) {
                   exit(1);
       }
       if (setattrat(fildes, XATRVIEWREADWRITE, "file", request)) {
                   exit(1);
            }


ATRIBUTES
     See attributes(5) for descriptions of the  following  attri-
     butes:



     
           ATRIBUTE TYPE               ATRIBUTE VALUE       
    
     Interface Stability          Committed                   
    
     MT-Level                     Safe                        
    


SEE ALSO
     creat(2), dup(2), fcntl(2), fstat(2),  fstatat(2),  open(2),
     pipe(2), libnvpair(3LIB), attributes(5), fsattr(5)















SunOS 5.11           Last change: 4 Aug 2008                    5



OpenSolaris man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™