X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=user.h;fp=user.h;h=3eefab13fb56e190bb777c357a484701848890fa;hb=4113e8c585d3da46bfa5326b866621cff854a737;hp=0000000000000000000000000000000000000000;hpb=322ce333fb09ceb39b55a77eceff3ac0cbaf1522;p=adu.git diff --git a/user.h b/user.h new file mode 100644 index 0000000..3eefab1 --- /dev/null +++ b/user.h @@ -0,0 +1,53 @@ +/** The columns of the id table. */ +enum user_table_columns { + /** The numer of the directory. */ + UT_DIR_NUM, + /** The number of bytes of all regular files in this dir owned by this id. */ + UT_BYTES, + /** The number of files in this dir owned by this id. */ + UT_FILES, + /** Number of columns in this table. */ + NUM_UT_COLUMNS +}; + +/** Information about one admissible user. */ +struct user_info { + /** User ID. */ + uint32_t uid; + /** \sa enum uid_info_flags. */ + uint32_t flags; + /** The user name. */ + char *pw_name; + /** The user table of this user.*/ + struct osl_table *table; + /** Total number of files owned by this user. */ + uint64_t files; + /** Total number of bytes owned by this user. */ + uint64_t bytes; + /** Total number of directories that contain at least one file */ + uint64_t dirs; + /** The description of the user table. */ + struct osl_table_description *desc; +}; + +/** An opaque struct that contains info about which users are admissible. */ +struct uid_range; + +enum search_uid_flags { + OPEN_USER_TABLE = 1, + CREATE_USER_TABLE = 2, +}; +int search_uid(uint32_t uid, struct uid_range *urs, + enum search_uid_flags flags, struct user_info **ui_ptr); + +int read_uid_file(struct uid_range *admissible_uids); +int write_uid_file(void); + +void create_hash_table(unsigned bits); +void sort_hash_table(int (*comp)(const void *, const void *)); +void free_hash_table(void); + +int for_each_admissible_user(int (*func)(struct user_info *, void *), + void *data); +int parse_uid_arg(const char *orig_arg, struct uid_range **ur); +void close_user_tables(void);