delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/07/13/09:06:43

X-Spam-Check-By: sourceware.org
Date: Fri, 13 Jul 2007 15:06:20 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: if [ -w branching: how to spot a locked USB stick
Message-ID: <20070713130620.GT6851@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <469715CF DOT 7090105 AT bonhard DOT uklinux DOT net> <46977404 DOT 6070105 AT byu DOT net>
Mime-Version: 1.0
In-Reply-To: <46977404.6070105@byu.net>
User-Agent: Mutt/1.4.2.2i
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Jul 13 06:45, Eric Blake wrote:
> According to fergus on 7/13/2007 12:03 AM:
> >     if [ -w /h ] ; then echo +W ;  else echo -W ; fi
> > 
> > tests a device located at /h (or /cygdrive/h) for write-ability: eg a
> > USB memory stick will echo +W and a CD will echo -W. If the stick is
> > locked, however, you still get +W.
> 
> Actually, this is a cygwin question.  Bash's [ command only reports what
> access("/h",W_OK) tells it to report, so the real question here is why
> cygwin1.dll thinks that a locked USB stick is writable.  And the answer
> may be that either cygwin doesn't ask Windows the correct question (in
> which case, http://cygwin.com/acronyms/#PTC), or that Windows lies (in
> which case, there is no way to work around it).

It's the latter.  The fact that the USB stick is locked doesn't
mean that the permission bits returned by the OS calls are augmented
to reflect the fact that the stick is not writable.  All permission
bits are still intact.  Only when actually trying to write to the device,
you'll get the Win32 error message equivalent of EROFS.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019