Home | History | Annotate | Download | only in e2p
      1 /*
      2  * pf.c			- Print file attributes on an ext2 file system
      3  *
      4  * Copyright (C) 1993, 1994  Remy Card <card (at) masi.ibp.fr>
      5  *                           Laboratoire MASI, Institut Blaise Pascal
      6  *                           Universite Pierre et Marie Curie (Paris VI)
      7  *
      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%
     12  */
     13 
     14 /*
     15  * History:
     16  * 93/10/30	- Creation
     17  */
     18 
     19 #include <stdio.h>
     20 
     21 #include "e2p.h"
     22 
     23 struct flags_name {
     24 	unsigned long	flag;
     25 	const char	*short_name;
     26 	const char	*long_name;
     27 };
     28 
     29 static struct flags_name flags_array[] = {
     30 	{ EXT2_SECRM_FL, "s", "Secure_Deletion" },
     31 	{ EXT2_UNRM_FL, "u" , "Undelete" },
     32 	{ EXT2_SYNC_FL, "S", "Synchronous_Updates" },
     33 	{ EXT2_DIRSYNC_FL, "D", "Synchronous_Directory_Updates" },
     34 	{ EXT2_IMMUTABLE_FL, "i", "Immutable" },
     35 	{ EXT2_APPEND_FL, "a", "Append_Only" },
     36 	{ EXT2_NODUMP_FL, "d", "No_Dump" },
     37 	{ EXT2_NOATIME_FL, "A", "No_Atime" },
     38 	{ EXT2_COMPR_FL, "c", "Compression_Requested" },
     39 #ifdef ENABLE_COMPRESSION
     40 	{ EXT2_COMPRBLK_FL, "B", "Compressed_File" },
     41 	{ EXT2_DIRTY_FL, "Z", "Compressed_Dirty_File" },
     42 	{ EXT2_NOCOMPR_FL, "X", "Compression_Raw_Access" },
     43 	{ EXT2_ECOMPR_FL, "E", "Compression_Error" },
     44 #else
     45 	{ EXT4_ENCRYPT_FL, "E", "Encrypted" },
     46 #endif
     47 	{ EXT3_JOURNAL_DATA_FL, "j", "Journaled_Data" },
     48 	{ EXT2_INDEX_FL, "I", "Indexed_directory" },
     49 	{ EXT2_NOTAIL_FL, "t", "No_Tailmerging" },
     50 	{ EXT2_TOPDIR_FL, "T", "Top_of_Directory_Hierarchies" },
     51 	{ EXT4_EXTENTS_FL, "e", "Extents" },
     52 	{ EXT4_HUGE_FILE_FL, "h", "Huge_file" },
     53 	{ FS_NOCOW_FL, "C", "No_COW" },
     54 	{ 0, NULL, NULL }
     55 };
     56 
     57 void print_flags (FILE * f, unsigned long flags, unsigned options)
     58 {
     59 	int long_opt = (options & PFOPT_LONG);
     60 	struct flags_name *fp;
     61 	int	first = 1;
     62 
     63 	for (fp = flags_array; fp->flag != 0; fp++) {
     64 		if (flags & fp->flag) {
     65 			if (long_opt) {
     66 				if (first)
     67 					first = 0;
     68 				else
     69 					fputs(", ", f);
     70 				fputs(fp->long_name, f);
     71 			} else
     72 				fputs(fp->short_name, f);
     73 		} else {
     74 			if (!long_opt)
     75 				fputs("-", f);
     76 		}
     77 	}
     78 	if (long_opt && first)
     79 		fputs("---", f);
     80 }
     81 
     82