Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 1443  / 2 Years ago, tue, july 26, 2022, 7:18:45

I am creating a program that takes a hexdump of a file, so that I can then transmit that somewhere, and have the file reconstructed, however the hexdump is only of the file contents, I also need to get the file properties, so where do I get the properties of that file, and then apply them to the new file that I create from that hexdump? I am using bash for this, but it's not really about the code, but more about where to find it, although you could it's about the code because obviously I am going to need some commands. I am running Ubuntu GNOME 15.04, with GNOME Shell, and GNOME 3.16.


More From » gnome

 Answers
0

File attributes are stored in inodes. The attributes that each inode stores are listed in POSIX Inode Specification. When we use ls -l or stat or any other program that get us the file attribute uses the stat(2) system call underneath.



Now inodes are filesystem dependent property, they are created as fixed numbers when the filesystem is created. There is a program dumpe2fs to read the superblock of a ext* filesystem so that we can get some idea e.g. :



sudo dumpe2fs -h /dev/sda1


Now let's check the inode related properties:



$ sudo dumpe2fs -h /dev/sda1 | grep -i 'inode.*:'

Inode count: 9379840
Free inodes: 9297243
Inodes per group: 8192
Inode blocks per group: 512
First inode: 11
Inode size: 256
Journal inode: 8


As you can see you get enough info like first inode, inode size, inode count etc. If you do a multiplication of Inode count and Inode size you get how much is reserved for the inodes.



File copying programs such as cp or rsync have the -a (archive) option to copy the attributes stored on the inode for a file, so you need to look for those or similar options available in the program you are likely to use.



For preserving attributes of files and then use it later you can check this answer from mighty Gilles.


[#18614] Thursday, July 28, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
scusaper

Total Points: 335
Total Questions: 111
Total Answers: 119

Location: Belize
Member since Mon, Jun 20, 2022
2 Years ago
;