Elijah Newren | 8bff5ca | 2023-02-24 00:09:20 +0000 | [diff] [blame] | 1 | #include "git-compat-util.h" |
Jeff Hostetler | a85ad67 | 2022-05-26 21:47:01 +0000 | [diff] [blame] | 2 | #include "config.h" |
Elijah Newren | 68d6864 | 2023-05-16 06:34:08 +0000 | [diff] [blame] | 3 | #include "fsmonitor-ll.h" |
Eric DeCosta | 508c1a5 | 2022-10-04 17:32:26 +0000 | [diff] [blame] | 4 | #include "fsmonitor-ipc.h" |
| 5 | #include "fsmonitor-settings.h" |
| 6 | #include "fsmonitor-path-utils.h" |
Jeff Hostetler | 1e7be10 | 2022-05-26 21:47:02 +0000 | [diff] [blame] | 7 | |
Eric DeCosta | 508c1a5 | 2022-10-04 17:32:26 +0000 | [diff] [blame] | 8 | /* |
Jeff Hostetler | 1e7be10 | 2022-05-26 21:47:02 +0000 | [diff] [blame] | 9 | * 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 DeCosta | 508c1a5 | 2022-10-04 17:32:26 +0000 | [diff] [blame] | 20 | * FAT32 and NTFS working directories are problematic too. |
Jeff Hostetler | ddc5dac | 2022-05-26 21:47:04 +0000 | [diff] [blame] | 21 | * |
| 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 Hostetler | 1e7be10 | 2022-05-26 21:47:02 +0000 | [diff] [blame] | 26 | */ |
Eric DeCosta | 508c1a5 | 2022-10-04 17:32:26 +0000 | [diff] [blame] | 27 | static enum fsmonitor_reason check_uds_volume(struct repository *r) |
Jeff Hostetler | 1e7be10 | 2022-05-26 21:47:02 +0000 | [diff] [blame] | 28 | { |
Eric DeCosta | 508c1a5 | 2022-10-04 17:32:26 +0000 | [diff] [blame] | 29 | struct fs_info fs; |
Eric DeCosta | 6beb268 | 2022-10-04 17:32:27 +0000 | [diff] [blame] | 30 | const char *ipc_path = fsmonitor_ipc__get_path(r); |
Eric DeCosta | 508c1a5 | 2022-10-04 17:32:26 +0000 | [diff] [blame] | 31 | struct strbuf path = STRBUF_INIT; |
| 32 | strbuf_add(&path, ipc_path, strlen(ipc_path)); |
Jeff Hostetler | 1e7be10 | 2022-05-26 21:47:02 +0000 | [diff] [blame] | 33 | |
Eric DeCosta | 508c1a5 | 2022-10-04 17:32:26 +0000 | [diff] [blame] | 34 | if (fsmonitor__get_fs_info(dirname(path.buf), &fs) == -1) { |
| 35 | strbuf_release(&path); |
Jeff Hostetler | 1e7be10 | 2022-05-26 21:47:02 +0000 | [diff] [blame] | 36 | return FSMONITOR_REASON_ERROR; |
| 37 | } |
| 38 | |
Eric DeCosta | 508c1a5 | 2022-10-04 17:32:26 +0000 | [diff] [blame] | 39 | strbuf_release(&path); |
Jeff Hostetler | 1e7be10 | 2022-05-26 21:47:02 +0000 | [diff] [blame] | 40 | |
Eric DeCosta | 508c1a5 | 2022-10-04 17:32:26 +0000 | [diff] [blame] | 41 | if (fs.is_remote || |
| 42 | !strcmp(fs.typename, "msdos") || |
| 43 | !strcmp(fs.typename, "ntfs")) { |
| 44 | free(fs.typename); |
Jeff Hostetler | ddc5dac | 2022-05-26 21:47:04 +0000 | [diff] [blame] | 45 | return FSMONITOR_REASON_NOSOCKETS; |
Eric DeCosta | 508c1a5 | 2022-10-04 17:32:26 +0000 | [diff] [blame] | 46 | } |
Jeff Hostetler | ddc5dac | 2022-05-26 21:47:04 +0000 | [diff] [blame] | 47 | |
Eric DeCosta | 508c1a5 | 2022-10-04 17:32:26 +0000 | [diff] [blame] | 48 | free(fs.typename); |
Jeff Hostetler | 1e7be10 | 2022-05-26 21:47:02 +0000 | [diff] [blame] | 49 | return FSMONITOR_REASON_OK; |
| 50 | } |
Jeff Hostetler | a85ad67 | 2022-05-26 21:47:01 +0000 | [diff] [blame] | 51 | |
Eric DeCosta | 8f44976 | 2022-10-04 17:32:28 +0000 | [diff] [blame] | 52 | enum fsmonitor_reason fsm_os__incompatible(struct repository *r, int ipc) |
Jeff Hostetler | a85ad67 | 2022-05-26 21:47:01 +0000 | [diff] [blame] | 53 | { |
Jeff Hostetler | 1e7be10 | 2022-05-26 21:47:02 +0000 | [diff] [blame] | 54 | enum fsmonitor_reason reason; |
| 55 | |
Eric DeCosta | 8f44976 | 2022-10-04 17:32:28 +0000 | [diff] [blame] | 56 | if (ipc) { |
| 57 | reason = check_uds_volume(r); |
| 58 | if (reason != FSMONITOR_REASON_OK) |
| 59 | return reason; |
| 60 | } |
Jeff Hostetler | 1e7be10 | 2022-05-26 21:47:02 +0000 | [diff] [blame] | 61 | |
Jeff Hostetler | a85ad67 | 2022-05-26 21:47:01 +0000 | [diff] [blame] | 62 | return FSMONITOR_REASON_OK; |
| 63 | } |