#!/bin/sh | |
set -e | |
SYSFS_MTD_DIR=/sys/class/mtd | |
log() | |
{ | |
echo "$@" >&2 | |
} | |
usage() | |
{ | |
log "Usage: $0" | |
log " Lists all mtd devices" | |
exit 9 | |
} | |
if [ "$#" != 0 ]; then | |
usage | |
fi | |
if [ ! -d $SYSFS_MTD_DIR ]; then | |
log "$SYSFS_MTD_DIR does not exist" | |
exit 1 | |
fi | |
for i in $SYSFS_MTD_DIR/mtd[0-9] $SYSFS_MTD_DIR/mtd[0-9][0-9] $SYSFS_MTD_DIR/mtd[0-9][0-9][0-9]; do | |
[ -d $i ] || continue | |
echo -n ${i##*/} '' | |
head -n1 $i/name | |
done |