source: pkg/vinnie/main/scanpartitions-parsix/trunk/scanpartitions @ 6865

Revision 6865, 1.8 KB checked in by alanbach-guest, 3 years ago (diff)
  • Use the old fstype script as a backup method if the

klibc-utils fstype returns unknown. This happens on
NTFS partitions for some reason

  • Bump standards version to 3.9.0
Line 
1#!/bin/bash
2# (C) Klaus Knopper Nov 2002
3# Reads /proc/partitions, returns table of the form
4# basename(devicefile) mountpoint filesystemtype
5# Useful for automatic generation of /etc/fstab entries (you
6# still may have to add noauto 0 0).
7
8# changes for Kanotix by Stefan Lippers-Hollmann, Joerg Schirottke
9# updated for Parsix by Alan Baghumian
10
11[ ! -e /proc/partitions ] && { echo "$0: /proc not mounted, exiting" >&2; exit 1; }
12
13###
14
15if [ -z "$1" ]; then
16        partitions=""
17        disks=""
18        disksize=0
19        blocksum=0
20        pold="none"
21
22        while read major minor blocks partition relax; do
23                partition="${partition#/dev/}"
24                [ -z "$partition" -o ! -e "/dev/$partition" ] && continue
25                [ "$blocks" -lt 2 ] 2>/dev/null && continue
26
27                case "$partition" in
28                        ?d?|ub?|ataraid/d?|rd/c?d?|cciss/c?d?)
29                                disks="$disks $partition"
30                                disksize="$blocks"
31                                blocksum=0
32                                ;;
33                        ram*|cloop*|loop*)
34                                ;; # Kernel 2.6 bug?
35                        *)
36                                blocksum="$(($blocksum + $blocks))"
37                                [ "$blocksum" -gt "$disksize" ] >/dev/null 2>&1 || partitions="$partitions /dev/$partition"
38                                ;;
39                esac
40        done <<EOT
41$(awk 'BEGIN{old="__start"}{if($0==old){exit}else{old=$0;if($4&&$4!="name"){print $0}}}' /proc/partitions)
42EOT
43
44        # Add disks without partition table (probably ZIP drives)
45        for d in $disks; do
46                case "$partitions" in
47                        */dev/$d*)
48                                continue
49                                ;;
50                esac
51                partitions="$partitions /dev/$d"
52        done
53else
54        partitions="$*"
55fi
56
57for p in $partitions; do
58        fs="auto"
59        # fstype is an external script
60        scanfs=`/usr/lib/klibc/bin/fstype $p | grep FSTYPE | awk 'BEGIN{FS="="}{print $2}'`
61
62        # if get unknown partition, try fstype script
63        if [ "$scanfs" = "unknown" ]; then
64             scanfs=`/usr/sbin/fstype $p`
65        fi
66
67        [ -n "$scanfs" ] && fs="$scanfs"
68        mountpoint="/media/${p##*/}"
69        [ "$fs" = "swap" ] && mountpoint="none"
70        echo "${p}" "${mountpoint}" "${fs}"       
71done
72
73exit 0
74
Note: See TracBrowser for help on using the repository browser.