mod_quotatab
Structure
The following data structures are all declared in mod_quotatab.h
,
but are provided here for ease of cross-reference.
typedef enum { all_quota = 10, user_quota = 20, group_quota = 30, class_quota = 40 } quota_type_t;
Quota byte limit types. A "hard" limit is imposed by deleting any file that causes the tally to go over the configured limit. A "soft" limit will allow that file to exist, but will not allow further uploads.
typedef enum { hard_limit = 1, soft_limit = 2 } quota_limit_type_t;
typedef struct { /* Name refers to user, group, or class */ char name[81]; quota_type_t quota_type; /* Are quotas enforced per session or not? */ unsigned char quota_per_session; /* Are byte quotas hard or soft? */ quota_limit_type_t quota_limit_type; /* Configured bytes limits. */ double bytes_in_avail; double bytes_out_avail; double bytes_xfer_avail; /* Configured files limits. These have no "limit type", as they are * always hard. */ unsigned long files_in_avail; unsigned long files_out_avail; unsigned long files_xfer_avail; } quota_limit_t;
typedef struct { char name[81]; quota_type_t quota_type; /* Current bytes tallies. */ double bytes_in_used; double bytes_out_used; double bytes_xfer_used; /* Current files tallies. */ unsigned long files_in_used; unsigned long files_out_used; unsigned long files_xfer_used; } quota_tally_t;
Quota table type (i.e. limit or tally):
typedef enum { type_limit = 100, type_tally } quota_tabtype_t;
typedef enum { byte = 10, kilo, mega, giga } quota_units_t;
Quota deltas structure. These are used to track the changes in tallies
per-operation (e.g. for each APPE, RETR, STOR, or STOU). This structure
is useful for some submodules (e.g. mod_quotatab_sql
) that
are more interested in the deltas, rather than in the current absolute
tallies values.
typedef struct { /* Deltas of bytes tallies. */ double bytes_in_delta; double bytes_out_delta; double bytes_xfer_delta; /* Deltas of files tallies. */ unsigned long files_in_delta; unsigned long files_out_delta; unsigned long files_xfer_delta; } quota_deltas_t;
This is just an interim quota table abstraction, to be used until Confstreams are added to the core proftpd code.
typedef struct table_obj { /* Memory pool for this object. */ pool *tab_pool; /* Table type, limit or tally. */ quota_tabtype_t tab_type; /* Table handle */ int tab_handle; /* Table "magic" number. Often used for the verification process. */ unsigned long tab_magic; /* Table record length */ unsigned int tab_quotalen; /* Arbitrary data pointer */ void *tab_data; /* Table I/O routines */ int (*tab_close)(struct table_obj *); int (*tab_create)(struct table_obj *); unsigned char (*tab_lookup)(struct table_obj *, const char *, quota_type_t); int (*tab_read)(struct table_obj *); unsigned char (*tab_verify)(struct table_obj *); int (*tab_write)(struct table_obj *); /* Table locking routines */ struct flock tab_lock; int (*tab_rlock)(struct table_obj *); int (*tab_unlock)(struct table_obj *); int (*tab_wlock)(struct table_obj *); } quota_table_t;
The header file also defines some instances of the above structures that
have scope for mod_quotatab
and its submodules. These
structures are used as the key in-memory storage locations for quota
information:
quota_limit_t quotatab_limit; quota_tally_t quotatab_tally; quota_deltas_t quotatab_deltas;