]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: introduce is_mapped_file macro
authorMasatake YAMATO <yamato@redhat.com>
Thu, 10 Nov 2022 21:02:00 +0000 (06:02 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Wed, 23 Nov 2022 07:42:11 +0000 (16:42 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
misc-utils/lsfd-file.c
misc-utils/lsfd.h

index 0c473fdded7f2ee46163afdd97c9488fb50ef5db..ce310cc0f206258cf234be1733fab0a12eac0580 100644 (file)
@@ -228,8 +228,7 @@ static bool file_fill_column(struct proc *proc,
                        xasprintf(&str, "%c%c%c",
                                  file->mode & S_IRUSR? 'r': '-',
                                  file->mode & S_IWUSR? 'w': '-',
-                                 ((file->association == -ASSOC_SHM
-                                  || file->association == -ASSOC_MEM)
+                                 (is_mapped_file(file)
                                   && file->mode & S_IXUSR)? 'x': '-');
                else
                        xasprintf(&str, "---");
@@ -254,8 +253,7 @@ static bool file_fill_column(struct proc *proc,
                break;
        }
        case COL_MAPLEN:
-               if (file->association != -ASSOC_SHM
-                   && file->association != -ASSOC_MEM)
+               if (!is_mapped_file(file))
                        return true;
                xasprintf(&str, "%ju", (uintmax_t)get_map_length(file));
                break;
index d6329c69684ab32bcf4f7591add141ca24767561..163715e58e11bf3fd14b8d047ed4dbec12081ad1 100644 (file)
@@ -149,6 +149,7 @@ struct file {
 };
 
 #define is_opened_file(_f) ((_f)->association >= 0)
+#define is_mapped_file(_f) (is_association((_f), SHM) || is_association((_f), MEM))
 #define is_association(_f, a)  ((_f)->association < 0 && (_f)->association == -ASSOC_ ## a)
 
 struct file_class {