浏览代码

storage/reflink: document hardcoded sizeof(int) for FICLONE

One alternative would look like

    import ctypes
    sizeof_int = ctypes.sizeof(ctypes.c_int)
    FICLONE = (1073741824 % 256**sizeof_int) | 37897 | (sizeof_int << 16)

but, even if the above really(?) is a 100% correct Python port of

    $ echo FICLONE | cpp -include linux/fs.h | tail -n 1

it still seems more likely that the ctypes package is somehow buggy
somewhere than for Qubes storage to run on an exotic architecture with
non 32 bit ints (in the foreseeable future).

So just document the baked in assumption.
Rusty Bird 4 年之前
父节点
当前提交
d7478d128b
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      qubes/storage/reflink.py

+ 1 - 1
qubes/storage/reflink.py

@@ -37,7 +37,7 @@ from contextlib import contextmanager, suppress
 
 import qubes.storage
 
-FICLONE = 1074041865        # defined in <linux/fs.h>
+FICLONE = 1074041865        # defined in <linux/fs.h>, assuming sizeof(int)==4
 LOOP_SET_CAPACITY = 0x4C07  # defined in <linux/loop.h>
 LOGGER = logging.getLogger('qubes.storage.reflink')