I am in a project where I need to do some book-keeping i.e to indicate whether a particular file has been accessed by a program A. I plan to store this information in the inode as using other additional datastructure would be inefficient. I plan to reuse the field i_mode in the inode datastructure. Any suggestions. Moreover I don't know how to write to the inode data structure from user space. How do I do that? thanks...
Asked
Active
Viewed 228 times
0
-
3To me, this sounds like absolutely the wrong way to solve the problem you describe. – NPE Jul 08 '11 at 06:44
3 Answers
1
The file system looks after the inode; it won't even let super-user modify the inode directly (though root can always access the unmounted (block or character) device to change it).
Unless you write code to modify the file system - a kernel module - you will not be able to do as you wish. Find another way to do it.

Jonathan Leffler
- 730,956
- 141
- 904
- 1,278
1
File system is not designed to solve users problem. You want bookkeeping changed files, other want bookkeeping of new/deleted files.
I see only the following options:
- inotify
- keep status of interested files/directories and check for changes once a time
Just for fun you can consider:
- kernel module
- implement your own file system

dimba
- 26,717
- 34
- 141
- 196
-1
After a bit of googling around saw that the "sticky bit" is not much in use today and we can use it as well as modify it from user space.

Lipika Deka
- 3,774
- 6
- 43
- 56
-
This still sounds like the wrong solution to me. Be aware that any sysadmin who uses octal permissions to chmod your files will unset your sticky bit. You should also be aware that a future version of the operating system may re-use the sticky bit for its own purposes. NetBSD currently has the sticky bit marked as 'Reserved for future use' – Steve Weet Jul 12 '11 at 06:31