Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: LGPL-2.1
0002 /*
0003  * trace/beauty/mount_flags.c
0004  *
0005  *  Copyright (C) 2018, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
0006  */
0007 
0008 #include "trace/beauty/beauty.h"
0009 #include <linux/compiler.h>
0010 #include <linux/kernel.h>
0011 #include <linux/log2.h>
0012 #include <sys/mount.h>
0013 
0014 static size_t mount__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix)
0015 {
0016 #include "trace/beauty/generated/mount_flags_array.c"
0017     static DEFINE_STRARRAY(mount_flags, "MS_");
0018 
0019     return strarray__scnprintf_flags(&strarray__mount_flags, bf, size, show_prefix, flags);
0020 }
0021 
0022 unsigned long syscall_arg__mask_val_mount_flags(struct syscall_arg *arg __maybe_unused, unsigned long flags)
0023 {
0024     // do_mount in fs/namespace.c:
0025     /*
0026      * Pre-0.97 versions of mount() didn't have a flags word.  When the
0027      * flags word was introduced its top half was required to have the
0028      * magic value 0xC0ED, and this remained so until 2.4.0-test9.
0029      * Therefore, if this magic number is present, it carries no
0030      * information and must be discarded.
0031      */
0032     if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
0033         flags &= ~MS_MGC_MSK;
0034 
0035     return flags;
0036 }
0037 
0038 size_t syscall_arg__scnprintf_mount_flags(char *bf, size_t size, struct syscall_arg *arg)
0039 {
0040     unsigned long flags = arg->val;
0041 
0042     return mount__scnprintf_flags(flags, bf, size, arg->show_string_prefix);
0043 }