paul@181 | 1 | /* |
paul@181 | 2 | * pf.c - Print file attributes on an ext2 file system |
paul@181 | 3 | * |
paul@181 | 4 | * Copyright (C) 1993, 1994 Remy Card <card@masi.ibp.fr> |
paul@181 | 5 | * Laboratoire MASI, Institut Blaise Pascal |
paul@181 | 6 | * Universite Pierre et Marie Curie (Paris VI) |
paul@181 | 7 | * |
paul@181 | 8 | * %Begin-Header% |
paul@181 | 9 | * This file may be redistributed under the terms of the GNU Library |
paul@181 | 10 | * General Public License, version 2. |
paul@181 | 11 | * %End-Header% |
paul@181 | 12 | */ |
paul@181 | 13 | |
paul@181 | 14 | /* |
paul@181 | 15 | * History: |
paul@181 | 16 | * 93/10/30 - Creation |
paul@181 | 17 | */ |
paul@181 | 18 | |
paul@181 | 19 | #include "config.h" |
paul@181 | 20 | #include <stdio.h> |
paul@181 | 21 | |
paul@181 | 22 | #include "e2p.h" |
paul@181 | 23 | |
paul@181 | 24 | struct flags_name { |
paul@181 | 25 | unsigned long flag; |
paul@181 | 26 | const char *short_name; |
paul@181 | 27 | const char *long_name; |
paul@181 | 28 | }; |
paul@181 | 29 | |
paul@181 | 30 | static struct flags_name flags_array[] = { |
paul@181 | 31 | { EXT2_SECRM_FL, "s", "Secure_Deletion" }, |
paul@181 | 32 | { EXT2_UNRM_FL, "u" , "Undelete" }, |
paul@181 | 33 | { EXT2_SYNC_FL, "S", "Synchronous_Updates" }, |
paul@181 | 34 | { EXT2_DIRSYNC_FL, "D", "Synchronous_Directory_Updates" }, |
paul@181 | 35 | { EXT2_IMMUTABLE_FL, "i", "Immutable" }, |
paul@181 | 36 | { EXT2_APPEND_FL, "a", "Append_Only" }, |
paul@181 | 37 | { EXT2_NODUMP_FL, "d", "No_Dump" }, |
paul@181 | 38 | { EXT2_NOATIME_FL, "A", "No_Atime" }, |
paul@181 | 39 | { EXT2_COMPR_FL, "c", "Compression_Requested" }, |
paul@181 | 40 | { EXT4_ENCRYPT_FL, "E", "Encrypted" }, |
paul@181 | 41 | { EXT3_JOURNAL_DATA_FL, "j", "Journaled_Data" }, |
paul@181 | 42 | { EXT2_INDEX_FL, "I", "Indexed_directory" }, |
paul@181 | 43 | { EXT2_NOTAIL_FL, "t", "No_Tailmerging" }, |
paul@181 | 44 | { EXT2_TOPDIR_FL, "T", "Top_of_Directory_Hierarchies" }, |
paul@181 | 45 | { EXT4_EXTENTS_FL, "e", "Extents" }, |
paul@181 | 46 | { FS_NOCOW_FL, "C", "No_COW" }, |
paul@181 | 47 | { EXT4_INLINE_DATA_FL, "N", "Inline_Data" }, |
paul@181 | 48 | { EXT4_PROJINHERIT_FL, "P", "Project_Hierarchy" }, |
paul@181 | 49 | { EXT4_VERITY_FL, "V", "Verity" }, |
paul@181 | 50 | { 0, NULL, NULL } |
paul@181 | 51 | }; |
paul@181 | 52 | |
paul@181 | 53 | void print_flags (FILE * f, unsigned long flags, unsigned options) |
paul@181 | 54 | { |
paul@181 | 55 | int long_opt = (options & PFOPT_LONG); |
paul@181 | 56 | struct flags_name *fp; |
paul@181 | 57 | int first = 1; |
paul@181 | 58 | |
paul@181 | 59 | for (fp = flags_array; fp->flag != 0; fp++) { |
paul@181 | 60 | if (flags & fp->flag) { |
paul@181 | 61 | if (long_opt) { |
paul@181 | 62 | if (first) |
paul@181 | 63 | first = 0; |
paul@181 | 64 | else |
paul@181 | 65 | fputs(", ", f); |
paul@181 | 66 | fputs(fp->long_name, f); |
paul@181 | 67 | } else |
paul@181 | 68 | fputs(fp->short_name, f); |
paul@181 | 69 | } else { |
paul@181 | 70 | if (!long_opt) |
paul@181 | 71 | fputs("-", f); |
paul@181 | 72 | } |
paul@181 | 73 | } |
paul@181 | 74 | if (long_opt && first) |
paul@181 | 75 | fputs("---", f); |
paul@181 | 76 | } |
paul@181 | 77 | |