Parcourir la source

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 il y a 4 ans
Parent
commit
d7478d128b
1 fichiers modifiés avec 1 ajouts et 1 suppressions
  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')