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 | * |
| 8 | * This file can be redistributed under the terms of the GNU Library General |
| 9 | * Public License |
| 10 | */ |
| 11 | |
| 12 | /* |
| 13 | * History: |
| 14 | * 93/10/30 - Creation |
| 15 | */ |
| 16 | |
| 17 | #include <stdio.h> |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 18 | |
| 19 | #include "e2p.h" |
| 20 | |
Theodore Ts'o | dede39b | 2000-02-11 04:48:03 +0000 | [diff] [blame] | 21 | struct flags_name { |
| 22 | unsigned long flag; |
| 23 | char *short_name; |
| 24 | char *long_name; |
| 25 | }; |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 26 | |
Theodore Ts'o | dede39b | 2000-02-11 04:48:03 +0000 | [diff] [blame] | 27 | static struct flags_name flags_array[] = { |
| 28 | { EXT2_SECRM_FL, "s", "Secure_Deletion" }, |
| 29 | { EXT2_UNRM_FL, "u" , "Undelete" }, |
| 30 | { EXT2_SYNC_FL, "S", "Synchronous_Updates" }, |
| 31 | { EXT2_IMMUTABLE_FL, "i", "Immutable" }, |
| 32 | { EXT2_APPEND_FL, "a", "Append_Only" }, |
| 33 | { EXT2_NODUMP_FL, "d", "No_Dump" }, |
| 34 | { EXT2_NOATIME_FL, "A", "No_Atime" }, |
Theodore Ts'o | bda1509 | 2000-12-31 13:35:38 +0000 | [diff] [blame] | 35 | { EXT2_COMPR_FL, "c", "Compression_Requested" }, |
| 36 | { EXT2_COMPRBLK_FL, "B", "Compressed_File" }, |
| 37 | { EXT2_DIRTY_FL, "D", "Compressed_Dirty_File" }, |
Theodore Ts'o | c8199c4 | 2001-01-12 01:43:28 +0000 | [diff] [blame] | 38 | { EXT2_NOCOMPR_FL, "X", "Compression_Raw_Access" }, |
Theodore Ts'o | dede39b | 2000-02-11 04:48:03 +0000 | [diff] [blame] | 39 | { EXT2_ECOMPR_FL, "E", "Compression_Error" }, |
Theodore Ts'o | c8199c4 | 2001-01-12 01:43:28 +0000 | [diff] [blame] | 40 | { EXT3_JOURNAL_DATA_FL, "j", "Journaled_Data" }, |
Theodore Ts'o | b3f5b4c | 2001-11-05 19:22:02 -0500 | [diff] [blame^] | 41 | { EXT2_NOTAIL_FL, "t", "No_Tailmerging" }, |
Theodore Ts'o | dede39b | 2000-02-11 04:48:03 +0000 | [diff] [blame] | 42 | { 0, NULL, NULL } |
| 43 | }; |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 44 | |
Theodore Ts'o | dede39b | 2000-02-11 04:48:03 +0000 | [diff] [blame] | 45 | void print_flags (FILE * f, unsigned long flags, unsigned options) |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 46 | { |
Theodore Ts'o | dede39b | 2000-02-11 04:48:03 +0000 | [diff] [blame] | 47 | int long_opt = (options & PFOPT_LONG); |
| 48 | struct flags_name *fp; |
| 49 | int first = 1; |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 50 | |
Theodore Ts'o | dede39b | 2000-02-11 04:48:03 +0000 | [diff] [blame] | 51 | for (fp = flags_array; fp->flag != 0; fp++) { |
| 52 | if (flags & fp->flag) { |
| 53 | if (long_opt) { |
| 54 | if (first) |
| 55 | first = 0; |
| 56 | else |
| 57 | fputs(", ", f); |
| 58 | fputs(fp->long_name, f); |
| 59 | } else |
| 60 | fputs(fp->short_name, f); |
| 61 | } else { |
| 62 | if (!long_opt) |
| 63 | fputs("-", f); |
| 64 | } |
Theodore Ts'o | f3db356 | 1997-04-26 13:34:30 +0000 | [diff] [blame] | 65 | } |
Theodore Ts'o | dede39b | 2000-02-11 04:48:03 +0000 | [diff] [blame] | 66 | if (long_opt && first) |
| 67 | fputs("---", f); |
Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame] | 68 | } |
Theodore Ts'o | dede39b | 2000-02-11 04:48:03 +0000 | [diff] [blame] | 69 | |