3 * Headerfile of quota interactions with system - filenames, fstab...
10 #include <sys/types.h>
14 #define MAXNAMELEN 64 /* Maximal length of user/group name */
15 #define MAXTIMELEN 40 /* Maximal length of time string */
16 #define MAXNUMLEN 32 /* Maximal length of number */
17 #define MAXMNTPOINTS 256 /* Maximal number of mountpoints with quota */
19 /* Flags for formatting time */
20 #define TF_ROUND 0x1 /* Should be printed time rounded? */
22 /* Flags for IO initialization */
23 #define IOI_LOCALONLY 0x1 /* Operate only on local quota */
24 #define IOI_READONLY 0x2 /* Only readonly access */
25 #define IOI_OPENFILE 0x4 /* Open file even if kernel has quotas turned on */
27 #define KERN_KNOWN_QUOTA_VERSION (6*10000 + 5*100 + 1)
29 /* Interface versions */
30 #define IFACE_VFSOLD 1
32 #define IFACE_GENERIC 3
34 /* Kernel quota format and supported interface */
35 extern int kernel_formats, kernel_iface;
40 /* Convert quota type to written form */
43 /* Convert username to uid */
44 uid_t user2uid(char *);
46 /* Convert groupname to gid */
47 gid_t group2gid(char *);
49 /* Convert user/groupname to id */
50 int name2id(char *name, int qtype);
52 /* Convert uid to username */
53 int uid2user(uid_t, char *);
55 /* Convert gid to groupname */
56 int gid2group(gid_t, char *);
58 /* Convert id to user/group name */
59 int id2name(int id, int qtype, char *buf);
61 /* Possible default passwd handling */
62 #define PASSWD_FILES 0
64 /* Parse /etc/nsswitch.conf and return type of default passwd handling */
65 int passwd_handling(void);
67 /* Convert quota format name to number */
68 int name2fmt(char *str);
70 /* Convert quota format number to name */
71 char *fmt2name(int fmt);
73 /* Convert kernel to utility format numbers */
74 int kern2utilfmt(int fmt);
76 /* Convert utility to kernel format numbers */
77 int util2kernfmt(int fmt);
79 /* Convert time difference between given time and current time to printable form */
80 void difftime2str(time_t, char *);
82 /* Convert time to printable form */
83 void time2str(time_t, char *, int);
85 /* Convert number and units to time in seconds */
86 int str2timeunits(time_t, char *, time_t *);
88 /* Convert number in quota blocks to short printable form */
89 void space2str(qsize_t, char *, int);
91 /* Convert number to short printable form */
92 void number2str(unsigned long long, char *, int);
94 /* Check to see if particular quota is to be enabled */
95 int hasquota(struct mntent *mnt, int type);
97 /* Flags for get_qf_name() */
98 #define NF_EXIST 1 /* Check whether file exists */
99 #define NF_FORMAT 2 /* Check whether file is in proper format */
100 /* Get quotafile name for given entry */
101 int get_qf_name(struct mntent *mnt, int type, int fmt, int flags, char **filename);
103 /* Detect newest quota format with existing file */
104 int detect_quota_files(struct mntent *mnt, int type, int fmt);
106 /* Create NULL-terminated list of handles for quotafiles for given mountpoints */
107 struct quota_handle **create_handle_list(int count, char **mntpoints, int type, int fmt,
108 int ioflags, int mntflags);
109 /* Dispose given list of handles */
110 int dispose_handle_list(struct quota_handle **hlist);
112 /* Check whether given device name matches quota handle device */
113 int devcmp_handle(const char *dev, struct quota_handle *h);
115 /* Check whether two quota handles have same device */
116 int devcmp_handles(struct quota_handle *a, struct quota_handle *b);
118 /* Check kernel supported quotafile format */
119 void init_kernel_interface(void);
121 /* Check whether is quota turned on on given device for given type */
122 int kern_quota_on(const char *dev, int type, int fmt);
124 /* Flags for init_mounts_scan() */
125 #define MS_NO_MNTPOINT 0x01 /* Specified directory needn't be mountpoint */
126 #define MS_NO_AUTOFS 0x02 /* Ignore autofs mountpoints */
127 #define MS_QUIET 0x04 /* Be quiet with error reporting */
128 /* Initialize mountpoints scan */
129 int init_mounts_scan(int dcnt, char **dirs, int flags);
131 /* Return next mountpoint for scan */
132 struct mntent *get_next_mount(void);
134 /* Free all structures associated with mountpoints scan */
135 void end_mounts_scan(void);
137 #endif /* _QUOTASYS_H */