lkml.org 
[lkml]   [2004]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: The argument for fs assistance in handling archives (was: silent semantic changes with reiser4)
Salut,

On Wed, Sep 01, 2004 at 01:50:56PM -0700, Linus Torvalds wrote:
> #define MAXNAME 1024
> int open_cached_view(int base_fd, char *type, char *subname)
> {
> struct stat st;
> char filename[PATH_MAX];
> char name[MAXNAME];
> int len, cachefd;
>
> if (fstat(base_fd, &st) < 0)
> return -1;
> sprintf(name, "/proc/self/fd/%d", base_fd);
> len = readlink(name, filename, sizeof(filename)-1);
> if (len < 0)
> return -1;
> filename[len] = 0;
>
> /* FIXME! Replace '/' with '#' in "type" and "subname" */
> len = snprintf(name, sizeof(name),
> "%04llx/%04llx/%s/%s/%s",
> (unsigned long long) st.st_dev,
> (unsigned long long) st.st_ino,
> type ? : "default",
> subname,
> filename);
> errno = ENAMETOOLONG;
> if (len >= sizeof(name))
> return -1;
> cachefd = open(name, O_RDONLY);
> if (cachefd >= 0) {
> /* Check mtime here - maybe we could have kernel support */
> return cachefd;
> }
> if (errno != ENOENT)
> return -1;
> /*
> .. try to generate cache file here ..
> */

Around of what I've had in mind. Only that one might use libmagic
instead of the type argument. The rest can be done by a corresponding
MIME plugin.

Tonnerre
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2005-03-22 14:05    [from the cache]
©2003-2011 Jasper Spaans