Skip to content

Instantly share code, notes, and snippets.

@ilhan-athn7
Created August 15, 2026 18:45
Show Gist options
  • Select an option

  • Save ilhan-athn7/00cb070a72039e466c2ca25a4fe5927f to your computer and use it in GitHub Desktop.

Select an option

Save ilhan-athn7/00cb070a72039e466c2ca25a4fe5927f to your computer and use it in GitHub Desktop.
Magisk set_perm style file attribute fetch tool
file_info() {
local f="$1"
if [ -z "$f" ] || [ ! -e "$f" ]; then
echo "$1" "Usage: file_info <path>"
return 1
fi
local uid gid perm ctx
uid=$(stat -c '%u' "$f")
gid=$(stat -c '%g' "$f")
perm=$(stat -c '%a' "$f")
ctx=$(stat -c '%C' "$f" 2>/dev/null)
# fallback if stat doesn't support %C (common on toybox/older busybox)
if [ -z "$ctx" ]; then
ctx=$(ls -Zd "$f" | awk '{print $1}')
fi
printf '%s %s %s 0%s %s\n' "$1" "$uid" "$gid" "$perm" "$ctx"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment