Subject: Re: long DOS filenames with amd
To: Steve Bellovin <smb@research.att.com>
From: Dave <spam@dberg.net>
List: netbsd-users
Date: 12/01/2004 15:15:45
--0lnxQi9hkpPO77W3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

  If all else fails, here's an approach.  It lets you choose the
options you want for an amd'ed FS via /etc/fstab rather than via amd
config files (i.e., you'd put "... ffs rw,-l ..." in fstab and not
worry about setting "opts:=..." except as a place-holder); and as an
added bonus, it automatically unmounts the filesystem when it's idle--
nice if your machine loses power (provided no open files kept the FS
mounted...).

==> /etc/amd/master
  ...
  /m              /etc/amd/m
  ...

==> /etc/amd/m
  ...
  /defaults       type:=program;mount:="/etc/amd/fsmount fsmount ${fs}";unmount:="/etc/amd/fsunmount fsunmount ${fs}"
  ...
  wrk             opts:=rw
  ...

==> /etc/fstab
  ...
  /dev/wd0p /amd/piano/m/wrk        ffs  rw,noauto,softdep               1 2
  ...

==

(substitute /amd/piano/m/wrk with whatever path your system automounts
the FS on).

  The fsmount and fsumount scripts (attached) aren't polished, but
they've been working ok under light usage for a couple years.  I
recall around the time I wrote them thinking that someone else on one
of the NetBSD lists had posted a different, very elegant approach, but
wasn't able to track it down, so I wrote these.

Cheers,  --Dave

On Wed, Dec 01, 2004 at 01:02:46AM -0500, Steve Bellovin wrote:
> I use amd to mount USB flash drives.  I'd like it if long file names 
> were always created when I mount it.  I can that manually if I use
> 
> 	mount -o -l /dev/sd0e /mnt
> 
> but I haven't figured out how to make amd use the -l option.  The 
...

--0lnxQi9hkpPO77W3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=fsmount

#!/bin/sh
# By Dave Berger; Boston, MA; 2002

_dir=$1

if [ -z "$_dir" ]
then
  echo 'error: Missing required argument: <path>.'
  exit 1
fi

if [ ! -d "$_dir" ]
then
  if ! mkdir -p "$_dir"
  then
    echo 'error: could not create directory <'$_dir'>.'
    exit 2
  fi
fi

/sbin/mount $1

--0lnxQi9hkpPO77W3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=fsunmount

#!/bin/sh
# By Dave Berger; Boston, MA; 2002

_dir=$1

if [ -z "$_dir" ]
then
  echo 'error: Missing required argument: <path>.'
  exit 1
fi

if ! _msg=$(/sbin/umount "$_dir" 2>&1)
then
##  Seems it's too late to set _stat from $? by now.  -dlb
#  _stat=$?
  case $_msg in
  *': not currently mounted')
    ;;
  *': Device busy')
    exit 2
    ;;
  *)
    echo 'error: Could not unmount <'$_dir'>.'
#    echo $_msg "<$_stat>"
    echo $_msg
    exit 3
    ;;
  esac
fi

# no -p because we don't know how far up the chain it's correct
# to go.  --dlb, 24-Jun-02
[ -d "$_dir" ] && rmdir "$_dir"
exit 0

--0lnxQi9hkpPO77W3--