Skip to content

Commit

Permalink
Added several constant macros as args to bufsize.
Browse files Browse the repository at this point in the history
  • Loading branch information
DarrenKirby committed Sep 19, 2024
1 parent b39521d commit e29348b
Showing 1 changed file with 41 additions and 3 deletions.
44 changes: 41 additions & 3 deletions lib/libstatfsext.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#ifndef _LIBSTATFSEXT_H
#define _LIBSTATFSEXT_H

#define LIBVERSION 2.0.0
#define LIBVERSION 2.0.1

#include <stdio.h>
#include <sys/statfs.h> /* for statfs struct */
Expand All @@ -41,6 +41,7 @@
#define FS_TYPE_LEN 90
#define MNT_FLAGS_LEN 256


struct mounted_fs_entry {
char fs_spec[PATH_MAX]; /* device or special file system path */
char fs_file[PATH_MAX]; /* mount point */
Expand All @@ -50,6 +51,7 @@ struct mounted_fs_entry {
int fs_passno; /* pass */
};


#if __WORDSIZE == 32
#define __WORD_TYPE int
#else /* __WORDSIZE == 64 */
Expand All @@ -75,13 +77,49 @@ struct statfs_ext {
char f_mntfromname[PATH_MAX]; /* mounted file sytem */
};

#define FS_1 sizeof(struct statfs_ext)
#define FS_ALL 0

/* These constants are for passing to the `bufsize` argument of
* getfsstat_ext(). Passing FS_NUM will tell the function to just
* return the number of mounted filesystems. FS_1 through FS_20 will
* populate statfs_ext structs for the first 1-20 mounted filesystems.
* FS_ALL will populate structs for all mounted filesystems.
*
* Note that getfsstat_ext's return value will be the number of mounted
* filesystems it has found regardless of how many structs were asked for.
*/

#define STATFS_EXT_SIZE sizeof(struct statfs_ext)
#define FS_NUM 0
#define FS_1 STATFS_EXT_SIZE
#define FS_2 (FS_1 * 2)
#define FS_3 (FS_1 * 3)
#define FS_4 (FS_1 * 4)
#define FS_5 (FS_1 * 5)
#define FS_6 (FS_1 * 6)
#define FS_7 (FS_1 * 7)
#define FS_8 (FS_1 * 8)
#define FS_9 (FS_1 * 9)
#define FS_10 (FS_1 * 10)
#define FS_11 (FS_1 * 11)
#define FS_12 (FS_1 * 12)
#define FS_13 (FS_1 * 13)
#define FS_14 (FS_1 * 14)
#define FS_15 (FS_1 * 15)
#define FS_16 (FS_1 * 16)
#define FS_17 (FS_1 * 17)
#define FS_18 (FS_1 * 18)
#define FS_19 (FS_1 * 19)
#define FS_20 (FS_1 * 20)
// bufsize expects a long int, so this must be
// an arbitrary 'magic number'.
#define FS_ALL 0xdeadbee


/* function prototypes */
extern int getmntpt(const char *path, char *mount_point);
extern int statfs_ext(const char *path, struct statfs_ext *struct_buf);
extern int getfsstat_ext(struct statfs_ext **struct_array_buf, long int bufsize, int flags);


#endif /* _LIBSTATFSEXT_H */

0 comments on commit e29348b

Please sign in to comment.