Skip to contentSkip to conversation

git source files with rw permissions

DISCUSSION Joe Perches 2 participants 6 messages Apr 6, 2018 – Jan 28, 2023

Subsystems (5)
DRM drivers Sound DRM misc ASoC +1 more subsystems
lore
Share & tools
lore
#0 lore raw

Some .c source files have r.x permissions (0755) that should be updated.

A trivial script on a clean git tree like:

$ git ls-files -- "*.[chsS]" | \
  xargs ls -la | \
  grep -P "^[^l](?:.{2,2}x|.{5,5}x|.{8,8}x)" | \
  awk '{print $9}'

today shows:

drivers/gpu/drm/amd/amdgpu/vce_v4_0.c
drivers/net/ethernet/cadence/macb_ptp.c

It would be good to update those via some script like:

$ git ls-files -- "*.[chsS]" | \
  xargs ls -la | \
  grep -P
"^[^l](?:.{2,2}x|.{5,5}x|.{8,8}x)" | \
  awk '{print $9}' | \
  xargs
chmod 644
tmpfile=$(mktemp)
echo "treewide: chmod executable source files
to 0644" > $tmpfile
git commit -s -a -F $tmpfile
rm -f $tmpfile
#1 lore raw
Quoted 7 lines · Joe Perches

A trivial script on a clean git tree like:

$ git ls-files -- "*.[chsS]" | \
  xargs ls -la | \
  grep -P "^[^l](?:.{2,2}x|.{5,5}x|.{8,8}x)" | \
  awk '{print $9}'

A simpler version of this is:

git ls-files -s '*.[chsS]' | grep '^100755'

and then you can use 'cut -f2' if you just want the filenames and do the "xargs chmod" thing.

Which I did, and committed, and just pushed out.

Thanks,
Linus

#2 lore raw
Quoted 8 lines · Linus Torvalds
Quoted 6 lines · Joe Perches

A trivial script on a clean git tree like:

$ git ls-files -- "*.[chsS]" | \
  xargs ls -la | \
  grep -P "^[^l](?:.{2,2}x|.{5,5}x|.{8,8}x)" | \
  awk '{print $9}'
Quoted 8 lines

A simpler version of this is:

git ls-files -s '*.[chsS]' | grep '^100755'

and then you can use 'cut -f2' if you just want the filenames and do the "xargs chmod" thing.

Which I did, and committed, and just pushed out.

Maybe time to do it again. Current tree:

$ git ls-files -s '*.[chsS]' | grep '^100755' | cut -f2 | xargs chmod 0644
$ git diff --stat -p
 drivers/gpu/drm/vmwgfx/vmwgfx_msg_arm64.h | 0
 sound/soc/codecs/es8326.c                 | 0
 sound/soc/codecs/es8326.h                 | 0
 3 files changed, 0 insertions(+), 0 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_msg_arm64.h +0 -0
old mode 100755
new mode 100644
sound/soc/codecs/es8326.c +0 -0
old mode 100755
new mode 100644
sound/soc/codecs/es8326.h +0 -0
old mode 100755
new mode 100644
#3 lore raw
Quoted 2 lines · Joe Perches

Maybe time to do it again.

Thanks, done.

Linus

#4 lore raw
Quoted 5 lines · Linus Torvalds
Quoted 2 lines · Joe Perches

Maybe time to do it again.

Thanks, done.

fyi: there's one more straggler:

100755 07781408e78820ad49d093d4bddcfd14eeadfa39 0 Documentation/devicetree/bindings/sound/everest,es8326.yaml

#5 lore raw
Quoted 2 lines · Joe Perches

fyi: there's one more straggler:

And I think there's one more.

Here's another one-liner shell script for finding suspicious files:

    git ls-files -s |
        grep '^100755' | cut -f2 |
        xargs grep -L '^#!'

and I don't think 'scripts/atomic/atomics.tbl' should be in that set.

At least that file has a reasonable explanation for why it's executable - over-eager "mark all these scripts executable" without noticing that one of the files in question was just the input file to another script.

Linus