pf.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * pf.c - Print file attributes on an ext2 file system
  4. *
  5. * Copyright (C) 1993, 1994 Remy Card <card@masi.ibp.fr>
  6. * Laboratoire MASI, Institut Blaise Pascal
  7. * Universite Pierre et Marie Curie (Paris VI)
  8. *
  9. * This file can be redistributed under the terms of the GNU Library General
  10. * Public License
  11. */
  12. /*
  13. * History:
  14. * 93/10/30 - Creation
  15. */
  16. #include <stdio.h>
  17. #include "e2p.h"
  18. struct flags_name {
  19. unsigned long flag;
  20. const char *short_name;
  21. const char *long_name;
  22. };
  23. static const struct flags_name flags_array[] = {
  24. { EXT2_SECRM_FL, "s", "Secure_Deletion" },
  25. { EXT2_UNRM_FL, "u" , "Undelete" },
  26. { EXT2_SYNC_FL, "S", "Synchronous_Updates" },
  27. { EXT2_DIRSYNC_FL, "D", "Synchronous_Directory_Updates" },
  28. { EXT2_IMMUTABLE_FL, "i", "Immutable" },
  29. { EXT2_APPEND_FL, "a", "Append_Only" },
  30. { EXT2_NODUMP_FL, "d", "No_Dump" },
  31. { EXT2_NOATIME_FL, "A", "No_Atime" },
  32. { EXT2_COMPR_FL, "c", "Compression_Requested" },
  33. #ifdef ENABLE_COMPRESSION
  34. { EXT2_COMPRBLK_FL, "B", "Compressed_File" },
  35. { EXT2_DIRTY_FL, "Z", "Compressed_Dirty_File" },
  36. { EXT2_NOCOMPR_FL, "X", "Compression_Raw_Access" },
  37. { EXT2_ECOMPR_FL, "E", "Compression_Error" },
  38. #endif
  39. { EXT3_JOURNAL_DATA_FL, "j", "Journaled_Data" },
  40. { EXT2_INDEX_FL, "I", "Indexed_direcctory" },
  41. { EXT2_NOTAIL_FL, "t", "No_Tailmerging" },
  42. { EXT2_TOPDIR_FL, "T", "Top_of_Directory_Hierarchies" },
  43. { 0, NULL, NULL }
  44. };
  45. void print_flags (FILE * f, unsigned long flags, unsigned options)
  46. {
  47. int long_opt = (options & PFOPT_LONG);
  48. const struct flags_name *fp;
  49. int first = 1;
  50. for (fp = flags_array; fp->flag != 0; fp++) {
  51. if (flags & fp->flag) {
  52. if (long_opt) {
  53. if (first)
  54. first = 0;
  55. else
  56. fputs(", ", f);
  57. fputs(fp->long_name, f);
  58. } else
  59. fputs(fp->short_name, f);
  60. } else {
  61. if (!long_opt)
  62. fputs("-", f);
  63. }
  64. }
  65. if (long_opt && first)
  66. fputs("---", f);
  67. }