Created
April 7, 2020 02:58
-
-
Save droberson/562c57377f60cea61f63c76b859d9594 to your computer and use it in GitHub Desktop.
example to get attributes of files (lsattr) with python.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import fcntl | |
from array import array | |
# https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/fs.h | |
FS_IOC_GETFLAGS = 0x80086601 | |
f = os.open("/bin/ls", os.O_RDONLY) | |
arg = array('L', [0]) | |
fcntl.ioctl(f, FS_IOC_GETFLAGS, arg, True) | |
print(hex(arg[0])) | |
os.close(f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment