joker
joker

Reputation: 106

Files informations on unix-based file systems

When I create a new file (eg. touch file.txt) its size equals to 0B. I'm wondering where are its informations (size, last modify date, owner name, file name) stored. These informations are stored on hd and are managed by kernel, of course, but I'd love to know something more about them: Where and how I may get them, using a programming language as C, for example, and how I may change them. Are these informations changeable, simply using a programming language, or maybe kernel avoids this operations?

I'm working on Unix based file systems, and I'm asking informations especially about this fs.

Upvotes: 0

Views: 119

Answers (3)

thiton
thiton

Reputation: 36049

The metadata such as owner, size and dates are usually stored in a structure called index-node (inode), which resides in the filesystem's superblock.

Upvotes: 0

nos
nos

Reputation: 229058

On unix system, they're traditionally stored in the metadata part of a file representation called an inode

You can fetch this information with the stat() call, see these fields, you can change the owner and permissions with chown() and chmod()

Upvotes: 3

mah
mah

Reputation: 39797

This information is retrievable using the stat() function (and others in its family). Where it's stored is up to the specific file system and for what should be obvious reasons, you cannot change them unless you have raw access to the drive -- and that should be avoided unless you're ok with losing everything on that drive.

Upvotes: 2

Related Questions