xref: /OK3568_Linux_fs/kernel/tools/perf/trace/beauty/mount_flags.sh (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#!/bin/sh
2*4882a593Smuzhiyun# SPDX-License-Identifier: LGPL-2.1
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun[ $# -eq 1 ] && header_dir=$1 || header_dir=tools/include/uapi/linux/
5*4882a593Smuzhiyun
6*4882a593Smuzhiyunprintf "static const char *mount_flags[] = {\n"
7*4882a593Smuzhiyunregex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MS_([[:alnum:]_]+)[[:space:]]+([[:digit:]]+)[[:space:]]*.*'
8*4882a593Smuzhiyunegrep $regex ${header_dir}/mount.h | egrep -v '(MSK|VERBOSE|MGC_VAL)\>' | \
9*4882a593Smuzhiyun	sed -r "s/$regex/\2 \2 \1/g" | sort -n | \
10*4882a593Smuzhiyun	xargs printf "\t[%s ? (ilog2(%s) + 1) : 0] = \"%s\",\n"
11*4882a593Smuzhiyunregex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MS_([[:alnum:]_]+)[[:space:]]+\(1<<([[:digit:]]+)\)[[:space:]]*.*'
12*4882a593Smuzhiyunegrep $regex ${header_dir}/mount.h | \
13*4882a593Smuzhiyun	sed -r "s/$regex/\2 \1/g" | \
14*4882a593Smuzhiyun	xargs printf "\t[%s + 1] = \"%s\",\n"
15*4882a593Smuzhiyunprintf "};\n"
16