patch-lib_fs_c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. $OpenBSD: patch-lib_fs_c,v 1.2 2010/05/19 13:45:15 espie Exp $
  2. --- lib/fs.c.orig Wed Jun 14 14:34:30 2000
  3. +++ lib/fs.c Wed May 19 13:05:05 2010
  4. @@ -3,6 +3,73 @@
  5. #include <rpmlib.h>
  6. #include <rpmmacro.h>
  7. +#ifdef __OpenBSD__
  8. +#ifdef __aix__
  9. +#define COMMENTCHAR '*'
  10. +#else
  11. +#define COMMENTCHAR '#'
  12. +#endif
  13. +
  14. +#if HAVE_STRUCT_MNTTAB
  15. +static our_mntent * getmntent(FILE *filep) {
  16. + static struct mnttab entry;
  17. + static our_mntent item;
  18. +
  19. + if (!fread(&entry, sizeof(entry), 1, filep)) return NULL;
  20. + item.our_mntdir = entry.mt_filsys;
  21. +
  22. + return &item;
  23. +}
  24. +#else
  25. +#define getmntent internal_getmntent
  26. +static our_mntent *getmntent(FILE *filep) {
  27. + static our_mntent item = { NULL };
  28. + char buf[1024], * start;
  29. + char * chptr;
  30. +
  31. + if (item.our_mntdir) {
  32. + free(item.our_mntdir);
  33. + }
  34. +
  35. + while (fgets(buf, sizeof(buf) - 1, filep)) {
  36. + /* chop off \n */
  37. + buf[strlen(buf) - 1] = '\0';
  38. +
  39. + chptr = buf;
  40. + while (isspace(*chptr)) chptr++;
  41. +
  42. + if (*chptr == COMMENTCHAR) continue;
  43. +
  44. +# if __aix__
  45. + /* aix uses a screwed up file format */
  46. + if (*chptr == '/') {
  47. + start = chptr;
  48. + while (*chptr != ':') chptr++;
  49. + *chptr = '\0';
  50. + item.mnt_dir = strdup(start);
  51. + return &item;
  52. + }
  53. +# else
  54. + while (!isspace(*chptr) && (*chptr)) chptr++;
  55. + if (!*chptr) return NULL;
  56. +
  57. + while (isspace(*chptr) && (*chptr)) chptr++;
  58. + if (!*chptr) return NULL;
  59. + start = chptr;
  60. +
  61. + while (!isspace(*chptr) && (*chptr)) chptr++;
  62. + *chptr = '\0';
  63. +
  64. + item.our_mntdir = strdup(start);
  65. + return &item;
  66. +# endif
  67. + }
  68. +
  69. + return NULL;
  70. +}
  71. +#endif
  72. +#endif
  73. +
  74. struct fsinfo {
  75. /*@only@*/ const char * mntPoint;
  76. dev_t dev;
  77. @@ -301,3 +368,5 @@ int rpmGetFilesystemUsage(const char ** fileList, int_
  78. return 0;
  79. }
  80. +
  81. +