def __init__(self, args, lfs_globals):
super().__init__(args, lfs_globals)
(head, tail) = os.path.split(args.shadow_file)
assert os.path.isdir(head), 'No such directory %s' % head
try:
probe = tempfile.TemporaryFile(dir=head)
probe.close()
except OSError as e:
raise RuntimeError('%s is not writeable' % head)
if os.path.isfile(args.shadow_file):
fd = os.open(args.shadow_file, os.O_RDWR)
else:
fd = os.open(args.shadow_file, os.O_RDWR | os.O_CREAT)
size = lfs_globals['nvm_bytes_total']
os.ftruncate(fd, size)
self._shadow_fd = fd
# Compare node requirements to actual file size
statinfo = os.stat(args.shadow_file)
assert self._S_IFREG_URW == self._S_IFREG_URW & statinfo.st_mode, \
'%s is not RW'
assert statinfo.st_size >= lfs_globals['nvm_bytes_total']
args.aperture_base = 0
args.aperture_size = statinfo.st_size
args.addr_mode = self._MODE_FALLBACK
super().__init__(args, lfs_globals)
# open(), create(), release() only do caching as handled by superclass
评论列表
文章目录