Re: The argument for fs assistance in handling archives (was: silent semantic changes with reiser4)

Tonnerre
2004-09-05T13:20:42Z

[-- Attachment #1: Type: text/plain, Size: 1631 bytes --]

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]