On Mon, Oct 26, 2009 at 01:16:15PM +0000, Matthew Booth wrote:
.. or the guestfish user who types 'cat
win:c:\windows\system32\blah.txt' and doesn't get the result they
intended. Essentially you need to do this in 2 cases: you read a path
from a config file, or you're accessing a file whose location you
already know. In either case, the additional call is just untidiness.
I don't understand this point.
Who told them to look at "c:\windows\system32\blah.txt"?
It must have come from a Windows config file, a Windows document or a
book, and that path is not case-sensitive.
> In any other case, using case_sensitive_path is almost certainly
> wrong, in fact not just slow but quite likely to be insecure too. You
> don't want a Linux config file that specifies /etc/something to
> randomly pick /etc/SOMETHING.
It's a very good point. You can fix this, though. When iterating down
the directory structure, you'll open a file to check if it's a
directory. At the same time, to fstatfs() to check what filesystem it's
on. By doing this you can choose directory-by-directory whether or not
to be case-sensitive. This should always be safe.
fstatfs doesn't tell you if a filesystem is case sensitive, and in any
case that is irrelevant. Think of the imaginary Windows-on-ext3 case
where you'd still have Windows containing case-insensitive
configuration paths, even if the filesystem is case-sensitive.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming blog:
http://rwmj.wordpress.com
Fedora now supports 80 OCaml packages (the OPEN alternative to F#)
http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora