pf.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. * History:
  13. * 93/10/30 - Creation
  14. */
  15. #include <stdio.h>
  16. #include "e2p.h"
  17. struct flags_name {
  18. unsigned long flag;
  19. const char *short_name;
  20. const char *long_name;
  21. };
  22. static struct flags_name flags_array[] = {
  23. { EXT2_SECRM_FL, "s", "Secure_Deletion" },
  24. { EXT2_UNRM_FL, "u" , "Undelete" },
  25. { EXT2_SYNC_FL, "S", "Synchronous_Updates" },
  26. { EXT2_DIRSYNC_FL, "D", "Synchronous_Directory_Updates" },
  27. { EXT2_IMMUTABLE_FL, "i", "Immutable" },
  28. { EXT2_APPEND_FL, "a", "Append_Only" },
  29. { EXT2_NODUMP_FL, "d", "No_Dump" },
  30. { EXT2_NOATIME_FL, "A", "No_Atime" },
  31. { EXT2_COMPR_FL, "c", "Compression_Requested" },
  32. #ifdef ENABLE_COMPRESSION
  33. { EXT2_COMPRBLK_FL, "B", "Compressed_File" },
  34. { EXT2_DIRTY_FL, "Z", "Compressed_Dirty_File" },
  35. { EXT2_NOCOMPR_FL, "X", "Compression_Raw_Access" },
  36. { EXT2_ECOMPR_FL, "E", "Compression_Error" },
  37. #endif
  38. { EXT3_JOURNAL_DATA_FL, "j", "Journaled_Data" },
  39. { EXT2_INDEX_FL, "I", "Indexed_direcctory" },
  40. { EXT2_NOTAIL_FL, "t", "No_Tailmerging" },
  41. { EXT2_TOPDIR_FL, "T", "Top_of_Directory_Hierarchies" },
  42. { 0, NULL, NULL }
  43. };
  44. void print_flags (FILE * f, unsigned long flags, unsigned options)
  45. {
  46. int long_opt = (options & PFOPT_LONG);
  47. struct flags_name *fp;
  48. int first = 1;
  49. for (fp = flags_array; fp->flag != 0; fp++) {
  50. if (flags & fp->flag) {
  51. if (long_opt) {
  52. if (first)
  53. first = 0;
  54. else
  55. fputs(", ", f);
  56. fputs(fp->long_name, f);
  57. } else
  58. fputs(fp->short_name, f);
  59. } else {
  60. if (!long_opt)
  61. fputs("-", f);
  62. }
  63. }
  64. if (long_opt && first)
  65. fputs("---", f);
  66. }