github.com/inspektor-gadget/inspektor-gadget@v0.28.1/pkg/gadgets/trace/mount/tracer/utils.go (about)

     1  // Copyright 2022 The Inspektor Gadget authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package tracer
    16  
    17  var flagNames = []string{
    18  	"MS_RDONLY",
    19  	"MS_NOSUID",
    20  	"MS_NODEV",
    21  	"MS_NOEXEC",
    22  	"MS_SYNCHRONOUS",
    23  	"MS_REMOUNT",
    24  	"MS_MANDLOCK",
    25  	"MS_DIRSYNC",
    26  	"MS_NOSYMFOLLOW",
    27  	"MS_NOATIME",
    28  	"MS_NODIRATIME",
    29  	"MS_BIND",
    30  	"MS_MOVE",
    31  	"MS_REC",
    32  	"MS_VERBOSE",
    33  	"MS_SILENT",
    34  	"MS_POSIXACL",
    35  	"MS_UNBINDABLE",
    36  	"MS_PRIVATE",
    37  	"MS_SLAVE",
    38  	"MS_SHARED",
    39  	"MS_RELATIME",
    40  	"MS_KERNMOUNT",
    41  	"MS_I_VERSION",
    42  	"MS_STRICTATIME",
    43  	"MS_LAZYTIME",
    44  	"MS_SUBMOUNT",
    45  	"MS_NOREMOTELOCK",
    46  	"MS_NOSEC",
    47  	"MS_BORN",
    48  	"MS_ACTIVE",
    49  	"MS_NOUSER",
    50  }
    51  
    52  func DecodeFlags(flags uint64) []string {
    53  	flagsStr := []string{}
    54  
    55  	for i, val := range flagNames {
    56  		if (1<<i)&flags == 0 {
    57  			continue
    58  		}
    59  		flagsStr = append(flagsStr, val)
    60  	}
    61  
    62  	return flagsStr
    63  }