9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Unmount a USB stick?
@ 2008-04-03 22:11 devrin talen
  2008-04-03 22:17 ` erik quanstrom
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: devrin talen @ 2008-04-03 22:11 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

I've got a USB stick that I've been using to shuttle a few docs
around. I googled a bit and I've been using:

% usb/disk -l
% usbfat:

to mount the stick. That works all well and good, but how do I go
about ejecting it gracefully? I've tried:

% unmount /n/usb
% unmount /n/disk

But have no idea if that's the right way to go about it. Additionally
if I eject it in this manner the next time I try to mount it using the
first two commands I get a bunch of usb errors.

Also, why is the disk only available from the rc window that I used to
mount it? In any other rc window I can't access the /n/usb mountpoint.
I realize I'm probably missing something fundamental about plan 9
(newbie here).

- Devrin


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9fans] Unmount a USB stick?
  2008-04-03 22:11 [9fans] Unmount a USB stick? devrin talen
@ 2008-04-03 22:17 ` erik quanstrom
  2008-04-03 22:28   ` geoff
  2008-04-03 22:19 ` a
  2008-04-04 10:42 ` Richard Miller
  2 siblings, 1 reply; 10+ messages in thread
From: erik quanstrom @ 2008-04-03 22:17 UTC (permalink / raw)
  To: 9fans

>
> % unmount /n/usb
> % unmount /n/disk
>
> But have no idea if that's the right way to go about it. Additionally
> if I eject it in this manner the next time I try to mount it using the
> first two commands I get a bunch of usb errors.

you have to restart usbd.  usbd doesn't handle device ejection as far
as i can tell.

> Also, why is the disk only available from the rc window that I used to
> mount it? In any other rc window I can't access the /n/usb mountpoint.
> I realize I'm probably missing something fundamental about plan 9
> (newbie here).

this is because rio puts each window in a sepeate namespace.  there are
two ways around this.  first, start this before you start rio.  (alternatively
use the plumber to give all new windows access.  plumb a string like
	Local 'cmd for everyone to see'
) alternatively, you can use /srv to post the fd.

- erik


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9fans] Unmount a USB stick?
  2008-04-03 22:11 [9fans] Unmount a USB stick? devrin talen
  2008-04-03 22:17 ` erik quanstrom
@ 2008-04-03 22:19 ` a
  2008-04-04 10:42 ` Richard Miller
  2 siblings, 0 replies; 10+ messages in thread
From: a @ 2008-04-03 22:19 UTC (permalink / raw)
  To: 9fans

// ...why is the disk only available from the rc window
// that I used to mount it?

Each rio window gets its own namespace from rio. Changes in
one will not affect others; this is central to the Plan 9's per-
process namespaces.

srvfs(4) is often useful for getting portions of one namespace
into another.
Anthony



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9fans] Unmount a USB stick?
  2008-04-03 22:17 ` erik quanstrom
@ 2008-04-03 22:28   ` geoff
  2008-04-03 22:48     ` erik quanstrom
  2008-04-03 23:58     ` devrin talen
  0 siblings, 2 replies; 10+ messages in thread
From: geoff @ 2008-04-03 22:28 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 570 bytes --]

I believe dossrv (which implements the fat filesystem) is synchronous,
so you shouldn't have to do anything special before removing the
stick.  What are the errors you get the next time you try to mount the
stick?

> you have to restart usbd.  usbd doesn't handle device ejection as
> far as i can tell.

I'm pretty sure that it's more nuanced than that.  I've been able to
eject and re-insert usb devices on uhci interfaces.  I think the
problems with usbd not noticing device additions and removals is
limited to ohci interfaces, and I'm not sure why yet.

[-- Attachment #2: Type: message/rfc822, Size: 2477 bytes --]

From: erik quanstrom <quanstro@coraid.com>
To: 9fans@9fans.net
Subject: Re: [9fans] Unmount a USB stick?
Date: Thu, 3 Apr 2008 18:17:42 -0400
Message-ID: <01044970cb30fd41a02e19818ead294e@coraid.com>

>
> % unmount /n/usb
> % unmount /n/disk
>
> But have no idea if that's the right way to go about it. Additionally
> if I eject it in this manner the next time I try to mount it using the
> first two commands I get a bunch of usb errors.

you have to restart usbd.  usbd doesn't handle device ejection as far
as i can tell.

> Also, why is the disk only available from the rc window that I used to
> mount it? In any other rc window I can't access the /n/usb mountpoint.
> I realize I'm probably missing something fundamental about plan 9
> (newbie here).

this is because rio puts each window in a sepeate namespace.  there are
two ways around this.  first, start this before you start rio.  (alternatively
use the plumber to give all new windows access.  plumb a string like
	Local 'cmd for everyone to see'
) alternatively, you can use /srv to post the fd.

- erik

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9fans] Unmount a USB stick?
  2008-04-03 22:28   ` geoff
@ 2008-04-03 22:48     ` erik quanstrom
  2008-04-03 23:58     ` devrin talen
  1 sibling, 0 replies; 10+ messages in thread
From: erik quanstrom @ 2008-04-03 22:48 UTC (permalink / raw)
  To: 9fans

> I'm pretty sure that it's more nuanced than that.  I've been able to
> eject and re-insert usb devices on uhci interfaces.  I think the
> problems with usbd not noticing device additions and removals is
> limited to ohci interfaces, and I'm not sure why yet.

this very well could be.  i have not been able to do much testing
with intel-style usb.

- erik


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9fans] Unmount a USB stick?
  2008-04-03 22:28   ` geoff
  2008-04-03 22:48     ` erik quanstrom
@ 2008-04-03 23:58     ` devrin talen
  2008-04-04  0:41       ` erik quanstrom
  1 sibling, 1 reply; 10+ messages in thread
From: devrin talen @ 2008-04-03 23:58 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Thu, Apr 3, 2008 at 6:28 PM,  <geoff@plan9.bell-labs.com> wrote:
> I believe dossrv (which implements the fat filesystem) is synchronous,
>  so you shouldn't have to do anything special before removing the
>  stick.  What are the errors you get the next time you try to mount the
>  stick?

If I have mounted the stick, then try to exit the rc window with which
I mounted it:

% exit

the window hangs indefinitely. If I delete the window, remove the
stick, reinsert it, then in a new rc window type:

% echo kill > /proc/86/notes # 86 is the pid of usbd
% usb/usbd
% usb/disk -l
usb/disk: describedevice: error reading usb device descriptor, got 0 of 18:

usb/disk: maxlun 0

and a few black boxes in the upper left of my screen with messages such as:

CleanTD 1/0: Error 00000001 ...

Usually at this point I just end up restarting the box, and I'll be
able to use the stick once again.

- Devrin


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9fans] Unmount a USB stick?
  2008-04-03 23:58     ` devrin talen
@ 2008-04-04  0:41       ` erik quanstrom
  2008-04-04  0:56         ` devrin talen
  0 siblings, 1 reply; 10+ messages in thread
From: erik quanstrom @ 2008-04-04  0:41 UTC (permalink / raw)
  To: 9fans

>
> % echo kill > /proc/86/notes # 86 is the pid of usbd
> % usb/usbd
> % usb/disk -l
> usb/disk: describedevice: error reading usb device descriptor, got 0 of 18:
>
> usb/disk: maxlun 0
>
> and a few black boxes in the upper left of my screen with messages such as:
>
> CleanTD 1/0: Error 00000001 ...
>
> Usually at this point I just end up restarting the box, and I'll be
> able to use the stick once again.

trick 'o the day: keep kernel messages from messing with rio:
	window -hide rc -c 'label kmesg ; tail -f /dev/kprint'
as long as you have someone reading kernel messages, they won't
be written directly to the screen.

what happens when you do the following:

	slay usbd|rc
	slay disk|rc
	usb/usbd; usb/disk -l


- erik


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9fans] Unmount a USB stick?
  2008-04-04  0:41       ` erik quanstrom
@ 2008-04-04  0:56         ` devrin talen
  0 siblings, 0 replies; 10+ messages in thread
From: devrin talen @ 2008-04-04  0:56 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Thu, Apr 3, 2008 at 8:41 PM, erik quanstrom <quanstro@quanstro.net> wrote:
>  trick 'o the day: keep kernel messages from messing with rio:
>         window -hide rc -c 'label kmesg ; tail -f /dev/kprint'
>  as long as you have someone reading kernel messages, they won't
>  be written directly to the screen.

Thanks!

>  what happens when you do the following:
>
>         slay usbd|rc
>         slay disk|rc
>         usb/usbd; usb/disk -l

% usb/usbd; usb/disk -l
usb/disk: maxlun 0

But then I try

% usbfat:
mount: mount /n/usb: '/n/disk/0' i/o on hungup channel

Is that an effect of me killing the window earlier?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9fans] Unmount a USB stick?
  2008-04-03 22:11 [9fans] Unmount a USB stick? devrin talen
  2008-04-03 22:17 ` erik quanstrom
  2008-04-03 22:19 ` a
@ 2008-04-04 10:42 ` Richard Miller
  2 siblings, 0 replies; 10+ messages in thread
From: Richard Miller @ 2008-04-04 10:42 UTC (permalink / raw)
  To: 9fans

> Additionally
> if I eject it in this manner the next time I try to mount it using the
> first two commands I get a bunch of usb errors.

There is a problem with usbd (and uhci?) on reinsertion of some
but not all devices.  Also the usbfat: script makes an entry in '#s'
which needs to be cleaned up.  You should find this works to undo
everything so the usb disk can be removed and reinserted:

  unmount /n/usb
  unmount /n/disk
  rm /srv/usbfat.$user
  kill usbd | rc
  usb/usbd

> Also, why is the disk only available from the rc window that I used to
> mount it?

To see the disk in another window, just type usbfat: there -- the
script uses the /srv/usbfat.$user entry to check for an existing service.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9fans] Unmount a USB stick?
@ 2008-04-04 13:23 Richard Miller
  0 siblings, 0 replies; 10+ messages in thread
From: Richard Miller @ 2008-04-04 13:23 UTC (permalink / raw)
  To: 9fans

I should have tried it myself before saying confidently:

> To see the disk in another window, just type usbfat: there

In fact usbfat: doesn't quite do the right thing.

You can either fix /rc/bin/usbfat: by moving the lines
	if (! test -e $disk)
		usb/disk $opts || exit 'no disk'
to follow the line
  if (! test -f /srv/usbfat.$user) {

or else just use
  mount -c /srv/usbfat.$user /n/usb
to mount an already-mounted usb disk in another window.



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-04-04 13:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-03 22:11 [9fans] Unmount a USB stick? devrin talen
2008-04-03 22:17 ` erik quanstrom
2008-04-03 22:28   ` geoff
2008-04-03 22:48     ` erik quanstrom
2008-04-03 23:58     ` devrin talen
2008-04-04  0:41       ` erik quanstrom
2008-04-04  0:56         ` devrin talen
2008-04-03 22:19 ` a
2008-04-04 10:42 ` Richard Miller
2008-04-04 13:23 Richard Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).