From: robk-tahoe Date: Mon, 20 Oct 2008 14:30:52 +0000 (-0700) Subject: fuse/blackmatch: fix platform specific problems in repr_flags X-Git-Url: https://git.rkrishnan.org/pf/content/en/service/module-simplejson.encoder.html?a=commitdiff_plain;h=e0fb7735bc675b03fb7feb3379c847768ac8dece;p=tahoe-lafs%2Ftahoe-lafs.git fuse/blackmatch: fix platform specific problems in repr_flags the repr_flags debug/logging function had a list of fields from the os module that might be passed into an open() call, but it included at least one which was available on the mac but not on linux. symmetrically linux has numerous flags which are not present on the mac. the repr_flags function is now tolerant of flags not being present, and has an expanded list of flags --- diff --git a/contrib/fuse/impl_c/blackmatch.py b/contrib/fuse/impl_c/blackmatch.py index 322df4e2..c45c0ae8 100644 --- a/contrib/fuse/impl_c/blackmatch.py +++ b/contrib/fuse/impl_c/blackmatch.py @@ -194,11 +194,13 @@ def repr_mode(mode=None): def repr_flags(flags=None): if flags is None: return 'none' - fields = ['O_WRONLY', 'O_RDWR', 'O_NONBLOCK', 'O_APPEND', 'O_CREAT', 'O_TRUNC', 'O_EXCL', 'O_SHLOCK', 'O_EXLOCK', 'O_NOFOLLOW'] + fields = [ 'O_APPEND', 'O_CREAT', 'O_DIRECT', 'O_DIRECTORY', 'O_EXCL', 'O_EXLOCK', + 'O_LARGEFILE', 'O_NDELAY', 'O_NOCTTY', 'O_NOFOLLOW', 'O_NONBLOCK', 'O_RDWR', + 'O_SHLOCK', 'O_SYNC', 'O_TRUNC', 'O_WRONLY', ] ret = [] for field in fields: - fval = getattr(os, field) - if (flags & fval) == fval: + fval = getattr(os, field, None) + if fval is not None and (flags & fval) == fval: ret.append(field) if not ret: ret = ['O_RDONLY']