Skip to contentSkip to conversation

opening files

DISCUSSION luc deschenaux 2 participants 2 messages Nov 6, 2003 – Nov 7, 2003 VFS

lore
Share & tools
lore
#0 lore raw

maybe somebody did it already, knows where i need to do it, or has something to say about it; so while i start looking how to implement the functionality described below, i post a message here

When booting from a livecd, the empty directory tree is duplicated in a tmpfs partition and all the cdrom files are linked in it

If a process need to open a file with write permission you have to remove the link in ramdisk and replace it with the real file from the cd at user level

I'm looking to patch the kernel or libraries so that when a process try to open such linked file with write permission, the kernel or library replace the link in ramdisk with the real file from cd before opening it and returning the file descriptor instead of a "permission denied" error.

infos and suggestions welcome

regards,

Luc

#1 lore raw
Quoted 11 lines · luc deschenaux

maybe somebody did it already, knows where i need to do it, or has something to say about it; so while i start looking how to implement the functionality described below, i post a message here

When booting from a livecd, the empty directory tree is duplicated in a tmpfs partition and all the cdrom files are linked in it

If a process need to open a file with write permission you have to remove the link in ramdisk and replace it with the real file from the cd at user level

Quoted 6 lines

I'm looking to patch the kernel or libraries so that when a process try to open such linked file with write permission, the kernel or library replace the link in ramdisk with the real file from cd before opening it and returning the file descriptor instead of a "permission denied" error.

infos and suggestions welcome

It's doable from a library and it even does not need to make any links at all. You can use the LD_PRELOAD mechanizm to replace the open function with version that would:
* Look if the file exists in tmpfs.
* If write permissions are needed, copy it; otherwise just replace the name by appropriate name on the CD.
* Open the file.

In kernel, you could write a "cow" filesystem driver. It is however much more complicated than replacing libc's open call. It might be useful to look at umlinux ubd (user block device) driver.

It might be that union mounts solve this or are at least some help. However, I am not sure they are implemented (in 2.6; no such thing in 2.4) and what they can actualy do.

-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <[email protected]>