162306a36Sopenharmony_ci#!/bin/sh
262306a36Sopenharmony_ci# SPDX-License-Identifier: LGPL-2.1
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci[ $# -eq 1 ] && header_dir=$1 || header_dir=tools/include/uapi/linux/
562306a36Sopenharmony_ci
662306a36Sopenharmony_ciprintf "static const char *mount_flags[] = {\n"
762306a36Sopenharmony_ciregex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MS_([[:alnum:]_]+)[[:space:]]+([[:digit:]]+)[[:space:]]*.*'
862306a36Sopenharmony_cigrep -E $regex ${header_dir}/mount.h | grep -E -v '(MSK|VERBOSE|MGC_VAL)\>' | \
962306a36Sopenharmony_ci	sed -r "s/$regex/\2 \2 \1/g" | sort -n | \
1062306a36Sopenharmony_ci	xargs printf "\t[%s ? (ilog2(%s) + 1) : 0] = \"%s\",\n"
1162306a36Sopenharmony_ciregex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MS_([[:alnum:]_]+)[[:space:]]+\(1<<([[:digit:]]+)\)[[:space:]]*.*'
1262306a36Sopenharmony_cigrep -E $regex ${header_dir}/mount.h | \
1362306a36Sopenharmony_ci	sed -r "s/$regex/\2 \1/g" | \
1462306a36Sopenharmony_ci	xargs printf "\t[%s + 1] = \"%s\",\n"
1562306a36Sopenharmony_ciprintf "};\n"
16