summaryrefslogtreecommitdiffstats
path: root/src/mtab.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-06-24 12:00:22 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-06-24 12:06:12 -0400
commit5c3572dc323527a5c168cc12a31b730e0749002d (patch)
tree9430894bcd1759823b956515b8397294f984c1f5 /src/mtab.c
parent93749993508eaa9035dbcb005f960bc0b64752f0 (diff)
downloadbfs-5c3572dc323527a5c168cc12a31b730e0749002d.tar.xz
Unify macro naming conventions
In particular, macros that decide whether to use a particular API/ dependency should be spelled BFS_USE_*, and should be configurable.
Diffstat (limited to 'src/mtab.c')
-rw-r--r--src/mtab.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/mtab.c b/src/mtab.c
index e5c25ba..384fdfc 100644
--- a/src/mtab.c
+++ b/src/mtab.c
@@ -14,22 +14,22 @@
#include <string.h>
#include <sys/types.h>
-#if BFS_USE_MNTENT_H
-# define BFS_MNTENT 1
-#elif BSD
-# define BFS_MNTINFO 1
-#elif __SVR4
-# define BFS_MNTTAB 1
+#if !defined(BFS_USE_MNTENT) && BFS_USE_MNTENT_H
+# define BFS_USE_MNTENT true
+#elif !defined(BFS_USE_MNTINFO) && BSD
+# define BFS_USE_MNTINFO true
+#elif !defined(BFS_USE_MNTTAB) && __SVR4
+# define BFS_USE_MNTTAB true
#endif
-#if BFS_MNTENT
+#if BFS_USE_MNTENT
# include <mntent.h>
# include <paths.h>
# include <stdio.h>
-#elif BFS_MNTINFO
+#elif BFS_USE_MNTINFO
# include <sys/mount.h>
# include <sys/ucred.h>
-#elif BFS_MNTTAB
+#elif BFS_USE_MNTTAB
# include <stdio.h>
# include <sys/mnttab.h>
#endif
@@ -45,7 +45,7 @@ struct bfs_mtab_entry {
};
struct bfs_mtab {
- /** The list of mount points. */
+ /** The array of mount points. */
struct bfs_mtab_entry *entries;
/** The basenames of every mount point. */
struct trie names;
@@ -59,7 +59,7 @@ struct bfs_mtab {
/**
* Add an entry to the mount table.
*/
-static int bfs_mtab_add(struct bfs_mtab *mtab, const char *path, const char *type) {
+static inline int bfs_mtab_add(struct bfs_mtab *mtab, const char *path, const char *type) {
struct bfs_mtab_entry entry = {
.path = strdup(path),
.type = strdup(type),
@@ -98,7 +98,7 @@ struct bfs_mtab *bfs_mtab_parse(void) {
int error = 0;
-#if BFS_MNTENT
+#if BFS_USE_MNTENT
FILE *file = setmntent(_PATH_MOUNTED, "r");
if (!file) {
@@ -121,7 +121,7 @@ struct bfs_mtab *bfs_mtab_parse(void) {
endmntent(file);
-#elif BFS_MNTINFO
+#elif BFS_USE_MNTINFO
#if __NetBSD__
typedef struct statvfs bfs_statfs;
@@ -143,7 +143,7 @@ struct bfs_mtab *bfs_mtab_parse(void) {
}
}
-#elif BFS_MNTTAB
+#elif BFS_USE_MNTTAB
FILE *file = xfopen(MNTTAB, O_RDONLY | O_CLOEXEC);
if (!file) {