lkml.org 
[lkml]   [1999]   [Jun]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subject[RFC] Open directory as default file - proposal for API
Wolfgang Walter wrote:
> At least in 2.0, you may open a directory and use the filehanlde you
> got later with fstat, fchown, fchmod. It would be rather bad if this
> will change.

No problem, it can be compatible:

Use the same attributes for the "default" file as the directory itself.
So really you've opened the directory inode, it's just that reading &
writing work on the associated file.

There are some fiddly issues w.r.t. the file size from fstat() and
whether lseek seeks in the directory or the file.

I'm inclined to say the fstat() should return the associated file size.
(If there isn't one it's a normal directory and the directory's size is
returned). S_ISDIR(st_mode) is true. lseek sets file and directory
position simultaneously, limited by max(dir_size,file_size) and SEEK_END
is relative to the file end. (No app will readdir() and read() the same
thing).

But if it's opened with O_DIRECTORY, none of this happens: you always
get the directory's size, reading & writing return EISDIR, and lseek()
position is limited by the directory size.

Ok it's a bit ugly but it does mean you can do this metadata stuff in a
neat way without breaking old code :-)

-- Jamie

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:52    [from the cache]
©2003-2011 Jasper Spaans