From 508c1a572d633202a220f2902c0d6b4cd1678349 Mon Sep 17 00:00:00 2001 From: Eric DeCosta Date: Tue, 4 Oct 2022 17:32:26 +0000 Subject: fsmonitor: refactor filesystem checks to common interface Provide a common interface for getting basic filesystem information including filesystem type and whether the filesystem is remote. Refactor existing code for getting basic filesystem info and detecting remote file systems to the new interface. Refactor filesystem checks to leverage new interface. For macOS, error-out if the Unix Domain socket (UDS) file is on a remote filesystem. Signed-off-by: Eric DeCosta Signed-off-by: Junio C Hamano --- fsmonitor-path-utils.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 fsmonitor-path-utils.h (limited to 'fsmonitor-path-utils.h') diff --git a/fsmonitor-path-utils.h b/fsmonitor-path-utils.h new file mode 100644 index 0000000000..41edf5b934 --- /dev/null +++ b/fsmonitor-path-utils.h @@ -0,0 +1,26 @@ +#ifndef FSM_PATH_UTILS_H +#define FSM_PATH_UTILS_H + +struct fs_info { + int is_remote; + char *typename; +}; + +/* + * Get some basic filesystem informtion for the given path + * + * The caller owns the storage that is occupied by fs_info and + * is responsible for releasing it. + * + * Returns -1 on error, zero otherwise. + */ +int fsmonitor__get_fs_info(const char *path, struct fs_info *fs_info); + +/* + * Determines if the filesystem that path resides on is remote. + * + * Returns -1 on error, 0 if not remote, 1 if remote. + */ +int fsmonitor__is_fs_remote(const char *path); + +#endif -- cgit v1.2.3