public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Luca Di Maio <luca.dimaio1@gmail.com>
Cc: linux-xfs@vger.kernel.org, dimitri.ledkov@chainguard.dev,
	smoser@chainguard.dev
Subject: Re: [PATCH RFC 1/2] xfs_proto: add origin also for directories, chardevs and symlinks
Date: Wed, 16 Apr 2025 09:07:59 -0700	[thread overview]
Message-ID: <20250416160759.GH25675@frogsfrogsfrogs> (raw)
In-Reply-To: <20250416144400.940532-2-luca.dimaio1@gmail.com>

On Wed, Apr 16, 2025 at 04:43:32PM +0200, Luca Di Maio wrote:
> In order to preserve timestamps when populating target filesystem, we
> need to have a reference to the original file.
> 
> This is already done with regular files, we extend this to dirs,
> symlinks and chardevices.
> 
> Excerpt of old protofile:
> 
> ```
> /
> 0 0
> d--755 0 0
> : Descending path rootfs
>  bin   l--777 0 0 usr/bin
>  lib64 l--777 0 0 lib
>  sbin  l--777 0 0 usr/bin
>  dev d--755 0 0
>   console c--620 0 0 5 1
>   null    c--666 0 0 1 3
>   random  c--666 0 0 1 8
>   urandom c--666 0 0 1 9
>   zero    c--666 0 0 1 5
>  $
>  lib d--755 0 0
>   ld-linux-x86-64.so.2   ---755 0 0 rootfs/lib/ld-linux-x86-64.so.2
> ```
> 
> Excerpt of new protofile:
> 
> ```
> /
> 0 0
> d--755 65534 65534 rootfs
> : Descending path rootfs
>  bin   l--777 65534 65534 usr/bin rootfs/bin
>  lib64 l--777 65534 65534 lib rootfs/lib64
>  sbin  l--777 65534 65534 usr/bin rootfs/sbin
>  $
>  dev d--755 65534 65534 rootfs/dev
>   console c--620 65534 65534 5 1 rootfs/dev/console
>   null    c--666 65534 65534 1 3 rootfs/dev/null
>   random  c--666 65534 65534 1 8 rootfs/dev/random
>   urandom c--666 65534 65534 1 9 rootfs/dev/urandom
>   zero    c--666 65534 65534 1 5 rootfs/dev/zero

The trouble is, this new field     ^^^^^^^^^^^^^^^ will break parsers,
which I'll talk about in the next email.

--D

>  $
>  lib d--755 0 0 rootfs/lib
>   ld-linux-x86-64.so.2   ---755 0 0 rootfs/lib/ld-linux-x86-64.so.2
> ```
> 
> Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
> ---
>  mkfs/xfs_protofile.in | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/mkfs/xfs_protofile.in b/mkfs/xfs_protofile.in
> index e83c39f..066265b 100644
> --- a/mkfs/xfs_protofile.in
> +++ b/mkfs/xfs_protofile.in
> @@ -51,12 +51,12 @@ def stat_to_str(statbuf):
>  def stat_to_extra(statbuf, fullpath):
>  	'''Compute the extras column for a protofile.'''
> 
> -	if stat.S_ISREG(statbuf.st_mode):
> +	if stat.S_ISREG(statbuf.st_mode) or stat.S_ISDIR(statbuf.st_mode):
>  		return ' %s' % fullpath
>  	elif stat.S_ISCHR(statbuf.st_mode) or stat.S_ISBLK(statbuf.st_mode):
> -		return ' %d %d' % (os.major(statbuf.st_rdev), os.minor(statbuf.st_rdev))
> +		return ' %d %d %s' % (os.major(statbuf.st_rdev), os.minor(statbuf.st_rdev), fullpath)
>  	elif stat.S_ISLNK(statbuf.st_mode):
> -		return ' %s' % os.readlink(fullpath)
> +		return ' %s %s' % (os.readlink(fullpath), fullpath)
>  	return ''
> 
>  def max_fname_len(s1):
> @@ -105,8 +105,8 @@ def walk_tree(path, depth):
>  		fullpath = os.path.join(path, fname)
>  		sb = os.lstat(fullpath)
>  		extra = stat_to_extra(sb, fullpath)
> -		print('%*s%s %s' % (depth, ' ', fname, \
> -				stat_to_str(sb)))
> +		print('%*s%s %s%s' % (depth, ' ', fname, \
> +				stat_to_str(sb), extra))
>  		walk_tree(fullpath, depth + 1)
> 
>  	if depth > 1:
> @@ -134,7 +134,7 @@ def main():
>  		statbuf = os.stat(args.paths[0])
>  		if not stat.S_ISDIR(statbuf.st_mode):
>  			raise NotADirectoryError(path)
> -		print(stat_to_str(statbuf))
> +		print(stat_to_str(statbuf), args.paths[0])
> 
>  		# All files under each path go in the root dir, recursively
>  		for path in args.paths:
> --
> 2.49.0
> 

  reply	other threads:[~2025-04-16 16:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-16 14:43 [PATCH RFC 0/2] prototype: improve timestamp handling Luca Di Maio
2025-04-16 14:43 ` [PATCH RFC 1/2] xfs_proto: add origin also for directories, chardevs and symlinks Luca Di Maio
2025-04-16 16:07   ` Darrick J. Wong [this message]
2025-04-16 14:43 ` [PATCH RFC 2/2] proto: read origin also for directories, chardevs and symlinks. copy timestamps from origin Luca Di Maio
2025-04-16 16:07   ` Darrick J. Wong
2025-04-17 14:14     ` Luca Di Maio
2025-04-22  3:10 ` [PATCH RFC 0/2] prototype: improve timestamp handling Darrick J. Wong
2025-04-22  6:16   ` Luca Di Maio
2025-04-23 14:46     ` Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250416160759.GH25675@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=dimitri.ledkov@chainguard.dev \
    --cc=linux-xfs@vger.kernel.org \
    --cc=luca.dimaio1@gmail.com \
    --cc=smoser@chainguard.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox