Linux fakeroot confusion

4.2k views Asked by At

I have lot of confusion over fakeroot utility. I am trying to add a character node to /dev folder to two rootfs. Owner for rootfs_1 is myself whereas owner of second is root.

  1. rootfs_1 owner is Me.
    a. If I do ls -l. I see owner as "Me Me"
    b. I try to create a node using mknod in rootfs_1/dev and it fails.
    c. $fakeroot command goes through.
    d. ls -al. I see owner as root (Which I know is fake)
    e. Now I can create a node in rootfs_1/dev using mknod.
    f. exit
    g. Newly created node has owner as "Me" which I expected.

  2. rootfs_2 owner is root
    a. ls -l. I see owner as "root root"
    b. I try to create a node using mknod in rootfs_2/dev and it fails.(expected)
    c. $fakeroot command goes through.
    d. Now I try to create a node and it fails.

Now, I know the behavior is expected. But I am confused about how fakeroot works and flow of system calls through fakeroot. I think fakeroot does LD_PRELOAD trick.

Can anyone explain little in detail why case 1 works and case 2 fails.

Thanks

1

There are 1 answers

3
AudioBubble On BEST ANSWER

All that fakeroot does is keep track of a "fake" owner for files that are modified while it's active. It doesn't simulate any other filesystem operations, such as file creation, so you still can't create files in a root-owned directory even with it active.