20-fsck 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/bin/sh
  2. # Copyright (C) 2009-2010 OpenWrt.org
  3. # Copyright (C) 2010 Vertical Communications
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. . /lib/functions/block.sh
  8. . /lib/functions/fsck.sh
  9. blkdev=`dirname $DEVPATH`
  10. if [ `basename $blkdev` != "block" ]; then
  11. device=`basename $DEVPATH`
  12. case "$ACTION" in
  13. add)
  14. local from_fstab
  15. local anon_mount
  16. local anon_swap
  17. local anon_fsck
  18. local mds_mount_target
  19. local mds_mount_device
  20. local mds_mount_fstype
  21. local mds_mount_enabled_fsck
  22. local sds_swap_device
  23. local use_device
  24. local do_fsck=0
  25. local fsck_type
  26. local autoswap_from_fstab
  27. local automount_from_fstab
  28. local hotplug_blkid_fstype_match
  29. mount_dev_section_cb() {
  30. mds_mount_device="$3"
  31. mds_mount_fstype="$4"
  32. mds_mount_enabled_fsck="$7"
  33. }
  34. swap_dev_section_cb() {
  35. sds_swap_device="$2"
  36. return 0
  37. }
  38. config_get_automount
  39. automount_from_fstab="$from_fstab"
  40. [ "$automount_from_fstab" -eq 1 ] && {
  41. config_get_mount_section_by_device "/dev/$device"
  42. use_device="$mds_mount_device"
  43. [ "$mds_mount_enabled_fsck" -eq 1 ] && {
  44. do_fsck=1
  45. fsck_type="$mds_mount_fstype"
  46. }
  47. }
  48. [ -z "$use_device" ] && {
  49. config_get_autoswap
  50. autoswap_from_fstab="$from_fstab"
  51. [ "$autoswap_from_fstab" -eq 1 ] && {
  52. config_get_swap_section_by_device "/dev/$device"
  53. use_device="$sds_swap_device" && do_fsck=0
  54. }
  55. }
  56. grep -q "/dev/$device" /proc/swaps || grep -q "/dev/$device" /proc/mounts || {
  57. [ "$anon_fsck" -eq 1 ] && [ -z "$use_device" ] && {
  58. use_device="/dev/$device" && do_fsck=1 && mds_mount_fstype="" && hotplug_blkid_fstype_match=0
  59. }
  60. }
  61. [ "$do_fsck" -eq 1 ] && {
  62. libmount_fsck "$use_device" "$fsck_type" "$do_fsck"
  63. }
  64. reset_dev_section_cb
  65. ;;
  66. esac
  67. fi