Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports
Path: blob/main/filesystems/amazon-efs-utils/files/patch-src_watchdog_____init____.py
46590 views
1
--- src/watchdog/__init__.py.orig 2026-04-17 08:53:05 UTC
2
+++ src/watchdog/__init__.py
3
@@ -60,7 +60,7 @@ FS_PREFIX = "fs-"
4
SERVICE = "elasticfilesystem"
5
FS_PREFIX = "fs-"
6
7
-CONFIG_FILE = "/etc/amazon/efs/efs-utils.conf"
8
+CONFIG_FILE = "/usr/local/etc/amazon/efs/efs-utils.conf"
9
CONFIG_SECTION = "mount-watchdog"
10
MOUNT_CONFIG_SECTION = "mount"
11
CLIENT_INFO_SECTION = "client-info"
12
@@ -79,7 +79,7 @@ EFS_SERVICE_NAME = "elasticfilesystem"
13
14
DEFAULT_NFS_PORT = "2049"
15
EFS_SERVICE_NAME = "elasticfilesystem"
16
-PRIVATE_KEY_FILE = "/etc/amazon/efs/privateKey.pem"
17
+PRIVATE_KEY_FILE = "/usr/local/etc/amazon/efs/privateKey.pem"
18
DEFAULT_REFRESH_SELF_SIGNED_CERT_INTERVAL_MIN = 60
19
DEFAULT_STUNNEL_HEALTH_CHECK_INTERVAL_MIN = 5
20
DEFAULT_STUNNEL_HEALTH_CHECK_TIMEOUT_SEC = 30
21
@@ -742,7 +742,64 @@ def get_current_local_nfs_mounts(mount_file="/proc/mou
22
"""
23
mounts = []
24
25
- if not check_if_running_on_macos():
26
+ if sys.platform.startswith("freebsd"):
27
+ # FreeBSD: no /proc/mounts, and neither mount(8) nor nfsstat(8) exposes
28
+ # the NFS client's TCP port. Use the watchdog's own state files as the
29
+ # source of truth: each mount created by mount.efs has a state file
30
+ # fs-<id>.<mountpoint-with-slashes-as-dots>.<port>
31
+ # in STATE_FILE_DIR. Cross-check with `mount -t nfs` so we skip state
32
+ # files whose mountpoint has already been unmounted. Keying off the
33
+ # state file (not the live proxy) lets the watchdog notice a dead
34
+ # efs-proxy and restart it.
35
+ live_mps = set()
36
+ try:
37
+ process = subprocess.run(
38
+ ["mount", "-t", "nfs"],
39
+ check=True,
40
+ stdout=subprocess.PIPE,
41
+ universal_newlines=True,
42
+ )
43
+ for line in process.stdout.splitlines():
44
+ parts = line.split()
45
+ if len(parts) >= 3 and parts[1] == "on":
46
+ live_mps.add(parts[2])
47
+ except Exception as e:
48
+ logging.warning("Unable to list NFS mounts: %s", e)
49
+
50
+ if live_mps:
51
+ try:
52
+ state_files = os.listdir(STATE_FILE_DIR)
53
+ except OSError:
54
+ state_files = []
55
+ seen = set()
56
+ for sf in state_files:
57
+ if not sf.startswith("fs-"):
58
+ continue
59
+ if sf.endswith("+") or "stunnel-config" in sf:
60
+ continue
61
+ # fs-<id>.<mountpoint-with-slashes-as-dots>.<port>
62
+ stem_port = sf.rsplit(".", 1)
63
+ if len(stem_port) != 2:
64
+ continue
65
+ stem, port = stem_port
66
+ try:
67
+ int(port)
68
+ except ValueError:
69
+ continue
70
+ inner = stem[len("fs-"):]
71
+ if "." not in inner:
72
+ continue
73
+ _, _, mp_enc = inner.partition(".")
74
+ mp = "/" + mp_enc.replace(".", "/")
75
+ if mp not in live_mps or (mp, port) in seen:
76
+ continue
77
+ seen.add((mp, port))
78
+ mounts.append(
79
+ Mount._make(
80
+ ["127.0.0.1:/", mp, "nfs", "port=" + port, 0, 0]
81
+ )
82
+ )
83
+ elif not check_if_running_on_macos():
84
with open(mount_file) as f:
85
for mount in f:
86
try:
87
88