From 821d8706f51730b6ca9f6f7d3f77a2eb27715f4d Mon Sep 17 00:00:00 2001 From: Stanislaw Adaszewski Date: Fri, 1 May 2020 13:10:39 +0200 Subject: [PATCH] Added code to figure out MNAMELEN dynamically as it can apparently change between FreeBSD releases. --- focker/mount.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/focker/mount.py b/focker/mount.py index 64dbd93..5be2d08 100644 --- a/focker/mount.py +++ b/focker/mount.py @@ -16,10 +16,23 @@ from ctypes import Structure, \ ARRAY, \ byref from ctypes.util import find_library +import re +with open('/usr/include/sys/mount.h', 'r') as f: + rx = re.compile('[ \t]') + lines = f.read().split('\n') + lines = [ a.strip() for a in lines \ + if list(filter(lambda b: b, rx.split(a))) [:2] == \ + [ '#define', 'MNAMELEN'] ] + MNAMELEN = int(rx.split(lines[0])[2]) + # print('MNAMELEN:', MNAMELEN) + #line = list(filter(lambda a: \ + # list(filter(lambda b: b, rx.split(a), a)[:2]) == \ + # ['#define', 'MNAMELEN'], f.read().split('\n'))) + #line[0] MFSNAMELEN = 16 -MNAMELEN = 1024 +# MNAMELEN = 1024 class statfs(Structure):