'mount' command permissions retention
I created a filesystem on file 'file.img' formatted with ext4, a mountpoint 'temp/' in the current directory.
Commands Issued Code:
$ dd if=/dev/urandom of=file.img bs=1024 count=10000 Code:
$ sudo chmod 757 temp/ Code:
$ sudo umount temp Code:
$ sudo mount file.img temp Where mount (or linux) store information what permission to give to a mountpoint when it is mounted? |
When you have mount point, chmod refers to the filesystem so mounted. When dismounted, the file reference returns to what it was BEFORE the mount.
When you remounted the filesystem, the access modes are from the chmod done when it was originally mounted. One way to think about this is that the directory file reference (in memory) contains two parts - the name, and its location in the directory tree... The other half is an inode reference containing the connection to the contents of the directory (the inode carries the access mode). When you mount a filesystem onto a directory, the top half (the one with the name and location in the directory tree) remains unchanged... But the other half is replaced by a reference to the now mounted filesystem, which has the inode of the root directory of that filesystem. And that inode has the access mode for the filesystem, which is now visible due to the mount. The original access mode is covered up. It is still in the system buffers though, so when you dismount the filesystem the original inode reference is restored, and the original access mode is visible again. When you change the access mode while a filesystem is mounted, the change is done to the inode from that mounted filesystem. So a dismount restores the visibility of the original mode. The inode from the previously mounted filesystem carries the access mode that was changed. |
If you add the mount to /etc/fstab with the option users you can do the mount as the user and it will have the permissions of the user. You can also pass -o users to the mount command as root. Just bear in mind that ext4 is a filesystem who's only default permissions belong to root (aka / + lost+found). So you'd have to mount it, and change the permissions to be written to by the user, before it would be of any use to a user. Also on my system, mkfs.ext4 is not available to userland (debian defaults).
|
Dear jpollard,
Quote:
Quote:
Quote:
"The temp/ after mount become root of the mounted filesystem, and hence when I am changing permissions after mount then the permissions are changed for the root of file.img, and not the actual temp/ directory created. Hence comes the two different inodes. The inode of file.img is changed, while the inode of temp/ directory before mount is not." Please let me know if I have got it correctly (as I do not know much about inodes, except that they are some kind of references to files). Thanks Shadow_7, But I was just trying to find out how the changed permissions of root of filesystem was retained in second mount which I think is answered by jpollard if I have been able to understand him/her correctly. |
The only error is the "inode of file.img" which isn't involved - the inode being modified by the chmod is from the root inode of the filesystem WITHIN the file.img file. The inode data is stored in the file.
The inode OF the "file.img" is not touched other than when mounting the file to locate where the data for the filesystem being mounted resides. |
OK I got it, it is inode of root inside filesystem and not 'file.img'.
Errata: Quote:
Quote:
|
All times are GMT -5. The time now is 07:35 PM. |