busybox-1.14.2-df.patch 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. --- busybox-1.14.2/coreutils/df.c Sun Jul 5 22:59:28 2009
  2. +++ busybox-1.14.2-df/coreutils/df.c Sun Jul 5 23:00:09 2009
  3. @@ -44,7 +44,6 @@
  4. FILE *mount_table;
  5. struct mntent *mount_entry;
  6. struct statfs s;
  7. - static const char ignored_mounts[] ALIGN1 = "rootfs\0";
  8. enum {
  9. OPT_KILO = (1 << 0),
  10. @@ -120,7 +119,7 @@
  11. mount_point = *argv++;
  12. if (!mount_point)
  13. break;
  14. - mount_entry = find_mount_point(mount_point, bb_path_mtab_file);
  15. + mount_entry = find_mount_point(mount_point);
  16. if (!mount_entry) {
  17. bb_error_msg("%s: can't find mount point", mount_point);
  18. set_error:
  19. @@ -154,8 +153,8 @@
  20. ) / (blocks_used + s.f_bavail);
  21. }
  22. - /* GNU coreutils 6.10 skip certain mounts, try to be compatible. */
  23. - if (index_in_strings(device, ignored_mounts) != -1)
  24. + /* GNU coreutils 6.10 skips certain mounts, try to be compatible. */
  25. + if (strcmp(device, "rootfs") == 0)
  26. continue;
  27. #ifdef WHY_WE_DO_IT_FOR_DEV_ROOT_ONLY
  28. --- busybox-1.14.2/include/libbb.h Sun Jul 5 22:59:31 2009
  29. +++ busybox-1.14.2-df/include/libbb.h Sun Jul 5 23:00:09 2009
  30. @@ -1025,7 +1025,7 @@
  31. #ifdef HAVE_MNTENT_H
  32. extern int match_fstype(const struct mntent *mt, const char *fstypes) FAST_FUNC;
  33. -extern struct mntent *find_mount_point(const char *name, const char *table) FAST_FUNC;
  34. +extern struct mntent *find_mount_point(const char *name) FAST_FUNC;
  35. #endif
  36. extern void erase_mtab(const char * name) FAST_FUNC;
  37. extern unsigned int tty_baud_to_value(speed_t speed) FAST_FUNC;
  38. --- busybox-1.14.2/libbb/find_mount_point.c Sun Jul 5 22:59:24 2009
  39. +++ busybox-1.14.2-df/libbb/find_mount_point.c Sun Jul 5 23:00:09 2009
  40. @@ -17,7 +17,7 @@
  41. * Given any other file (or directory), find the mount table entry for its
  42. * filesystem.
  43. */
  44. -struct mntent* FAST_FUNC find_mount_point(const char *name, const char *table)
  45. +struct mntent* FAST_FUNC find_mount_point(const char *name)
  46. {
  47. struct stat s;
  48. dev_t mountDevice;
  49. @@ -25,27 +25,35 @@
  50. struct mntent *mountEntry;
  51. if (stat(name, &s) != 0)
  52. - return 0;
  53. + return NULL;
  54. - if ((s.st_mode & S_IFMT) == S_IFBLK)
  55. + if (S_ISBLK(s.st_mode))
  56. mountDevice = s.st_rdev;
  57. else
  58. mountDevice = s.st_dev;
  59. - mountTable = setmntent(table ? table : bb_path_mtab_file, "r");
  60. + mountTable = setmntent(bb_path_mtab_file, "r");
  61. if (!mountTable)
  62. return 0;
  63. - while ((mountEntry = getmntent(mountTable)) != 0) {
  64. + while ((mountEntry = getmntent(mountTable)) != NULL) {
  65. + /* rootfs mount in Linux 2.6 exists always,
  66. + * and it makes sense to always ignore it.
  67. + * Otherwise people can't reference their "real" root! */
  68. + if (strcmp(mountEntry->mnt_fsname, "rootfs") == 0)
  69. + continue;
  70. +
  71. if (strcmp(name, mountEntry->mnt_dir) == 0
  72. || strcmp(name, mountEntry->mnt_fsname) == 0
  73. ) { /* String match. */
  74. break;
  75. }
  76. - if (stat(mountEntry->mnt_fsname, &s) == 0 && s.st_rdev == mountDevice) /* Match the device. */
  77. + /* Match the device. */
  78. + if (stat(mountEntry->mnt_fsname, &s) == 0 && s.st_rdev == mountDevice)
  79. break;
  80. - if (stat(mountEntry->mnt_dir, &s) == 0 && s.st_dev == mountDevice) /* Match the directory's mount point. */
  81. + /* Match the directory's mount point. */
  82. + if (stat(mountEntry->mnt_dir, &s) == 0 && s.st_dev == mountDevice)
  83. break;
  84. }
  85. endmntent(mountTable);
  86. --- busybox-1.14.2/util-linux/mkfs_minix.c Sun Jul 5 22:59:30 2009
  87. +++ busybox-1.14.2-df/util-linux/mkfs_minix.c Sun Jul 5 23:00:09 2009
  88. @@ -624,7 +624,6 @@
  89. int mkfs_minix_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  90. int mkfs_minix_main(int argc UNUSED_PARAM, char **argv)
  91. {
  92. - struct mntent *mp;
  93. unsigned opt;
  94. char *tmp;
  95. struct stat statbuf;
  96. @@ -683,11 +682,8 @@
  97. G.total_blocks = 65535;
  98. /* Check if it is mounted */
  99. - mp = find_mount_point(G.device_name, NULL);
  100. - if (mp && strcmp(G.device_name, mp->mnt_fsname) == 0)
  101. - bb_error_msg_and_die("%s is mounted on %s; "
  102. - "refusing to make a filesystem",
  103. - G.device_name, mp->mnt_dir);
  104. + if (find_mount_point(G.device_name))
  105. + bb_error_msg_and_die("can't format mounted filesystem");
  106. xmove_fd(xopen(G.device_name, O_RDWR), dev_fd);
  107. if (fstat(dev_fd, &statbuf) < 0)
  108. --- busybox-1.14.2/util-linux/mkfs_vfat.c Sun Jul 5 22:59:30 2009
  109. +++ busybox-1.14.2-df/util-linux/mkfs_vfat.c Sun Jul 5 23:00:35 2009
  110. @@ -273,10 +273,10 @@
  111. device_num == 0x0d00 || // xd
  112. device_num == 0x1600 ) // hdc, hdd
  113. )
  114. - bb_error_msg_and_die("Will not try to make filesystem on full-disk device (use -I if wanted)");
  115. + bb_error_msg_and_die("will not try to make filesystem on full-disk device (use -I if wanted)");
  116. // can't work on mounted filesystems
  117. - if (find_mount_point(device_name, NULL))
  118. - bb_error_msg_and_die("Can't format mounted filesystem");
  119. + if (find_mount_point(device_name))
  120. + bb_error_msg_and_die("can't format mounted filesystem");
  121. #endif
  122. // get true sector size
  123. // (parameter must be int*, not long* or size_t*)