patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Demi Marie Obenour <demiobenour@gmail.com>
To: Alyssa Ross <hi@alyssa.is>
Cc: Spectrum OS Development <devel@spectrum-os.org>
Subject: Re: [PATCH 1/3] scripts/make-erofs.sh: Avoid unneeded calls to awk and chmod
Date: Sun, 21 Sep 2025 13:12:51 -0400	[thread overview]
Message-ID: <645da3bf-6c9d-44d9-baab-cafd4de6e3bc@gmail.com> (raw)
In-Reply-To: <87plbj4w9q.fsf@alyssa.is>


[-- Attachment #1.1.1: Type: text/plain, Size: 3036 bytes --]

On 9/21/25 12:15, Alyssa Ross wrote:
> Demi Marie Obenour <demiobenour@gmail.com> writes:
> 
>> On 9/21/25 07:31, Alyssa Ross wrote:
>>> Demi Marie Obenour <demiobenour@gmail.com> writes:
>>>
>>>> These calls were made to work around permission problems, but it is much
>>>> cleaner to solve these problems by making every directory in the new
>>>> filesystem image writable so that cp can write to it.
>>>>
>>>> Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
>>>> ---
>>>> Hyperfine confirms that this does improve performance, though there are
>>>> outliers.
>>>> ---
>>>>  scripts/make-erofs.sh | 22 +++++++++++-----------
>>>>  1 file changed, 11 insertions(+), 11 deletions(-)
>>>>
>>>> diff --git a/scripts/make-erofs.sh b/scripts/make-erofs.sh
>>>> index b47048ad747bd7dfcc28e0f1dfd75ec090fa7e09..82d37573ad0454e79becfddd05f93585df7b671c 100755
>>>> --- a/scripts/make-erofs.sh
>>>> +++ b/scripts/make-erofs.sh
>>>> @@ -30,18 +30,18 @@ while read -r arg1; do
>>>>  	fi
>>>>  	echo
>>>>  
>>>> -	parent="$(dirname "$arg2")"
>>>> -	awk -v parent="$parent" -v root="$root" 'BEGIN {
>>>> -		n = split(parent, components, "/")
>>>> -		for (i = 1; i <= n; i++) {
>>>> -			printf "%s/", root
>>>> -			for (j = 1; j <= i; j++)
>>>> -				printf "%s/", components[j]
>>>> -			print
>>>> -		}
>>>> -	}' | xargs -rd '\n' chmod +w -- 2>/dev/null || :
>>>> -	mkdir -p -- "$root/$parent"
>>>> +	if [ "$arg2" = / ]; then
>>>> +		cp -RT -- "$arg1" "$root"
>>>> +		# Nix store paths are read-only, so fix up permissions
>>>> +		# so that subsequent copies can write to directories
>>>> +		# created by the above copy.  This means giving all
>>>> +		# directories 0755 permissions.
>>>> +		find "$root" -type d -exec chmod 0755 -- '{}' +
>>>> +		continue
>>>> +	fi
>>>
>>> As I said last time, I don't love that this now only handles the case
>>> where / is given first, when previously the input didn't have to be in
>>> any particular order.
>>>
>>> Maybe we could get the performance win /and/ preserve the unordered
>>> property of the input by reimplementing the logic from before in shell
>>> instead of awk, including testing whether any directories actually
>>> needed to be modified before invoking chmod using [ (probably a shell
>>> built-in)?
>>
>> That's always going to be true right now, though, and I can easily add
>> a check and bail out if it turns out to be false.  I don't want extra
>> complexity.
>>
>> In the long term this needs to be rewritten in C or Python anyway.
> 
> In my opinion, adding an ordering requirement when we can do fine
> without increases complexity, and rewriting what we currently have in
> shell doesn't.  I can try that myself if you don't want to, and I'm also
> happy to take the following two patches without blocking them on this.

That would be awesome.

> (I would love an implementation of this that didn't require the copies
> at all, of course.)

Me too.
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 7253 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2025-09-21 17:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-19 23:26 [PATCH 0/3] Optimize scripts/make-erofs.sh Demi Marie Obenour
2025-09-19 23:26 ` [PATCH 1/3] scripts/make-erofs.sh: Avoid unneeded calls to awk and chmod Demi Marie Obenour
2025-09-21 11:31   ` Alyssa Ross
2025-09-21 15:56     ` Demi Marie Obenour
2025-09-21 16:15       ` Alyssa Ross
2025-09-21 17:12         ` Demi Marie Obenour [this message]
2025-09-21 18:06         ` Demi Marie Obenour
2025-09-19 23:26 ` [PATCH 2/3] scripts/make-erofs.sh: Avoid calls to dirname Demi Marie Obenour
2025-09-21 11:40   ` Alyssa Ross
2025-09-23 18:54   ` Alyssa Ross
2025-09-19 23:26 ` [PATCH 3/3] scripts/make-erofs.sh: Avoid unneeded calls to mkdir Demi Marie Obenour
2025-09-21 18:36   ` Alyssa Ross
2025-09-21 18:37     ` Demi Marie Obenour
2025-09-23 14:35       ` Alyssa Ross
2025-09-23 18:06         ` Demi Marie Obenour
2025-09-23 18:56           ` Alyssa Ross
2025-09-23 21:41             ` Demi Marie Obenour

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=645da3bf-6c9d-44d9-baab-cafd4de6e3bc@gmail.com \
    --to=demiobenour@gmail.com \
    --cc=devel@spectrum-os.org \
    --cc=hi@alyssa.is \
    /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.
Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).