Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 1 | /* |
| 2 | * pf.c - Print file attributes on an ext2 file system |
| 3 | * |
| 4 | * Copyright (C) 1993, 1994 Remy Card <card@masi.ibp.fr> |
| 5 | * Laboratoire MASI, Institut Blaise Pascal |
| 6 | * Universite Pierre et Marie Curie (Paris VI) |
| 7 | * |
Theodore Ts'o | 543547a | 2010-05-17 21:31:56 -0400 | [diff] [blame] | 8 | * %Begin-Header% |
| 9 | * This file may be redistributed under the terms of the GNU Library |
| 10 | * General Public License, version 2. |
| 11 | * %End-Header% |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | /* |
| 15 | * History: |
| 16 | * 93/10/30 - Creation |
| 17 | */ |
| 18 | |
Theodore Ts'o | d1154eb | 2011-09-18 17:34:37 -0400 | [diff] [blame] | 19 | #include "config.h" |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 20 | #include <stdio.h> |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 21 | |
| 22 | #include "e2p.h" |
| 23 | |
Theodore Ts'o | dede39b | 2000-02-11 04:48:03 +0000 | [diff] [blame] | 24 | struct flags_name { |
| 25 | unsigned long flag; |
Theodore Ts'o | 4ea7bd0 | 2001-12-16 23:23:37 -0500 | [diff] [blame] | 26 | const char *short_name; |
| 27 | const char *long_name; |
Theodore Ts'o | dede39b | 2000-02-11 04:48:03 +0000 | [diff] [blame] | 28 | }; |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 29 | |
Theodore Ts'o | dede39b | 2000-02-11 04:48:03 +0000 | [diff] [blame] | 30 | static struct flags_name flags_array[] = { |
| 31 | { EXT2_SECRM_FL, "s", "Secure_Deletion" }, |
| 32 | { EXT2_UNRM_FL, "u" , "Undelete" }, |
| 33 | { EXT2_SYNC_FL, "S", "Synchronous_Updates" }, |
Theodore Ts'o | 88372d5 | 2002-06-15 18:58:39 -0400 | [diff] [blame] | 34 | { EXT2_DIRSYNC_FL, "D", "Synchronous_Directory_Updates" }, |
Theodore Ts'o | dede39b | 2000-02-11 04:48:03 +0000 | [diff] [blame] | 35 | { EXT2_IMMUTABLE_FL, "i", "Immutable" }, |
| 36 | { EXT2_APPEND_FL, "a", "Append_Only" }, |
| 37 | { EXT2_NODUMP_FL, "d", "No_Dump" }, |
| 38 | { EXT2_NOATIME_FL, "A", "No_Atime" }, |
Theodore Ts'o | bda1509 | 2000-12-31 13:35:38 +0000 | [diff] [blame] | 39 | { EXT2_COMPR_FL, "c", "Compression_Requested" }, |
Theodore Ts'o | c4e5e36 | 2002-11-08 19:12:48 -0500 | [diff] [blame] | 40 | #ifdef ENABLE_COMPRESSION |
Theodore Ts'o | bda1509 | 2000-12-31 13:35:38 +0000 | [diff] [blame] | 41 | { EXT2_COMPRBLK_FL, "B", "Compressed_File" }, |
Theodore Ts'o | 88372d5 | 2002-06-15 18:58:39 -0400 | [diff] [blame] | 42 | { EXT2_DIRTY_FL, "Z", "Compressed_Dirty_File" }, |
Theodore Ts'o | c8199c4 | 2001-01-12 01:43:28 +0000 | [diff] [blame] | 43 | { EXT2_NOCOMPR_FL, "X", "Compression_Raw_Access" }, |
Theodore Ts'o | dede39b | 2000-02-11 04:48:03 +0000 | [diff] [blame] | 44 | { EXT2_ECOMPR_FL, "E", "Compression_Error" }, |
Theodore Ts'o | c4e5e36 | 2002-11-08 19:12:48 -0500 | [diff] [blame] | 45 | #endif |
Theodore Ts'o | c8199c4 | 2001-01-12 01:43:28 +0000 | [diff] [blame] | 46 | { EXT3_JOURNAL_DATA_FL, "j", "Journaled_Data" }, |
Eric Sandeen | 312c2a4 | 2009-05-27 23:23:43 -0500 | [diff] [blame] | 47 | { EXT2_INDEX_FL, "I", "Indexed_directory" }, |
Theodore Ts'o | b3f5b4c | 2001-11-05 19:22:02 -0500 | [diff] [blame] | 48 | { EXT2_NOTAIL_FL, "t", "No_Tailmerging" }, |
Theodore Ts'o | 15f9011 | 2002-11-01 01:53:52 -0500 | [diff] [blame] | 49 | { EXT2_TOPDIR_FL, "T", "Top_of_Directory_Hierarchies" }, |
Andreas Dilger | 8fe81a3 | 2006-08-05 18:50:22 -0400 | [diff] [blame] | 50 | { EXT4_EXTENTS_FL, "e", "Extents" }, |
Theodore Ts'o | 1ca1059 | 2008-04-09 11:39:11 -0400 | [diff] [blame] | 51 | { EXT4_HUGE_FILE_FL, "h", "Huge_file" }, |
Theodore Ts'o | 0796e66 | 2012-06-12 17:09:39 -0400 | [diff] [blame] | 52 | { FS_NOCOW_FL, "C", "No_COW" }, |
Theodore Ts'o | dede39b | 2000-02-11 04:48:03 +0000 | [diff] [blame] | 53 | { 0, NULL, NULL } |
| 54 | }; |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 55 | |
Theodore Ts'o | dede39b | 2000-02-11 04:48:03 +0000 | [diff] [blame] | 56 | void print_flags (FILE * f, unsigned long flags, unsigned options) |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 57 | { |
Theodore Ts'o | dede39b | 2000-02-11 04:48:03 +0000 | [diff] [blame] | 58 | int long_opt = (options & PFOPT_LONG); |
| 59 | struct flags_name *fp; |
| 60 | int first = 1; |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 61 | |
Theodore Ts'o | dede39b | 2000-02-11 04:48:03 +0000 | [diff] [blame] | 62 | for (fp = flags_array; fp->flag != 0; fp++) { |
| 63 | if (flags & fp->flag) { |
| 64 | if (long_opt) { |
| 65 | if (first) |
| 66 | first = 0; |
| 67 | else |
| 68 | fputs(", ", f); |
| 69 | fputs(fp->long_name, f); |
| 70 | } else |
| 71 | fputs(fp->short_name, f); |
| 72 | } else { |
| 73 | if (!long_opt) |
| 74 | fputs("-", f); |
| 75 | } |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 76 | } |
Theodore Ts'o | dede39b | 2000-02-11 04:48:03 +0000 | [diff] [blame] | 77 | if (long_opt && first) |
| 78 | fputs("---", f); |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 79 | } |
Theodore Ts'o | dede39b | 2000-02-11 04:48:03 +0000 | [diff] [blame] | 80 | |