소스 검색

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')