QUOTACTL(2)               NetBSD System Calls Manual               QUOTACTL(2)

NAME
     quotactl -- manipulate file system quotas

LIBRARY
     Standard C Library (libc, -lc)

SYNOPSIS
     #include <prop/proplib.h>
     #include <sys/quota.h>

     int
     quotactl(const char *path, struct plistref *pref);

DESCRIPTION
     The quotactl() call manipulates file system quotas.  A quota control com-
     mand described by struct plistref * operates on the given filename path.

     The top-level object of the property list sent to the kernel is a dictio-
     nary.  It holds an integer with key "interface version", which must be 1
     at this time.  The key "commands" holds an array of dictionaries, each
     dictionary describe a command.

     A command dictionary has the following keys:

     command  A string describing the command to execute.

     data     An array of arguments to the command.

     type     A string describing the type of quota to address.  At this time
              this can be either "user" or "group".

     The data array is an array of dictionaries, the dictionary structure
     depends on the command.  If the command takes no arguments, the array
     must be present and empty.  A dictionary describing a quota entry is com-
     mon to many commands arguments or replies.  It has the following keys:

     block  A dictionary describing quota values and limits for block usage.

     file   A dictionary describing quota values and limits for inode usage.

     id     either an unsigned integer, or the string "default".  If this key
            is an integer, the value is the user or group id this quota entry
            belongs to.  If this key is the string "default", this quota entry
            describe the default quotas for this file system.

     The block or file dictionaries have the following structures:

     usage        an unsigned integer which contains the current usage.

     soft         unsigned integer containing the soft limit.  The value
                  defined by the macro UQUAD_MAX means there is no limit.

     hard         unsigned integer containing the hard limit.  The value
                  defined by the macro UQUAD_MAX means there is no limit.

     grace time   integer, the grace delay in seconds which should be applied
                  when usage goes over the soft limit.

     expire time  integer, the time (in seconds since epoch) at which the
                  grace delay expires.  This key is only valid when usage is
                  over the soft limit.

     On return the "struct plistref *" contains an updated plist.  It has the
     same structure as the plist sent to the kernel.  The command dictionary
     gains an additional key "return", and integer holding an errno which is
     the status of the command.  The data array is updated with replies from
     the command.

     Commands are:

     get version  get the kernel quota version implementation for the speci-
                  fied file system and type.  The data array in the reply has
                  a single dictionary, which has a single integer key "ver-
                  sion".  At this time version can be "1" (the legacy quota
                  implementation, with usages and limits stored in an external
                  file) or "2" (the new quota implementation, where usages and
                  limits are integrated in the file system metadata).

     get          Get a quota entry for the specified id.  The command argu-
                  ment is one or more "id" keys.  The command reply is the
                  requested quota entries, as described above.

     getall       Get all quota entries (kernel quota version 2 only).  This
                  command takes no arguments, the reply is all the existing
                  quota entries for this file system and type.

     set          create or update quota limits.  Argument is one or more
                  quota entries holding the updated quota limits.  There is no
                  reply.

     clear        clear specified quota entries (kernel quota version 2 only).
                  Each quota entry is either returned to the free list if both
                  block and file usage is 0, or limits are reverted to the
                  default values otherwise.  The command argument is one or
                  more "id" keys.  There is no reply.

     quotaon      enable the specified quota type on the specified file system
                  (kernel quota version 1 only).  Argument is a string with
                  key "quotafile", which contains the path to the external
                  file holding usages and limits.  There is no reply.

     quotaoff     disable the specified quota type on the specified file sys-
                  tem (kernel quota version 1 only).  There is no arguments
                  and no replies.

RETURN VALUES
     A successful call returns 0, otherwise the value -1 is returned and the
     global variable errno indicates the reason for the failure.

FILES
     Example of usage of the quotactl syscall, with construction of the pref
     argument an interpretation of the reply, can be found in the following
     NetBSD source files:

     src/usr.bin/quota/getvfsquota.c

     src/usr.sbin/repquota/repquota.c

     src/usr.sbin/edquota/edquota.c

     src/usr.sbin/quotaon/quotaon.c

     src/sys/ufs/ufs/quota2_prop.c

ERRORS
     A quotactl() call will fail if:

     [EFAULT]           struct plistref * points outside the process's allo-
                        cated address space, or an invalid addr was supplied;
                        the associated structure could not be copied in or out
                        of the kernel.

     [EINVAL]           The plist is invalid.

     [ENOMEM]           Memory could not be allocated to handle the plist.

     [EOPNOTSUPP]       Either the kernel has not been compiled with the QUOTA
                        or QUOTA2 options, or the mounted file system doesn't
                        support quota.

SEE ALSO
     quota(1), prop_send_syscall(3), proplib(3), fstab(5), edquota(8),
     quotacheck(8), quotactl(8), quotaon(8), repquota(8)

HISTORY
     The quotactl() function call appeared in 4.3BSD-Reno.

BUGS
     There should be some way to integrate this call with the resource limit
     interface provided by setrlimit(2) and getrlimit(2).

NetBSD 5.0                     February 11, 2011                    NetBSD 5.0