0

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

Shachar Shemesh
  • 8,193
  • 6
  • 25
  • 57
agent.smith
  • 9,134
  • 9
  • 37
  • 49

1 Answers1

3

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.

  • Hey, why am I able to create a node in first scenario? How come mknod worked with fakeroot? I think I should have put a separate question. What exactly fakeroot does and how does it do? – agent.smith Apr 24 '12 at 00:00
  • Oh yeah: fakeroot also simulates mknod by creating normal files and making them appear as devices. They don't have any of the functionality of device nodes, though -- for instance, you won't be able to read data from a fakeroot-created `/dev/random` device. –  Apr 24 '12 at 00:10
  • Actually, the roadmap for fakeroot-ng is that you could. It's still down the road, though. The idea is that if there is a user readable/writable device with the same major/minor as the fake device you've created, that will be opened instead. – Shachar Shemesh Aug 28 '16 at 08:27