~ubuntu-branches/ubuntu/trusty/hdparm/trusty-proposed

« back to all changes in this revision

Viewing changes to wiper/wiper.sh

  • Committer: Steve Langasek
  • Date: 2012-10-25 03:08:04 UTC
  • mfrom: (1.1.16 upstream)
  • Revision ID: steve.langasek@canonical.com-20121025030804-l50mshoma6jtp6kg
Merging shared upstream rev into target branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
#
3
3
# SATA SSD free-space TRIM utility, by Mark Lord <mlord@pobox.com>
4
4
 
5
 
VERSION=3.3 
 
5
VERSION=3.5 
6
6
 
7
7
# Copyright (C) 2009-2010 Mark Lord.  All rights reserved.
8
8
#
252
252
## because that's the pattern such systems also use in /proc/mounts.
253
253
## Later, at time of use, we'll try harder to find the real rootdev.
254
254
##
 
255
## FIXME: apparently this doesn't work on SuSE Linux, though.
 
256
## So for there, we'll likely need to read /etc/mtab,
 
257
## or be a lot more clever and get it somehow from statfs or something.
 
258
## FIXME: or use target from /dev/root symlink for Gentoo as well.
 
259
##
255
260
function match_rootdev() {
256
261
        rdev=""
257
262
        rdevno="$1"
370
375
        rawdev=""
371
376
elif [ "`get_major $fsdev`" -ne "`get_major $rawdev`" ]; then  ## sanity check
372
377
        rawdev=""
373
 
elif [ "`get_major $fsdev`" -ne "8" ]; then ## "SCSI" drives only; no LVM confusion for now
374
 
        echo "$rawdev: does not appear to be a SCSI/SATA SSD, aborting." >&2
375
 
        exit 1
376
 
elif ! $HDPARM -I $rawdev | $GREP -i '[         ][*][   ]*Data Set Management TRIM supported' &>/dev/null ; then
377
 
        if [ "$commit" = "yes" ]; then
378
 
                echo "$rawdev: DSM/TRIM command not supported, aborting." >&2
 
378
else
 
379
        ## "SCSI" drives only; no LVM confusion for now:
 
380
        maj="$(get_major $fsdev)"
 
381
        maj_ok=0
 
382
        for scsi_major in 8 65 66 67 68 69 70 71 ; do
 
383
                [ "$maj" = "$scsi_major" ] && maj_ok=1
 
384
        done
 
385
        if [ $maj_ok -eq 0 ]; then
 
386
                echo "$rawdev: does not appear to be a SCSI/SATA SSD, aborting." >&2
379
387
                exit 1
380
388
        fi
381
 
        echo "$rawdev: DSM/TRIM command not supported (continuing with dry-run)." >&2
 
389
        if ! $HDPARM -I $rawdev | $GREP -i '[   ][*][   ]*Data Set Management TRIM supported' &>/dev/null ; then
 
390
                if [ "$commit" = "yes" ]; then
 
391
                        echo "$rawdev: DSM/TRIM command not supported, aborting." >&2
 
392
                        exit 1
 
393
                fi
 
394
                echo "$rawdev: DSM/TRIM command not supported (continuing with dry-run)." >&2
 
395
        fi
382
396
fi
383
397
if [ "$rawdev" = "" ]; then
384
398
        echo "$fsdev: unable to reliably determine the underlying physical device name, aborting" >&2
784
798
                blksects = $NF / 512
785
799
                next
786
800
        }
787
 
        /^Group [1-9][0-9]*:/ { ## Second stage output from dumpe2fs:
 
801
        /^Group [0-9][0-9]*:/ { ## Second stage output from dumpe2fs:
788
802
                in_groups = 1
789
803
                next
790
804
        }