Re: [PATCH] Separate out common fstatat code

From: Christoph Hellwig
Date: Wed Apr 08 2009 - 09:27:47 EST


On Wed, Apr 08, 2009 at 09:54:11AM +0400, Oleg Drokin wrote:
> Hello!
>
> It seems we have way too many copy&pasted fstatat code elsewhere which
> might not have been a problem until now, but with all the changes
> with "stat light" now and who knows what other additions in there in
> the future, it really helps if we have only one copy of the code.
>
> Hence this patch adds fstatat_common() that fills struct kstat with
> proper values and does all the AT flags parsing that's needed and
> then calls all the proper underlying functions, what's left to the
> caller now is to only copy filled out kstat buffer to the final
> destination.

Looks good and like a merge candidate even without any statlite-like
syscall.

But I would call it vfs_fstatat, not fstatat_common.

> --- linux-2.6.29.orig/arch/arm/kernel/sys_oabi-compat.c 2009-04-08 01:31:41.000000000 -0400
> +++ linux-2.6.29/arch/arm/kernel/sys_oabi-compat.c 2009-04-08 01:41:59.000000000 -0400
> @@ -176,20 +176,12 @@
> int flag)
> {
> struct kstat stat;
> + int error;
>
> + error = fstatat_common(dfd, filename, &stat, flag);
> if (!error)
> + error = cp_oldabi_stat64(&stat, statbuf);
>
> return error;

Also a

error = vfs_fstatat(dfd, filename, &stat, flag);
if (error)
return error;
return cp_oldabi_stat64(&stat, statbuf);

would looks slightly cleaner than that.

(Same for the various other duplicates)

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