]> git.ipfire.org Git - thirdparty/git.git/blob - compat/fsmonitor/fsm-settings-darwin.c
t9001: fix indentation in test_no_confirm()
[thirdparty/git.git] / compat / fsmonitor / fsm-settings-darwin.c
1 #include "config.h"
2 #include "fsmonitor.h"
3 #include "fsmonitor-ipc.h"
4 #include "fsmonitor-settings.h"
5 #include "fsmonitor-path-utils.h"
6
7 /*
8 * For the builtin FSMonitor, we create the Unix domain socket for the
9 * IPC in the .git directory. If the working directory is remote,
10 * then the socket will be created on the remote file system. This
11 * can fail if the remote file system does not support UDS file types
12 * (e.g. smbfs to a Windows server) or if the remote kernel does not
13 * allow a non-local process to bind() the socket. (These problems
14 * could be fixed by moving the UDS out of the .git directory and to a
15 * well-known local directory on the client machine, but care should
16 * be taken to ensure that $HOME is actually local and not a managed
17 * file share.)
18 *
19 * FAT32 and NTFS working directories are problematic too.
20 *
21 * The builtin FSMonitor uses a Unix domain socket in the .git
22 * directory for IPC. These Windows drive formats do not support
23 * Unix domain sockets, so mark them as incompatible for the daemon.
24 *
25 */
26 static enum fsmonitor_reason check_uds_volume(struct repository *r)
27 {
28 struct fs_info fs;
29 const char *ipc_path = fsmonitor_ipc__get_path(r);
30 struct strbuf path = STRBUF_INIT;
31 strbuf_add(&path, ipc_path, strlen(ipc_path));
32
33 if (fsmonitor__get_fs_info(dirname(path.buf), &fs) == -1) {
34 strbuf_release(&path);
35 return FSMONITOR_REASON_ERROR;
36 }
37
38 strbuf_release(&path);
39
40 if (fs.is_remote ||
41 !strcmp(fs.typename, "msdos") ||
42 !strcmp(fs.typename, "ntfs")) {
43 free(fs.typename);
44 return FSMONITOR_REASON_NOSOCKETS;
45 }
46
47 free(fs.typename);
48 return FSMONITOR_REASON_OK;
49 }
50
51 enum fsmonitor_reason fsm_os__incompatible(struct repository *r, int ipc)
52 {
53 enum fsmonitor_reason reason;
54
55 if (ipc) {
56 reason = check_uds_volume(r);
57 if (reason != FSMONITOR_REASON_OK)
58 return reason;
59 }
60
61 return FSMONITOR_REASON_OK;
62 }