3 * Headerfile of quota interactions with system - filenames, fstab...
7 #ifndef GUARD_QUOTASYS_H
8 #define GUARD_QUOTASYS_H
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 */
18 /* Flags for formatting time */
19 #define TF_ROUND 0x1 /* Should be printed time rounded? */
21 /* Flags for IO initialization */
22 #define IOI_READONLY 0x1 /* Only readonly access */
23 #define IOI_INITSCAN 0x2 /* Prepare handle for scanning dquots */
24 #define IOI_NFS_MIXED_PATHS 0x4 /* Trim leading / from NFSv4 mountpoints */
26 #define KERN_KNOWN_QUOTA_VERSION (6*10000 + 5*100 + 1)
28 /* Interface versions */
29 #define IFACE_VFSOLD 1
31 #define IFACE_GENERIC 3
33 /* Path to export table of NFS daemon */
34 #define NFSD_XTAB_PATH "/var/lib/nfs/etab"
36 /* Supported kernel interface */
37 extern int kernel_iface;
40 char *me_type; /* Type of filesystem for given entry */
41 char *me_opts; /* Options of filesystem */
42 dev_t me_dev; /* Device filesystem is mounted on */
43 ino_t me_ino; /* Inode number of root of filesystem */
44 const char *me_devname; /* Name of device (after pass through get_device_name()) */
45 const char *me__dir; /* One mountpoint of a filesystem (strdup()ed) */
46 const char *me_dir; /* Current mountpoint of a filesystem to process */
47 int me_qfmt[MAXQUOTAS]; /* Detected quota formats */
53 /* Check whether type is one of the NFS filesystems */
54 int nfs_fstype(char *);
55 /* Quota file is treated as metadata? */
56 int meta_qf_fstype(char *type);
58 /* Convert quota type to written form */
61 /* Convert username to uid */
62 uid_t user2uid(char *, int flag, int *err);
64 /* Convert groupname to gid */
65 gid_t group2gid(char *, int flag, int *err);
67 /* Convert user/groupname to id */
68 int name2id(char *name, int qtype, int flag, int *err);
70 /* Convert uid to username */
71 int uid2user(uid_t, char *);
73 /* Convert gid to groupname */
74 int gid2group(gid_t, char *);
76 /* Convert id to user/group name */
77 int id2name(int id, int qtype, char *buf);
79 /* Possible default passwd handling */
80 #define PASSWD_FILES 0
82 /* Parse /etc/nsswitch.conf and return type of default passwd handling */
83 int passwd_handling(void);
85 /* Convert quota format name to number */
86 int name2fmt(char *str);
88 /* Convert quota format number to name */
89 char *fmt2name(int fmt);
91 /* Convert utility to kernel format numbers */
92 int util2kernfmt(int fmt);
94 /* Convert time difference between given time and current time to printable form */
95 void difftime2str(time_t, char *);
97 /* Convert time to printable form */
98 void time2str(time_t, char *, int);
100 /* Convert number and units to time in seconds */
101 int str2timeunits(time_t, char *, time_t *);
103 /* Convert number in quota blocks to short printable form */
104 void space2str(qsize_t, char *, int);
106 /* Convert number to short printable form */
107 void number2str(unsigned long long, char *, int);
109 /* Return pointer to given mount option in mount option string */
110 char *str_hasmntopt(const char *optstring, const char *opt);
112 /* Check to see if particular quota type is configured */
113 static inline int me_hasquota(struct mount_entry *mnt, int type)
115 return mnt->me_qfmt[type] >= 0;
118 /* Flags for get_qf_name() */
119 #define NF_EXIST 1 /* Check whether file exists */
120 #define NF_FORMAT 2 /* Check whether file is in proper format */
121 /* Get quotafile name for given entry */
122 int get_qf_name(struct mount_entry *mnt, int type, int fmt, int flags, char **filename);
124 /* Detect newest quota format with existing file */
125 int detect_quota_files(struct mount_entry *mnt, int type, int fmt);
127 /* Create NULL-terminated list of handles for quotafiles for given mountpoints */
128 struct quota_handle **create_handle_list(int count, char **mntpoints, int type, int fmt,
129 int ioflags, int mntflags);
130 /* Dispose given list of handles */
131 int dispose_handle_list(struct quota_handle **hlist);
133 /* Check whether given device name matches quota handle device */
134 int devcmp_handle(const char *dev, struct quota_handle *h);
136 /* Check whether two quota handles have same device */
137 int devcmp_handles(struct quota_handle *a, struct quota_handle *b);
139 /* Check kernel supported quotafile format */
140 void init_kernel_interface(void);
142 /* Check whether is quota turned on on given device for given type */
143 int kern_quota_on(struct mount_entry *mnt, int type, int fmt);
145 /* Return whether kernel is able to handle given format */
146 int kern_qfmt_supp(int fmt);
148 /* Flags for init_mounts_scan() */
149 #define MS_NO_MNTPOINT 0x01 /* Specified directory needn't be mountpoint */
150 #define MS_NO_AUTOFS 0x02 /* Ignore autofs mountpoints */
151 #define MS_QUIET 0x04 /* Be quiet with error reporting */
152 #define MS_LOCALONLY 0x08 /* Ignore nfs mountpoints */
153 #define MS_XFS_DISABLED 0x10 /* Return also XFS mountpoints with quota disabled */
154 #define MS_NFS_ALL 0x20 /* Don't filter NFS mountpoints on the same device */
156 /* Initialize mountpoints scan */
157 int init_mounts_scan(int dcnt, char **dirs, int flags);
159 /* Return next mountpoint for scan */
160 struct mount_entry *get_next_mount(void);
162 /* Free all structures associated with mountpoints scan */
163 void end_mounts_scan(void);
165 #endif /* GUARD_QUOTASYS_H */