All of lore.kernel.org
 help / color / mirror / Atom feed
* a bit OT: traditional Unix filesystems
@ 2006-09-14 17:05 Payal Rathod
  2006-09-14 17:13 ` Danny Milosavljevic
  2006-09-14 19:43 ` Quinn Harris
  0 siblings, 2 replies; 3+ messages in thread
From: Payal Rathod @ 2006-09-14 17:05 UTC (permalink / raw)
  To: reiserfs-list

Hi,
I have a small OT query on working of traditional filesystem of Unix.
Can someone comment/correct me on the query below?

If i type $ cat /tmp/payal.txt (according to my knowledge) inode of / is 
found out (2) from super-block. From there physical location of "/" is 
read (i.e. the directory entry) and from there inode of tmp is found 
out. Then directory entry of tmp is read and inode of payal.txt is found 
out and then data blocks of that file are read.
Am I correct in this?

Now if tmp is on different partition or harddisk, how will directory 
entry of "?" point it out exactly? As far as I know, directory entry 
contains names and inode number and not the device details, then how 
does it exactly work? I googled a lot for it, but didn't find exact 
answer. Can someone please explain?

With warm regards,
-Payal


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: a bit OT: traditional Unix filesystems
  2006-09-14 17:05 a bit OT: traditional Unix filesystems Payal Rathod
@ 2006-09-14 17:13 ` Danny Milosavljevic
  2006-09-14 19:43 ` Quinn Harris
  1 sibling, 0 replies; 3+ messages in thread
From: Danny Milosavljevic @ 2006-09-14 17:13 UTC (permalink / raw)
  To: reiserfs-list

Hi,

On Thu, 14 Sep 2006 13:05:44 -0400, Payal Rathod wrote:

> Hi,
> I have a small OT query on working of traditional filesystem of Unix.
> Can someone comment/correct me on the query below?
> 
> If i type $ cat /tmp/payal.txt (according to my knowledge) [...]
[unverified by me, and unrelated]

> Now if tmp is on different partition or harddisk, how will directory
> entry of "?" point it out exactly? 

The kernel has a list of mountpoints (see "/proc/<pid>/mounts") per
process. It looks there if path argument starts with one of those, and if
so, passes the path on to the topmost filesystem handler for that
mountpoint (it also knows the device, it is part of the mountpoint list).

> As far as I know, directory entry
> contains names and inode number and not the device details, then how
> does it exactly work? 

For mountpoints, the kernel checks the mountpoint table (in kernel memory,
per process) before passing the request on to the (topmost) filesystem that
handles that prefix (which reads the directory entry and fetches the inode
mentioned there).

cheers, 
  Danny


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: a bit OT: traditional Unix filesystems
  2006-09-14 17:05 a bit OT: traditional Unix filesystems Payal Rathod
  2006-09-14 17:13 ` Danny Milosavljevic
@ 2006-09-14 19:43 ` Quinn Harris
  1 sibling, 0 replies; 3+ messages in thread
From: Quinn Harris @ 2006-09-14 19:43 UTC (permalink / raw)
  To: reiserfs-list; +Cc: Payal Rathod

Payal

All file operations pass through the linux VFS (virtual file system).  When a 
process requests a file operation, the kernel VFS code will traverse the tree 
of dentries starting at the root or current working directory dentry.  If it 
hits a point where there is no dentry, VFS will ask the file system to 
produce one with info that file system needs to relate the dentry to the data 
on the file system (usually includes reference to the inode).  So if we 
open("/tmp/paypal.txt") the vfs will look for a 'tmp' dentry that is a child 
of the root dentry.  Then look for a 'paypat.txt' dentry.  From that, VFS 
will call the file system to open the file for the specified dentry.

When you mount a file system, VFS will find the dentry associated with the 
directory you are mounting the new fs at.  Then get a dentry for the root of 
the new file system.  Then essentially swap them out.  So when the VFS 
traverses the dentries it will traverse right onto the dentry for the other 
file system.  That isn't really correct, there is a bump through a vfsmount 
structure, but that's the basic theme.  
Namespaces allowing different process to see different view of the file 
system also complicate the matter a bit.

Try googling "linux vfs"

If you really want to know "exactly" how it works, look at the code.  
Documentation/filesystems/vfs.txt 
include/linux/dcache.h include/linux/mount.h include/linux/fs.h fs/namei.c 
fs/namespaces.c are some places to start.  



On Thursday 14 September 2006 11:05, Payal Rathod wrote:
> Hi,
> I have a small OT query on working of traditional filesystem of Unix.
> Can someone comment/correct me on the query below?
>
> If i type $ cat /tmp/payal.txt (according to my knowledge) inode of / is
> found out (2) from super-block. From there physical location of "/" is
> read (i.e. the directory entry) and from there inode of tmp is found
> out. Then directory entry of tmp is read and inode of payal.txt is found
> out and then data blocks of that file are read.
> Am I correct in this?
>
> Now if tmp is on different partition or harddisk, how will directory
> entry of "?" point it out exactly? As far as I know, directory entry
> contains names and inode number and not the device details, then how
> does it exactly work? I googled a lot for it, but didn't find exact
> answer. Can someone please explain?
>
> With warm regards,
> -Payal


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-09-14 19:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-14 17:05 a bit OT: traditional Unix filesystems Payal Rathod
2006-09-14 17:13 ` Danny Milosavljevic
2006-09-14 19:43 ` Quinn Harris

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.