Hi,
> I am trying to implement encryption for filesystem
> I want to implement a system call in FS server that appends data
> ( key ) to a key file(common to all users)
> I don't want user process to gain access to the file, however I want
> to allow him to write a key value onto
> key file ,so i have decided to put it into a system call in FS server
If you store the keys in plaintext encryption is pretty pointless. One
can still decrypt the contents of the disk without the password by
booting another OS, like Linux or even the MINIX installation CD. It
doesn't matter from the OS itself either, as the rot user can read to
file through /dev/c0d#p#s# while non-root users can be prevented from
reading the file simply by setting Unix permissions correctly. Relying
on a hidden file is a bad design.
> I have written a handler in FS/protect.c
> wherein i open ,lseek to end of file,write ,then close file
>
> however write call is not functioning as expected
> it simply appends as many 0's to end of file as the number of
> characters i wanted to write
> here is the code
>
> I am changing the input message and calling other handlers
> in below code i want to append "aa" in /keys file
> but it appended 3 nuls instead
These calls are meant to be called by other processes, not from within
FS. Don't expect them to be reliable. Instead, add a separate server
to do the encryption. If you have a MINIX with VFS (>= 3.1.3) you
could for example try to insert such a server between VFS and MFS.
This way you can rely on the MFS calls, which I think is enough for
your purposes. I have no experience with VFS, but documentation is
found on the Wiki (
http://wiki.minix3.org/en/DevelopersGuide/
VfsFsProtocol).
With kind regards,
Erik