Re: How to extend struct stat?

Matti Aarnio (matti.aarnio@sonera.fi)
Thu, 14 Oct 1999 23:29:48 +0300


On Thu, Oct 14, 1999 at 07:16:43PM +0200, Jamie Lokier wrote:
> Alan Cox wrote:
> [about d_type field in dirent]
> > If the LFS stuff goes in as planned before the freeze it does have to
> > change the stat structure for stat64 at least. Perhaps this is an
> > opportunity to do both in one ?
>
> This change doesn't have anything to do with stat as such. But IMO, it
> would be a very logical to do it at the same time.
>
> I will code up a patch that adds this:
>
> - New struct dirent that matches the one in glibc.
>
> - getdirentries syscall.

Have a look at my LFS patches. There syscall is already
there as: getdents64.

ftp://mea.tmt.tele.fi/linux/LFS/

+/*
+ * New, some-improved getdents64() (for LFS) interface.
+ */
+struct linux_dirent64 {
+ __u64 d_ino; /* 64-bit inode */
+ unsigned long d_off; /* Offset within the directory */
+ unsigned short d_reclen;
+ char d_name[1];
+};
+
+struct getdents_callback64 {
+ struct linux_dirent64 * current_dir;
+ struct linux_dirent64 * previous;
+ int count;
+ int error;
+};

That done (after you tell me which fields to add into that dirent),
you have only the glibc side to do... And what parameters to add
to sys_getdents64() syscall.

I have infact wondered, how many of stat64 parameters could be
carried in to supply speeded up processing; mode, size, mtime ?
Full 'struct stat' ? (propably not)

> Like glibc's getdirentries, except that BASEP can be null and
> there's an additional flags argument.
>
> With appropriate flags, glibc's getdirentries will be able to call
> this syscall directly, avoiding the parsing and copying overhead
> and redundant syscalls it does at the moment.
>
> - Flags argument to distinguish:
>
> - d_type or no d_type
> - 32 bit or 64 bit offset.
>
> There's really no gain in the implementation using a separate
> syscall for the 64 bit readdir. However if it's decided it's
> cleaner to use a separate syscall, say so and I'll do it.

fs/readdir.c: sys_getdents() doesn't have user-space
supplied flag parameter to control call behaviour.
D'uh.. Must have separate call.

> -- Jamie

/Matti Aarnio <matti.aarnio@sonera.fi>

-
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/