diff options
author | Waldemar Brodkorb <wbx@openadk.org> | 2014-05-06 12:36:57 +0200 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2014-05-06 12:37:21 +0200 |
commit | 498bfde15d0a9212ee3935bfe76076b7de69444c (patch) | |
tree | 455488bc596125568e9039dc552e4da4040cc825 /package/base-files/src/etc/mdev | |
parent | e8d7893e45ad4f9ef306f11920ddee086c2c8897 (diff) |
fix automounting of usb sticks
Diffstat (limited to 'package/base-files/src/etc/mdev')
-rwxr-xr-x | package/base-files/src/etc/mdev/fs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/package/base-files/src/etc/mdev/fs b/package/base-files/src/etc/mdev/fs new file mode 100755 index 000000000..afbcaffff --- /dev/null +++ b/package/base-files/src/etc/mdev/fs @@ -0,0 +1,46 @@ +#!/bin/sh +fs=$(grep -v "^#" /etc/fstab | grep "^/dev/${MDEV}[[:blank:]]"|awk '{ print $3}') +mnt=$(grep -v "^#" /etc/fstab | grep "^/dev/${MDEV}[[:blank:]]"|awk '{ print $2}') +procfs=$fs +if [ $fs = "ntfs-3g" ];then + procfs=fuse +fi + +# fstab check +adk_check() { + grep -v "^#" /etc/fstab | grep -q "^/dev/${1}[[:blank:]]" + if [ $? -ne 0 ];then + logger -t fs -s "Disk ${1} not registered in /etc/fstab" + exit 1 + fi +} + +# filesystem check +adk_fsck() { + [ -x /usr/sbin/fsck.$2 ] && { + logger -t fs -s "Checking filesystem on ${1} with ${2}" + fsck -p -t ${2} ${1} + } +} + +# mount filesystem +adk_mount() { + mkdir -p $3 >/dev/null 2>&1 + grep $2 /proc/filesystems >/dev/null 2>&1 + if [ $? -eq 0 ];then + logger -t fs -s "Mounting /dev/${1} to $mnt" + mount $mnt + else + logger -t fs -s "Required filesystem $2 not available" + fi +} + +case "${ACTION}" in +add) + logger -t fs -s "Device ${MDEV} added to the system" + adk_check ${MDEV} + adk_fsck ${MDEV} $fs + adk_mount ${MDEV} $procfs $mnt + ;; +esac +exit 0 |