Re: [DNG] slashes in FAT file names

2018-12-24 Thread Didier Kryn

Le 23/12/2018 à 18:16, k...@aspodata.se a écrit :

Didier:
...

    2) there isn't a function in the C library which permits to change
the name of a file (or open it), except by giving its whole pathname.
Eg. it's not possible to open it from its directory entry.

...

man openat
man renameat

int openat(int dirfd, const char *pathname, int flags);



    The file isn't refered by its directory entry, but by a file 
descriptor allowing to read the directory, and the relative pathname 
(which contains slashes). The slashes will be interpreted as a directory 
tree which doesnexist.


If it was possible to refer to the file by the /struct dirent/ 
associated to each file in the directory, obtained by readdir(dirfd), 
then it would solve the problem, but the only thing in /struct dirent/ 
which can be used to refer to the file is d_filename, which is its 
relative pathname.


   struct dirent {
   ino_t  d_ino;   /* Inode number */
   off_t  d_off;   /* Not an offset; see below */
   unsigned short d_reclen;    /* Length of this record */
   unsigned char  d_type;  /* Type of file; not supported
  by all filesystem types */
   char   d_name[256]; /* Null-terminated filename */
   };

            Didier

___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-23 Thread Rick Moen
Quoting Didier Kryn (k...@in2p3.fr):

>   Therefore I wonder how 'find' would do, unless fopen() accepts
> the pathological name, which I doubt of.

I'm pretty sure you're right, because upon reflection and testing 
'find . -inum N' returns a relative pathspec.  Example:

$ cd /tmp
/tmp $ ls -i
139003 access-2008q3.log
138995 access.log 
139004 apache.conf
/tmp $ find . -inum 139003
./access-2008q3.log
/tmp $

So the trick I mentioned is highly useful for a large number of _other_
varieties of pathological filename, such as ones with several control
characters, etc. -- but not for filenames containing one of the two
absolutely forbidden characters (slash and null).

___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-23 Thread Olaf Meeuwissen
Hi Karl,

k...@aspodata.se writes:

> Didier:
> ...
>>   2) there isn't a function in the C library which permits to change
>> the name of a file (or open it), except by giving its whole pathname.
>> Eg. it's not possible to open it from its directory entry.
> ...
>
> man openat
> man renameat

These still require a *pathname*, which is problematic in the case
Hendrik initially described as it contains a `/`.

I'm not sure whether Didier meant absolute or relative pathname but I'm
fairly certain that he was trying to point out that you cannot open or
rename a file using just its inode.

Hope this helps,
--
Olaf Meeuwissen, LPIC-2FSF Associate Member since 2004-01-27
 GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13  F43E B8A4 A88A F84A 2DD9
 Support Free Softwarehttps://my.fsf.org/donate
 Join the Free Software Foundation  https://my.fsf.org/join
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-23 Thread Eric Pozharski
On Sat, Dec 22, 2018 at 11:13:55AM -0500, Hendrik Boom wrote:

> Let me thank everyone for their advice;  it looks as if I have enough
> ideas to try out now.  I'll do that when I'm fully awake an report
> back on what worked.
*SKIP*
> > ls -l lists them like this:
> > 
> > -rw-r--r-- 1 hendrik hendrik   0 Sep  1  2007 06 - Track 6.mq3
> > -? ? ?   ? ?? 07/TRA~1.MP3
> > -rw-r--r-- 1 hendrik hendrik 3585716 Sep  1  2007 08-URA~1.MP3
*CUT*

Sorry being late to the party and I have multiple confirmations to
different mails, so these went in one bag.

Yes, kernel somehow constructs i-node numbers from VFAT (which doesn't
have i-node per se).  Thus, in your listing, multiple files with same
i-node -- filesystem is corrupted.

Yes, mtools can manipulate 8.3 FAT names instead of VFAT names.  But, as
we confirmed, filesystem is corrupted -- it won't help either.

If everything fails -- consider magicrescue.

-- 
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-23 Thread karl
Didier:
...
>    2) there isn't a function in the C library which permits to change 
> the name of a file (or open it), except by giving its whole pathname. 
> Eg. it's not possible to open it from its directory entry.
...

man openat
man renameat

Regards,
/Karl Hammar

---
Aspö Data
Lilla Aspö 148
S-742 94 Östhammar
Sweden


___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-23 Thread Didier Kryn

Le 22/12/2018 à 07:24, Rick Moen a écrit :

Quoting Hendrik Boom (hend...@topoi.pooq.com):


I have a 32GiB microSD card an am reying to read it on my Devuan system.
I munted it with a simpel mount/dev/sdb1 /nedia/hendrik/

It reads almost everything fine, except for a few files whose names
contain '/' characters.  I can handle the other horribly weird
characters in file names -- emacs Rename in the directory
editor works just fine.  But the names containing '/'s even have
emacs stymied.

Rename them.

1.  'ls -i'   #Gets the inode number.
2.  'find . -inum "inode-number-from-ls -i" -exec mv {} "newfilename" \;'


    Didn't try (because I haven't such filenames), but wonder how it 
would be possible.


  1) it is impossible in Linux to modify a file without access 
permission, and permissions are not associated to the inode but to the 
whole directory tree above.


  2) there isn't a function in the C library which permits to change 
the name of a file (or open it), except by giving its whole pathname. 
Eg. it's not possible to open it from its directory entry.


  Therefore I wonder how 'find' would do, unless fopen() accepts the 
pathological name, which I doubt of.


  Sorry to be so negative. Mount options suggested by others are 
probably a better idea.


        Didier



___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-23 Thread Hendrik Boom
On Sun, Dec 23, 2018 at 09:45:47AM +0100, Martin Steigerwald wrote:
> Hendrik Boom - 23.12.18, 04:15:
> > On Sun, Dec 23, 2018 at 02:35:35AM +0100, Gonzalo Pérez de Olaguer 
> Córdoba wrote:
> > > Hi Hendrik,
> > > 
> > > El Sat, 22 Dec 2018 18:20:22 -0500
> > > 
> > > Hendrik Boom  escribió:
> > > > > > > Rename them.
> > > > > > > 
> > > > > > > 1.  'ls -i'   #Gets the inode number.
> > > > > > > 2.  'find . -inum "inode-number-from-ls -i" -exec mv {}
> > > > > > > "newfilename" \;'> > 
> > > > Yes, I see inode numbers.  Unfortunately, the files with slashes
> > > > in
> > > > their names have question marks for their inode numbers.
> > > > 
> > > > 2522 @  2523 ?  2526 ?? 07/TRA~1.MP3  
> > > > 2516
> > > 
> > > You don't have to use inodes at all. Anything provided by find to
> > > match the file will do. For example, try something like:
> > > 
> > > find . -type f -iname '07*TRA*MP3' -exec ...
> > 
> > I'm starting to think the way to go about this is to use a utility
> > that bypasses the kernel's VFAT file system and treats /dev/sdb1 as a
> > block device.  A few have been suggested.  Maybe a hex editor.  Maybe
> > fsck.vfat.  Maybe mtools, possibly modified since the documentation
> > https://www.gnu.org/software/mtools/manual/mtools.html#default-values
> > says:
> 
> Well mtools act directly on an FAT filesystem and do not use the vfat/
> msdos filesystem drivers in Linux. It has the "mren" command to rename 
> files.
> 
> However I still assume that this FAT filesystem is just corrupted and 
> that maybe not even mtools is able to do the rename.
> 
> What I'd do is:
> 
> First copy the whole block device with the filesystem block by block into 
> a file.

Already did that.

> Then make a copy of that file. Only work from the copy of the file.

That's actually a good idea -- thanks.  I hadn't thought of that.  I'll 
dig up some extra storage somewhere.  Don't have space on the laptop 
SSD for a second 32014073856-byte file.

> 
> Then you can throw 'mren', 'fsck.vfat' / 'fsck.msdos', use a hex editor, 
> or well just 'photorec' on it. And due to working with a copy of the 
> copy you have unlimited attempts.
> 
> Thanks,
> -- 
> Martin
> 
> 
> ___
> Dng mailing list
> Dng@lists.dyne.org
> https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-23 Thread Martin Steigerwald
Hendrik Boom - 23.12.18, 04:15:
> On Sun, Dec 23, 2018 at 02:35:35AM +0100, Gonzalo Pérez de Olaguer 
Córdoba wrote:
> > Hi Hendrik,
> > 
> > El Sat, 22 Dec 2018 18:20:22 -0500
> > 
> > Hendrik Boom  escribió:
> > > > > > Rename them.
> > > > > > 
> > > > > > 1.  'ls -i'   #Gets the inode number.
> > > > > > 2.  'find . -inum "inode-number-from-ls -i" -exec mv {}
> > > > > > "newfilename" \;'> > 
> > > Yes, I see inode numbers.  Unfortunately, the files with slashes
> > > in
> > > their names have question marks for their inode numbers.
> > > 
> > > 2522 @  2523 ?  2526 ?? 07/TRA~1.MP3  
> > > 2516
> > 
> > You don't have to use inodes at all. Anything provided by find to
> > match the file will do. For example, try something like:
> > 
> > find . -type f -iname '07*TRA*MP3' -exec ...
> 
> I'm starting to think the way to go about this is to use a utility
> that bypasses the kernel's VFAT file system and treats /dev/sdb1 as a
> block device.  A few have been suggested.  Maybe a hex editor.  Maybe
> fsck.vfat.  Maybe mtools, possibly modified since the documentation
> https://www.gnu.org/software/mtools/manual/mtools.html#default-values
> says:

Well mtools act directly on an FAT filesystem and do not use the vfat/
msdos filesystem drivers in Linux. It has the "mren" command to rename 
files.

However I still assume that this FAT filesystem is just corrupted and 
that maybe not even mtools is able to do the rename.

What I'd do is:

First copy the whole block device with the filesystem block by block into 
a file. Then make a copy of that file. Only work from the copy of the file.

Then you can throw 'mren', 'fsck.vfat' / 'fsck.msdos', use a hex editor, 
or well just 'photorec' on it. And due to working with a copy of the 
copy you have unlimited attempts.

Thanks,
-- 
Martin


___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread Olaf Meeuwissen
Hi Steve,

Steve Litt writes:

> On Sat, 22 Dec 2018 02:38:42 -0800
> Rick Moen  wrote:
>
>> Quoting Olaf Meeuwissen (paddy-h...@member.fsf.org):
>>
>> > On any Unix-like system I've come across the '/' (and '\0') are
>> > about the only character that cannot be used in a filename.
>>
>> That and null are the only disallowed characters.  It's in the Single
>> Unix Specification.
>> http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_170
>
> Regardless of any spec, I wouldn't be caught using anything in a
> filename except letters, numbers, dots and underscores.

Everywhere around me あいうえお and 一二三 are perfectly fine letters
and numbers ;-P

And there are at least three encodings to store them disk (in file names
or otherwise).  Fortunately, EUC-JP has pretty much gone the way of the
dinosaur but Shift_JIS (MS-932, really) is still a sad fact of everyday
life.

> Once in a while I'll let somebody else's dash go through. Some day I
> should write a filename cleaner to get rid of all that junk windows
> people just love putting in their filenames.

Hope this enlightens,
--
Olaf Meeuwissen, LPIC-2FSF Associate Member since 2004-01-27
 GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13  F43E B8A4 A88A F84A 2DD9
 Support Free Softwarehttps://my.fsf.org/donate
 Join the Free Software Foundation  https://my.fsf.org/join
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread Olaf Meeuwissen
Hi,

Hendrik Boom writes:

> hendrik@midwinter:/media/hendrik/FC30-3DA9/Pure disco$ ls -i
> ls: cannot access '07/TRA~1.MP3': No such file or directory
> ls: cannot access '18/TRA~1.MP3': No such file or directory
> 2522 @  2523 ?  2526 ?? 07/TRA~1.MP3   2516
> 16-TRA~1.M?3 2520 21 - Traɣk 21.mp3
> 2522 @  2521 ?  2524 ? 2508 08-URA~1.MP3   2517
> 17-TRA~1.MP3 2525 Ç
> 2522 @  2521 ?  2502 01-TRA~1.MP│  2509 09=TRA~1.MP3  ?
> 18/TRA~1.MP3 2525 Ç
> 2522 @  2521 ?  2504 03 - Track 3.mp3  2503 0" - Track 2.mp䀳  2518 19
> - Ŕrack 19.mp3䀀  2510 q0-TRA~1.MP3
> 2523 ?  2527 ?  2505 04,TRA~1.MP3  2512 12!- Track 12.mŰ3  2515
> 1%-TRA~1.MP3
> 2523 ?  2526 ?  2506 05  Track 5.mp3   2513 13-TRA~1.MP3   2511 !1
> - Track 11.mp3ࠀ
> 2523 ?  2526 ?  2507 06 - Track 6.mq3  2514 14 - Track 14.mp3  2519
> 20-T╥A~1.MP3

Hmm, looks like the directory contains a pile of files that should match
one of these patterns

  [0-9][0-9]-TRA~1.MP#
  [0-9][0-9] - Track [0-9][0-9].mp3

The first pattern is indicative of FAT12/FAT16, the second of VFAT.
Seriously suspect that the directory entry got whacked in the head and
is corrupted.

You may find

 https://www.win.tue.nl/~aeb/linux/fs/fat/fat-1.html

useful if you go the route of hexediting that directory entry.

Hope this helps,
--
Olaf Meeuwissen, LPIC-2FSF Associate Member since 2004-01-27
 GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13  F43E B8A4 A88A F84A 2DD9
 Support Free Softwarehttps://my.fsf.org/donate
 Join the Free Software Foundation  https://my.fsf.org/join
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread Hendrik Boom
On Sun, Dec 23, 2018 at 02:35:35AM +0100, Gonzalo Pérez de Olaguer Córdoba 
wrote:
> Hi Hendrik,
> 
> El Sat, 22 Dec 2018 18:20:22 -0500
> Hendrik Boom  escribió:
> 
> > > > > Rename them.
> > > > > 
> > > > > 1.  'ls -i'   #Gets the inode number.
> > > > > 2.  'find . -inum "inode-number-from-ls -i" -exec mv {} "newfilename" 
> > > > > \;'
> > > > > 
> > 
> > Yes, I see inode numbers.  Unfortunately, the files with slashes in 
> > their names have question marks for their inode numbers.
> > 
> > 2522 @  2523 ?  2526 ?? 07/TRA~1.MP3   2516 
> 
> You don't have to use inodes at all. Anything provided by find to match the 
> file
> will do. For example, try something like:
> 
> find . -type f -iname '07*TRA*MP3' -exec ...

I'm starting to think the way to go about this is to use a utility that 
bypasses the kernel's VFAT file system and treats /dev/sdb1 as a block 
device.  A few have been suggested.  Maybe a hex editor.  Maybe 
fsck.vfat.  Maybe mtools, possibly modified since the documentation 
https://www.gnu.org/software/mtools/manual/mtools.html#default-values
says: 

Subdirectory names can use either the ’/’ or ’\’ separator.

and that's just how I *don't* want it to treat the '/' in the DOS name.

But maybe a neighbour's old Windows machine.

But the guy that gave me this sd card a few years ago happens to be 
visiting me soon from out of town, so I'll show him what's up.

-- hendrik
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread karl
Gonzalo:
> Hi Hendrik,
> El Sat, 22 Dec 2018 18:20:22 -0500
> Hendrik Boom  escribió:
> > > > > Rename them.
> > > > > 
> > > > > 1.  'ls -i'   #Gets the inode number.
> > > > > 2.  'find . -inum "inode-number-from-ls -i" -exec mv {} "newfilename" 
> > > > > \;'
> > Yes, I see inode numbers.  Unfortunately, the files with slashes in 
> > their names have question marks for their inode numbers.
> > 2522 @  2523 ?  2526 ?? 07/TRA~1.MP3   2516 
> You don't have to use inodes at all. Anything provided by find to match the 
> file
> will do. For example, try something like:
> find . -type f -iname '07*TRA*MP3' -exec ...

I think all of the above will fail since you can opendir()/readdir()
to look at file names and inodes numbers all you like, but there is
no open()/rename() etc. system call that takes an inode number.
They all take a pathname. So something that works on the file system
level seems to be the only solution.

Regards,
/Karl Hammar

---
Aspö Data
Lilla Aspö 148
S-742 94 Östhammar
Sweden


___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread Hendrik Boom
On Sun, Dec 23, 2018 at 02:35:35AM +0100, Gonzalo Pérez de Olaguer Córdoba 
wrote:
> Hi Hendrik,
> 
> El Sat, 22 Dec 2018 18:20:22 -0500
> Hendrik Boom  escribió:
> 
> > > > > Rename them.
> > > > > 
> > > > > 1.  'ls -i'   #Gets the inode number.
> > > > > 2.  'find . -inum "inode-number-from-ls -i" -exec mv {} "newfilename" 
> > > > > \;'
> > > > > 
> > 
> > Yes, I see inode numbers.  Unfortunately, the files with slashes in 
> > their names have question marks for their inode numbers.
> > 
> > 2522 @  2523 ?  2526 ?? 07/TRA~1.MP3   2516 
> 
> You don't have to use inodes at all. Anything provided by find to match the 
> file
> will do. For example, try something like:
> 
> find . -type f -iname '07*TRA*MP3' -exec ...

Wouldn't find just try and stick the name of the file in for the {}, 
and  then wouldn't mv have the same trouble I'm having with my other 
commands, namely, that the name has a slash in it and that the slash 
will get interpreted as a directory name separator rather then as an 
ordinary part of the filename?

Is there a way of naming a file using the inode number?  Like 
/dev/sdb1/2527 or some such?

Of course, this syntax won't work in the case of an inode within a file 
used as a block device.

-- hendrik

> 
> 
> -- 
>Gonzalo Pérez de Olaguer Córdoba   s...@gpoc.es
>   -=- buscando empleo desde 1988 -=-   www.gpoc.es 
> 
> PGP: 3F87 CCE7 8B35 8C06 E637  2D57 5723 9984 718C A614
> ___
> Dng mailing list
> Dng@lists.dyne.org
> https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread Gonzalo Pérez de Olaguer Córdoba
Hi Hendrik,

El Sat, 22 Dec 2018 18:20:22 -0500
Hendrik Boom  escribió:

> > > > Rename them.
> > > > 
> > > > 1.  'ls -i'   #Gets the inode number.
> > > > 2.  'find . -inum "inode-number-from-ls -i" -exec mv {} "newfilename" 
> > > > \;'
> > > > 
> 
> Yes, I see inode numbers.  Unfortunately, the files with slashes in 
> their names have question marks for their inode numbers.
> 
> 2522 @  2523 ?  2526 ?? 07/TRA~1.MP3   2516 

You don't have to use inodes at all. Anything provided by find to match the file
will do. For example, try something like:

find . -type f -iname '07*TRA*MP3' -exec ...


-- 
   Gonzalo Pérez de Olaguer Córdoba   s...@gpoc.es
  -=- buscando empleo desde 1988 -=-   www.gpoc.es 

PGP: 3F87 CCE7 8B35 8C06 E637  2D57 5723 9984 718C A614
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread karl
Hendrik:
> On Sat, Dec 22, 2018 at 02:42:13PM -0800, Rick Moen wrote:
> > Quoting Hendrik Boom (hend...@topoi.pooq.com):
> > > On Fri, Dec 21, 2018 at 10:24:24PM -0800, Rick Moen wrote:
...
> > > > Rename them.
> > > > 
> > > > 1.  'ls -i'   #Gets the inode number.
> > > > 2.  'find . -inum "inode-number-from-ls -i" -exec mv {} "newfilename" 
> > > > \;'
...
> Yes, I see inode numbers.  Unfortunately, the files with slashes in 
> their names have question marks for their inode numbers.
> 
> hendrik@midwinter:/media/hendrik/FC30-3DA9/Pure disco$ ls -i
> ls: cannot access '07/TRA~1.MP3': No such file or directory
> ls: cannot access '18/TRA~1.MP3': No such file or directory
> 2522 @  2523 ?  2526 ?? 07/TRA~1.MP3   2516 
...

Perhaps you can see them if you tell ls to not to sort the entries:
ls -iU1

If that doesn't work, you could possible use the example program in
man getdents.

Regards,
/Karl Hammar

---
Aspö Data
Lilla Aspö 148
S-742 94 Östhammar
Sweden


___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread Rick Moen
Quoting Hendrik Boom (hend...@topoi.pooq.com):

> Yes, I see inode numbers.  Unfortunately, the files with slashes in 
> their names have question marks for their inode numbers.
[snip]

Wow, that's meshugge.  ;->

Perhaps some lateral thinking will help.  What about booting a FreeDOS
v. 1.2 image, and then doing a 'ren' or 'copy' operation there?

http://www.freedos.org/
https://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/

-- 
May those that love us love us; and those that don't love us, may
God turn their hearts; and if he doesn't turn their hearts, may
he turn their ankles so we'll know them by their limping.
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread Hendrik Boom
On Sat, Dec 22, 2018 at 02:42:13PM -0800, Rick Moen wrote:
> Quoting Hendrik Boom (hend...@topoi.pooq.com):
> 
> > On Fri, Dec 21, 2018 at 10:24:24PM -0800, Rick Moen wrote:
> > > Quoting Hendrik Boom (hend...@topoi.pooq.com):
> > > 
> > > > I have a 32GiB microSD card an am reying to read it on my Devuan system.
> > > > I munted it with a simpel mount /dev/sdb1 /nedia/hendrik/
> > > > 
> > > > It reads almost everything fine, except for a few files whose names 
> > > > contain '/' characters.  I can handle the other horribly weird 
> > > > characters in file names -- emacs Rename in the directory 
> > > > editor works just fine.  But the names containing '/'s even have 
> > > > emacs stymied.
> > > 
> > > Rename them.
> > > 
> > > 1.  'ls -i'   #Gets the inode number.
> > > 2.  'find . -inum "inode-number-from-ls -i" -exec mv {} "newfilename" \;'
> > > 
> > > Man, I hate files with pathological filenames, and some of the
> > > other-OS-originating examples are among the worst.
> > 
> > Do VFAT files systems have inode numbers?
> 
> The only way Unix ever dereferences files is by inode number, so I think
> (speculate) that the Linux vfat filesystem layer allocates them to
> observed files.  Anyway, I'd give the inode trick a try.

Yes, I see inode numbers.  Unfortunately, the files with slashes in 
their names have question marks for their inode numbers.

hendrik@midwinter:/media/hendrik/FC30-3DA9/Pure disco$ ls -i
ls: cannot access '07/TRA~1.MP3': No such file or directory
ls: cannot access '18/TRA~1.MP3': No such file or directory
2522 @  2523 ?  2526 ?? 07/TRA~1.MP3   2516 
16-TRA~1.M?3 2520 21 - Traɣk 21.mp3
2522 @  2521 ?  2524 ? 2508 08-URA~1.MP3   2517 
17-TRA~1.MP3 2525 Ç
2522 @  2521 ?  2502 01-TRA~1.MP│  2509 09=TRA~1.MP3  ? 
18/TRA~1.MP3 2525 Ç
2522 @  2521 ?  2504 03 - Track 3.mp3  2503 0" - Track 2.mp䀳  2518 19 
- Ŕrack 19.mp3䀀  2510 q0-TRA~1.MP3
2523 ?  2527 ?  2505 04,TRA~1.MP3  2512 12!- Track 12.mŰ3  2515 
1%-TRA~1.MP3
2523 ?  2526 ?  2506 05  Track 5.mp3   2513 13-TRA~1.MP3   2511 !1 
- Track 11.mp3ࠀ
2523 ?  2526 ?  2507 06 - Track 6.mq3  2514 14 - Track 14.mp3  2519 
20-T╥A~1.MP3

-- hendrik
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread Rick Moen
Quoting Hendrik Boom (hend...@topoi.pooq.com):

> On Fri, Dec 21, 2018 at 10:24:24PM -0800, Rick Moen wrote:
> > Quoting Hendrik Boom (hend...@topoi.pooq.com):
> > 
> > > I have a 32GiB microSD card an am reying to read it on my Devuan system.
> > > I munted it with a simpel mount /dev/sdb1 /nedia/hendrik/
> > > 
> > > It reads almost everything fine, except for a few files whose names 
> > > contain '/' characters.  I can handle the other horribly weird 
> > > characters in file names -- emacs Rename in the directory 
> > > editor works just fine.  But the names containing '/'s even have 
> > > emacs stymied.
> > 
> > Rename them.
> > 
> > 1.  'ls -i'   #Gets the inode number.
> > 2.  'find . -inum "inode-number-from-ls -i" -exec mv {} "newfilename" \;'
> > 
> > Man, I hate files with pathological filenames, and some of the
> > other-OS-originating examples are among the worst.
> 
> Do VFAT files systems have inode numbers?

The only way Unix ever dereferences files is by inode number, so I think
(speculate) that the Linux vfat filesystem layer allocates them to
observed files.  Anyway, I'd give the inode trick a try.

___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread Steve Litt
On Sat, 22 Dec 2018 02:38:42 -0800
Rick Moen  wrote:

> Quoting Olaf Meeuwissen (paddy-h...@member.fsf.org):
> 
> > On any Unix-like system I've come across the '/' (and '\0') are
> > about the only character that cannot be used in a filename.
> 
> That and null are the only disallowed characters.  It's in the Single
> Unix Specification.
> http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_170

Regardless of any spec, I wouldn't be caught using anything in a
filename except letters, numbers, dots and underscores. Once in a while
I'll let somebody else's dash go through. Some day I should write a
filename cleaner to get rid of all that junk windows people just love
putting in their filenames.

 
SteveT

Steve Litt 
December 2018 featured book: Rapid Learning for the 21st Century
http://www.troubleshooters.com/rl21
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread Hendrik Boom
Let me thank everyone for their advice;  it looks as if I have enough 
ideas to try out now.  I'll do that when I'm fully awake an report back 
on what worked.

-- hendrik

On Fri, Dec 21, 2018 at 10:23:14PM -0500, Hendrik Boom wrote:
> I have a 32GiB microSD card an am reying to read it on my Devuan system.
> I munted it with a simpel mount /dev/sdb1 /nedia/hendrik/
> 
> It reads almost everything fine, except for a few files whose names 
> contain '/' characters.  I can handle the other horribly weird 
> characters in file names -- emacs Rename in the directory 
> editor works just fine.  But the names containing '/'s even have 
> emacs stymied.
> 
> ls -l lists them like this:
> 
> -rw-r--r-- 1 hendrik hendrik   0 Sep  1  2007 06 - Track 6.mq3
> -? ? ?   ? ?? 07/TRA~1.MP3
> -rw-r--r-- 1 hendrik hendrik 3585716 Sep  1  2007 08-URA~1.MP3
> 
> With the slash, it can't even figure out the permissions, ownership, or 
> file size.  Preumably some parts of the system interpret the '/' as the 
> directory name separator, and in this file system that's not what it 
> is.
> 
> Does anyone have any ideas here other than begging, borrowing, or 
> buying a Windows system?
> 
> -- hendrik
> 
> ___
> Dng mailing list
> Dng@lists.dyne.org
> https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread Hendrik Boom
On Sat, Dec 22, 2018 at 11:37:32AM +, Adam Sampson via Dng wrote:
> Hendrik Boom  writes:
> 
> > -? ? ?   ? ?? 07/TRA~1.MP3
> 
> As others have said, / isn't a valid character in Windows filenames, so
> finding a Windows machine probably won't help (perhaps this is just a
> very unlucky random bitflip, or it was written on some embedded device
> that doesn't implement the FAT filename rules properly).
> 
> "fsck.fat" from dosfstools usually does a decent job of fixing FAT
> filesystem errors. The man page says it'll check for invalid filenames,
> so that'd be worth a try.

Perhaps first dd the entire card to a backup file just in case.

> 
> Alternatively, the FAT directory format is very straightforward, so you
> could fire up a hex editor like "tweak" on the block device, do a string
> search for the invalid filename, and overwrite it with something more
> reasonable.

This looks promising, too.

-- hendrik

> 
> -- 
> Adam Sampson  
> ___
> Dng mailing list
> Dng@lists.dyne.org
> https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread Hendrik Boom
On Sat, Dec 22, 2018 at 10:37:44AM +, marc wrote:
> Hello:
> 
> > -? ? ?   ? ?? 07/TRA~1.MP3
> 
> > With the slash, it can't even figure out the permissions, ownership, or 
> > file size.  Preumably some parts of the system interpret the '/' as the 
> > directory name separator, and in this file system that's not what it 
> > is.
> > 
> > Does anyone have any ideas here other than begging, borrowing, or 
> > buying a Windows system?
> 
> Try mtools ? But also consider the possibility that the card may be 
> corrupted in somehow...

Looks like that could help.  It handles VFAT.  But treats '/' to mean 
the same as '\'.  But that might just be an easy code change, feasible 
because of freedom.

Given some of the other file names in that directory, there does seem 
to be corruption.  But those other files contain mp3 files that do play 
correctly.

-- hendrik

> 
> regards
> 
> marc
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread Hendrik Boom
On Sat, Dec 22, 2018 at 05:15:55PM +0900, Olaf Meeuwissen wrote:
> Hi Hendrik,
> 
> Hendrik Boom writes:
> 
> > I have a 32GiB microSD card an am reying to read it on my Devuan system.
> > I munted it with a simpel mount /dev/sdb1 /nedia/hendrik/
> 
> You might want to try adding a suitable mount option there.  Not sure if
> it's mounted as FAT or VFAT or whatever, but scour the options part of
> the appropriate manual page.

The mount command tells me it already *is* mounted as VFAT.
Which is what I's expect of a 32G sd card -- presumably SDHC.

> 
> > It reads almost everything fine, except for a few files whose names
> > contain '/' characters.  I can handle the other horribly weird
> > characters in file names
> 
> Here `convmv` might come in handy.  I often use that to clean up the
> "mess" after extracting zip archives with Shi*t_JIS file names on a
> UTF-8 using file system.  Guessing your "horribly weird characters" are
> ISO-8859-{1,4,10,15}, (or whatever IBM code page Microsoft saw fit to
> appropriate for those).

As long as convmv uses the file system provided by the kernel, it will 
treat slashes as directory name separators.  It looks like a mechanism 
to use when names are untypeable.  But it looks as if it uses the 
kernel's rename facility just like anything else.

Still, something to try when other attacks have failed.

> 
> > -- emacs Rename in the directory editor works just fine.  But the
> > names containing '/'s even have emacs stymied.

Presumably because of the same kernel's file-system's name restrictions

> 
> # Hoping that Emacs on Windows isn't ;-)  But fully expect it to be
> # stymied by file names with a `\` in it :-P

Worth a try if I get to a Windows system.

-- hendrik


> 
> > ls -l lists them like this:
> >
> > -rw-r--r-- 1 hendrik hendrik   0 Sep  1  2007 06 - Track 6.mq3
> > -? ? ?   ? ?? 07/TRA~1.MP3
> > -rw-r--r-- 1 hendrik hendrik 3585716 Sep  1  2007 08-URA~1.MP3
> 
> That `~1` looks a lot like you are actually dealing with a VFAT file
> system.  How do things look after a
> 
>   mount -t vfat /dev/sdb1 /media/hendrik/
> 
> > With the slash, it can't even figure out the permissions, ownership, or
> > file size.  Preumably some parts of the system interpret the '/' as the
> > directory name separator, and in this file system that's not what it
> > is.
> 
> On any Unix-like system I've come across the '/' (and '\0') are about
> the only character that cannot be used in a filename.  As mentioned
> above check the mount.vfat (or mount.fat or mount.cifs?) manual pages
> for options that might transparently "fix up" the file name.

It is already mounted as a vfat filesystem.
The vfat uni_xlate offers faint hope, because it translates the 
character set.  It converts odd Unicode characters in file names using 
escape sequences involving ':', because ':' is apparently illegal in 
VFAT file names.  (perhaps a drive letter designator on Windows?)

Perhaps, just perhaps, it treats a slash to be a Unicode vagary?  
Unlikely, but worth a try.

> 
> # Yes, you can use `\n` in a file name ... but please don't.
> 
> > Does anyone have any ideas here other than begging, borrowing, or
> > buying a Windows system?
> 
> It's an SD card, right?  Asking a friendly neighbour to rename the
> file(s) in question may be the quickest way out of your conundrum.

Yes, indeed, but it would not be good publicity for Linux.  A secondary 
consideration.

-- hendrik
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread Hendrik Boom
On Fri, Dec 21, 2018 at 10:24:24PM -0800, Rick Moen wrote:
> Quoting Hendrik Boom (hend...@topoi.pooq.com):
> 
> > I have a 32GiB microSD card an am reying to read it on my Devuan system.
> > I munted it with a simpel mount /dev/sdb1 /nedia/hendrik/
> > 
> > It reads almost everything fine, except for a few files whose names 
> > contain '/' characters.  I can handle the other horribly weird 
> > characters in file names -- emacs Rename in the directory 
> > editor works just fine.  But the names containing '/'s even have 
> > emacs stymied.
> 
> Rename them.
> 
> 1.  'ls -i'   #Gets the inode number.
> 2.  'find . -inum "inode-number-from-ls -i" -exec mv {} "newfilename" \;'
> 
> Man, I hate files with pathological filenames, and some of the
> other-OS-originating examples are among the worst.

Do VFAT files systems have inode numbers?

-- hendrik
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread Hendrik Boom
On Fri, Dec 21, 2018 at 10:00:00PM -0600, goli...@dyne.org wrote:
> On 2018-12-21 21:23, Hendrik Boom wrote:
> > 
> > Does anyone have any ideas here other than begging, borrowing, or
> > buying a Windows system?
> > 
> > -- hendrik
> > 
> > ___
> > 
> 
> Don't use / in filenames.  I thought it was a no-no.  Yes it is:
> 
> "File names in Linux can contain any characters other than (1) a forward
> slash ( / ), which is reserved for use as the name of the root directory
> (i.e., the directory that contains all other directories and files) and as a
> directory separator . . ."

I know, I know.  It wasn't me that put the filenames there.  Presumably 
the Microsoft system he used didn't have that restriction.

I also know that modern Windows does have this restriction.  Presumably 
dating back historically to the days of original DOS, ahidh used 
slashes as a marker for command language flags.

But back then a program could still stick anything at all in the file 
name.  And some did.

- hendrik
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread Martin Steigerwald
Hello Hendrik,

Hendrik Boom - 22.12.18, 04:23:
> ls -l lists them like this:
> 
> -rw-r--r-- 1 hendrik hendrik   0 Sep  1  2007 06 - Track 6.mq3
> -? ? ?   ? ?? 07/TRA~1.MP3

 instead of useful metadata can be a sign of filesystem corruption. 
There might be something in kernel log about that.

I'd try fsck.vfat and if that does not work use photorec from the 
testdisk package to recover the image.

Best of success,
-- 
Martin


___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread Adam Sampson via Dng
Hendrik Boom  writes:

> -? ? ?   ? ?? 07/TRA~1.MP3

As others have said, / isn't a valid character in Windows filenames, so
finding a Windows machine probably won't help (perhaps this is just a
very unlucky random bitflip, or it was written on some embedded device
that doesn't implement the FAT filename rules properly).

"fsck.fat" from dosfstools usually does a decent job of fixing FAT
filesystem errors. The man page says it'll check for invalid filenames,
so that'd be worth a try.

Alternatively, the FAT directory format is very straightforward, so you
could fire up a hex editor like "tweak" on the block device, do a string
search for the invalid filename, and overwrite it with something more
reasonable.

-- 
Adam Sampson  
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread Rick Moen
Quoting Olaf Meeuwissen (paddy-h...@member.fsf.org):

> On any Unix-like system I've come across the '/' (and '\0') are about
> the only character that cannot be used in a filename.  

That and null are the only disallowed characters.  It's in the Single
Unix Specification.
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_170

___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread marc
Hello:

> -? ? ?   ? ?? 07/TRA~1.MP3

> With the slash, it can't even figure out the permissions, ownership, or 
> file size.  Preumably some parts of the system interpret the '/' as the 
> directory name separator, and in this file system that's not what it 
> is.
> 
> Does anyone have any ideas here other than begging, borrowing, or 
> buying a Windows system?

Try mtools ? But also consider the possibility that the card may be 
corrupted in somehow...

regards

marc
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-22 Thread Olaf Meeuwissen
Hi Hendrik,

Hendrik Boom writes:

> I have a 32GiB microSD card an am reying to read it on my Devuan system.
> I munted it with a simpel mount /dev/sdb1 /nedia/hendrik/

You might want to try adding a suitable mount option there.  Not sure if
it's mounted as FAT or VFAT or whatever, but scour the options part of
the appropriate manual page.

> It reads almost everything fine, except for a few files whose names
> contain '/' characters.  I can handle the other horribly weird
> characters in file names

Here `convmv` might come in handy.  I often use that to clean up the
"mess" after extracting zip archives with Shi*t_JIS file names on a
UTF-8 using file system.  Guessing your "horribly weird characters" are
ISO-8859-{1,4,10,15}, (or whatever IBM code page Microsoft saw fit to
appropriate for those).

> -- emacs Rename in the directory editor works just fine.  But the
> names containing '/'s even have emacs stymied.

# Hoping that Emacs on Windows isn't ;-)  But fully expect it to be
# stymied by file names with a `\` in it :-P

> ls -l lists them like this:
>
> -rw-r--r-- 1 hendrik hendrik   0 Sep  1  2007 06 - Track 6.mq3
> -? ? ?   ? ?? 07/TRA~1.MP3
> -rw-r--r-- 1 hendrik hendrik 3585716 Sep  1  2007 08-URA~1.MP3

That `~1` looks a lot like you are actually dealing with a VFAT file
system.  How do things look after a

  mount -t vfat /dev/sdb1 /media/hendrik/

> With the slash, it can't even figure out the permissions, ownership, or
> file size.  Preumably some parts of the system interpret the '/' as the
> directory name separator, and in this file system that's not what it
> is.

On any Unix-like system I've come across the '/' (and '\0') are about
the only character that cannot be used in a filename.  As mentioned
above check the mount.vfat (or mount.fat or mount.cifs?) manual pages
for options that might transparently "fix up" the file name.

# Yes, you can use `\n` in a file name ... but please don't.

> Does anyone have any ideas here other than begging, borrowing, or
> buying a Windows system?

It's an SD card, right?  Asking a friendly neighbour to rename the
file(s) in question may be the quickest way out of your conundrum.

Hope this helps,
--
Olaf Meeuwissen, LPIC-2FSF Associate Member since 2004-01-27
 GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13  F43E B8A4 A88A F84A 2DD9
 Support Free Softwarehttps://my.fsf.org/donate
 Join the Free Software Foundation  https://my.fsf.org/join
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-21 Thread rainerh

Hendrik Boom  schrieb am Sa 22 Dez 2018 04:23:14 CET:


Does anyone have any ideas here other than begging, borrowing, or
buying a Windows system?


The forward slash isn't allowed in filenames on Windows too:

https://docs.microsoft.com/de-de/windows/desktop/FileIO/naming-a-file#naming-conventions

___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-21 Thread Rick Moen
Quoting Hendrik Boom (hend...@topoi.pooq.com):

> I have a 32GiB microSD card an am reying to read it on my Devuan system.
> I munted it with a simpel mount /dev/sdb1 /nedia/hendrik/
> 
> It reads almost everything fine, except for a few files whose names 
> contain '/' characters.  I can handle the other horribly weird 
> characters in file names -- emacs Rename in the directory 
> editor works just fine.  But the names containing '/'s even have 
> emacs stymied.

Rename them.

1.  'ls -i'   #Gets the inode number.
2.  'find . -inum "inode-number-from-ls -i" -exec mv {} "newfilename" \;'

Man, I hate files with pathological filenames, and some of the
other-OS-originating examples are among the worst.
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] slashes in FAT file names

2018-12-21 Thread golinux

On 2018-12-21 21:23, Hendrik Boom wrote:


Does anyone have any ideas here other than begging, borrowing, or
buying a Windows system?

-- hendrik

___



Don't use / in filenames.  I thought it was a no-no.  Yes it is:

"File names in Linux can contain any characters other than (1) a forward 
slash ( / ), which is reserved for use as the name of the root directory 
(i.e., the directory that contains all other directories and files) and 
as a directory separator . . ."


http://www.linfo.org/file_name.html

golinux
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


[DNG] slashes in FAT file names

2018-12-21 Thread Hendrik Boom
I have a 32GiB microSD card an am reying to read it on my Devuan system.
I munted it with a simpel mount /dev/sdb1 /nedia/hendrik/

It reads almost everything fine, except for a few files whose names 
contain '/' characters.  I can handle the other horribly weird 
characters in file names -- emacs Rename in the directory 
editor works just fine.  But the names containing '/'s even have 
emacs stymied.

ls -l lists them like this:

-rw-r--r-- 1 hendrik hendrik   0 Sep  1  2007 06 - Track 6.mq3
-? ? ?   ? ?? 07/TRA~1.MP3
-rw-r--r-- 1 hendrik hendrik 3585716 Sep  1  2007 08-URA~1.MP3

With the slash, it can't even figure out the permissions, ownership, or 
file size.  Preumably some parts of the system interpret the '/' as the 
directory name separator, and in this file system that's not what it 
is.

Does anyone have any ideas here other than begging, borrowing, or 
buying a Windows system?

-- hendrik

___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng