blob: a38259063517144690122454970f399ae504708e [file] [log] [blame]
Elijah Newren8bff5ca2023-02-24 00:09:20 +00001#include "git-compat-util.h"
Jeff Hostetlera85ad672022-05-26 21:47:01 +00002#include "config.h"
Elijah Newren68d68642023-05-16 06:34:08 +00003#include "fsmonitor-ll.h"
Eric DeCosta508c1a52022-10-04 17:32:26 +00004#include "fsmonitor-ipc.h"
5#include "fsmonitor-settings.h"
6#include "fsmonitor-path-utils.h"
Jeff Hostetler1e7be102022-05-26 21:47:02 +00007
Eric DeCosta508c1a52022-10-04 17:32:26 +00008 /*
Jeff Hostetler1e7be102022-05-26 21:47:02 +00009 * For the builtin FSMonitor, we create the Unix domain socket for the
10 * IPC in the .git directory. If the working directory is remote,
11 * then the socket will be created on the remote file system. This
12 * can fail if the remote file system does not support UDS file types
13 * (e.g. smbfs to a Windows server) or if the remote kernel does not
14 * allow a non-local process to bind() the socket. (These problems
15 * could be fixed by moving the UDS out of the .git directory and to a
16 * well-known local directory on the client machine, but care should
17 * be taken to ensure that $HOME is actually local and not a managed
18 * file share.)
19 *
Eric DeCosta508c1a52022-10-04 17:32:26 +000020 * FAT32 and NTFS working directories are problematic too.
Jeff Hostetlerddc5dac2022-05-26 21:47:04 +000021 *
22 * The builtin FSMonitor uses a Unix domain socket in the .git
23 * directory for IPC. These Windows drive formats do not support
24 * Unix domain sockets, so mark them as incompatible for the daemon.
25 *
Jeff Hostetler1e7be102022-05-26 21:47:02 +000026 */
Eric DeCosta508c1a52022-10-04 17:32:26 +000027static enum fsmonitor_reason check_uds_volume(struct repository *r)
Jeff Hostetler1e7be102022-05-26 21:47:02 +000028{
Eric DeCosta508c1a52022-10-04 17:32:26 +000029 struct fs_info fs;
Eric DeCosta6beb2682022-10-04 17:32:27 +000030 const char *ipc_path = fsmonitor_ipc__get_path(r);
Eric DeCosta508c1a52022-10-04 17:32:26 +000031 struct strbuf path = STRBUF_INIT;
32 strbuf_add(&path, ipc_path, strlen(ipc_path));
Jeff Hostetler1e7be102022-05-26 21:47:02 +000033
Eric DeCosta508c1a52022-10-04 17:32:26 +000034 if (fsmonitor__get_fs_info(dirname(path.buf), &fs) == -1) {
35 strbuf_release(&path);
Jeff Hostetler1e7be102022-05-26 21:47:02 +000036 return FSMONITOR_REASON_ERROR;
37 }
38
Eric DeCosta508c1a52022-10-04 17:32:26 +000039 strbuf_release(&path);
Jeff Hostetler1e7be102022-05-26 21:47:02 +000040
Eric DeCosta508c1a52022-10-04 17:32:26 +000041 if (fs.is_remote ||
42 !strcmp(fs.typename, "msdos") ||
43 !strcmp(fs.typename, "ntfs")) {
44 free(fs.typename);
Jeff Hostetlerddc5dac2022-05-26 21:47:04 +000045 return FSMONITOR_REASON_NOSOCKETS;
Eric DeCosta508c1a52022-10-04 17:32:26 +000046 }
Jeff Hostetlerddc5dac2022-05-26 21:47:04 +000047
Eric DeCosta508c1a52022-10-04 17:32:26 +000048 free(fs.typename);
Jeff Hostetler1e7be102022-05-26 21:47:02 +000049 return FSMONITOR_REASON_OK;
50}
Jeff Hostetlera85ad672022-05-26 21:47:01 +000051
Eric DeCosta8f449762022-10-04 17:32:28 +000052enum fsmonitor_reason fsm_os__incompatible(struct repository *r, int ipc)
Jeff Hostetlera85ad672022-05-26 21:47:01 +000053{
Jeff Hostetler1e7be102022-05-26 21:47:02 +000054 enum fsmonitor_reason reason;
55
Eric DeCosta8f449762022-10-04 17:32:28 +000056 if (ipc) {
57 reason = check_uds_volume(r);
58 if (reason != FSMONITOR_REASON_OK)
59 return reason;
60 }
Jeff Hostetler1e7be102022-05-26 21:47:02 +000061
Jeff Hostetlera85ad672022-05-26 21:47:01 +000062 return FSMONITOR_REASON_OK;
63}