The standard Unix file system provides very basic meta data, such as the owner and the file creation time. For searching files, it would be highly desirable to be able to add additional comments, label the content and to provide display hints. (Services such as MacOSX Spotlight provide such a feature, albeit outside the kernel.)
In this assignment, you will augment the existing Linux file system to add a set of search terms, a color and a media type string.
You could store the additional information either as part of the inode entry or in a separate datastructure. Since extending the inode structure would require creating a new file system, you may find it easier to store this information separately, indexed by the inode number. You can assume that comments and content type are limited to 255 bytes. The content type is a string such as "text/plain" or "application/pdf". You should also record when the information was last changed.
When a file is removed, the additional information should also be deleted.
You will implement two system calls, one to annotate a file, the
other to retrieve the annotation. Your system call
annotate()
should allow somebody who has write permission
to the file to annotate the file:
int annotate(char *filename, int color, char *comments, char *contenttype);
To retrieve the annotation, use
int statx(char *filename, int *color, int comment_length, char *comments, int content_length, char *contenttype);
Here, *_length
contains the length of the buffer that
the caller allocates for this parameter. If there is no additional file
information, the function should return -1 and set errno
.
Your program must check the file permissions and set
errno
accordingly.
The color value is an RGB value, with 8 bits each.
For testing, create a simple user mode program that annotates a file:
annotate filename color comments content-type
The color should be specified as a six-digit hex RGB value, such as 0305ab.
A new program, statx, should display this additional information, such as
statx test.txt Change: Sun Feb 4 16:50:51 2007 Color: #0305ab Comments: helpful hints for OS homework Content: text/plain
If you have time and interest (sorry, no extra credit), you may also want to modify the Linux ls command to use the stored color information instead of the current highlighting algorithm.
You must submit a single file named Your README file should describe what changes you made to the kernel,
how to run your test programs and what the expected output should be.
For each programming part, if your program(s) do not work, you must
submit file named nonworking.txt. Inside this file, you need to
describe what problems you ran into, where your program fails and what
you think are the reasons.
Last updated
by Henning Schulzrinne