Re: : in file's name using mount_ntfs (not fuse)

2017-11-12 Thread trebol


Well, after reading a lot of boring documentation about a file system I 
practically never use created by a company whose products I'm allergic to, 
I've arrived at the conclusion that in a posix environment, all unicode 
characters except '/' and '\0' must be allowed.


My advice for the developers: Put the access of attributes functionality 
apart in a program.


For now, I'm separating the attributes with a bell control character with 
a dirty hack I'm not pretty sure it is correct because I don't care of 
attributes. I only want to get my files and put away "the fascinating 
world of NTFS!"


https://blogs.technet.microsoft.com/askcore/2010/08/25/ntfs-file-attributes/

Regards,
trebol.


--- ntfs_subr.c 2017-11-13 00:05:07.333116651 +
+++ ntfs_subr.c.orig2017-11-12 11:44:53.152382608 +
@@ -696,7 +696,7 @@
 }

 /*
- * Lookup attribute name in format: [['\a'$ATTR_TYPE]:$ATTR_NAME],
+ * Lookup attribute name in format: [[:$ATTR_TYPE]:$ATTR_NAME],
  * $ATTR_TYPE is searched in attrdefs read from $AttrDefs.
  * If $ATTR_TYPE not specified, ATTR_A_DATA assumed.
  */
@@ -782,14 +782,14 @@
}

/*
-* Divide file name into: foofilefoofilefoofile['\a'attrspec]
+* Divide file name into: foofilefoofilefoofile[:attrspec]
 * Store like this:   fname:fnamelen   [aname:anamelen]
 */
fname = cnp->cn_nameptr;
aname = NULL;
anamelen = 0;
for (fnamelen = 0; fnamelen < cnp->cn_namelen; fnamelen++)
-   if (fname[fnamelen] == '\a') {
+   if (fname[fnamelen] == ':') {
aname = fname + fnamelen + 1;
anamelen = cnp->cn_namelen - fnamelen - 1;
dprintf(("%s: %s (%d), attr: %s (%d)\n", __func__,


Re: : in file's name using mount_ntfs (not fuse)

2017-11-11 Thread Michael Parson

On Fri, 10 Nov 2017, trebol wrote:


Hello Michael.

The only thing you are achieving using find in this way, is passing the 
correct name to cp. If you have problems with your shell, or your environment 
(terminal, etc...) passing some characters to your commands, this may be 
useful for you. But that is not the problem I'm talking about (In fact, with 
linux and sh if some file name has a ':' you can just type it). The problem 
is that if the name contains ':' the netbsd implementation of ntfs is going 
to treat it as a query of attributes.


For example, ls will show the file names (e.g. file:h.ext), but 'ls -l' or 
'ls -i' is going to give the error:

ls: file:h.ext: No such file or directory

As I see it, and please correct me if I'm wrong, the problem is that the 
implementation of the file system is taking for sure that ':' can't be in a 
file name, so is fine to use it for querying attributes.


You seem to be correct, the in-kernel NTFS driver does not seem to know
how to deal with files with ':' in the filename.  I tried with the
NetBSD and (gnu)coreutils and findutils, none of them could get any
usable information about that file.

This limitation seems to be in the NTFS code, as I can
create/edit/copy/etc/ a file with that name on an FFS mount without any
issues.

I was able to install the fuse-ntfs-3g stuff out of pkgsrc and it was
able to mount the NTFS formatted USB stick and then I was able to access
the file as 'file\:.ext' and copy it off.

I know your subject line said 'not fuse', but that might be the only way
to get this file off the USB stick and onto your NetBSD system.

--
Michael Parson
Pflugerville, TX
KF5LGQ


Re: : in file's name using mount_ntfs (not fuse)

2017-11-10 Thread trebol

Hello Michael.

The only thing you are achieving using find in this way, is passing 
the correct name to cp. If you have problems with your shell, or your 
environment (terminal, etc...) passing some characters to your commands, 
this may be useful for you. But that is not the problem I'm talking about 
(In fact, with linux and sh if some file name has a ':' you can just type 
it). The problem is that if the name contains ':' the netbsd 
implementation of ntfs is going to treat it as a query of attributes.


For example, ls will show the file names (e.g. file:h.ext), but 'ls -l' or 
'ls -i' is going to give the error:

ls: file:h.ext: No such file or directory

As I see it, and please correct me if I'm wrong, the problem is that the 
implementation of the file system is taking for sure that ':' can't be in 
a file name, so is fine to use it for querying attributes.


Regards,
trebol.


On Fri, 10 Nov 2017, Michael Parson wrote:


On 2017-11-10 04:21, trebol wrote:

Hello,

I'd appreciate it if someone could tell me how to copy a file from a
ntfs partition with a colon in its name. This character is used to get
files attributes, and I can't find a way to avoid it.


I don't have any NTFS stuff mounted on NetBSD, but I tried this on my laptop 
running Linux (Dual-boots Win 10, windows partition is mounted on /windows):


Use 'ls -li' to get the inode of the file (first column)

Then use 'find . -maxdepth 1 -inum $inode -exec cp {} /tmp/new_filename.ext 
\;'


You can also use this to rename or remove files with chars that aren't 
supposed to exist in filenames or aren't otherwise easily typeable.


--
Michael Parson
Pflugerville, TX
KF5LGQ




Re: : in file's name using mount_ntfs (not fuse)

2017-11-10 Thread Michael Parson

On 2017-11-10 04:21, trebol wrote:

Hello,

I'd appreciate it if someone could tell me how to copy a file from a
ntfs partition with a colon in its name. This character is used to get
files attributes, and I can't find a way to avoid it.


I don't have any NTFS stuff mounted on NetBSD, but I tried this on my 
laptop running Linux (Dual-boots Win 10, windows partition is mounted on 
/windows):


Use 'ls -li' to get the inode of the file (first column)

Then use 'find . -maxdepth 1 -inum $inode -exec cp {} 
/tmp/new_filename.ext \;'


You can also use this to rename or remove files with chars that aren't 
supposed to exist in filenames or aren't otherwise easily typeable.


--
Michael Parson
Pflugerville, TX
KF5LGQ



Re: : in file's name using mount_ntfs (not fuse)

2017-11-10 Thread Martin Husemann
On Fri, Nov 10, 2017 at 10:59:22AM +, Stephen Borrill wrote:
> On Fri, 10 Nov 2017, trebol wrote:
> > Well, ':' it seems to allowed. From
> > 
> > https://msdn.microsoft.com/en-us/library/windows/desktop/dd317748(v=vs.85).aspx
> > 
> > [...] In both NTFS and FAT file systems, the special file name
> > characters are: '\', '/', '.', '?', and '*' [...]
> 
> Windows 7 and 10 disagree, even trying to type a : in a file name gives an
> immediate popup warning.

Ah, I mixed it up. My set of chars was the win32 file name restrictions.

But with posix subsystem or similar you could use more chars, depending on
the file system.

Martin


Re: : in file's name using mount_ntfs (not fuse)

2017-11-10 Thread Stephen Borrill

On Fri, 10 Nov 2017, trebol wrote:

Well, ':' it seems to allowed. From

https://msdn.microsoft.com/en-us/library/windows/desktop/dd317748(v=vs.85).aspx

[...] In both NTFS and FAT file systems, the special file name characters 
are: '\', '/', '.', '?', and '*' [...]


Windows 7 and 10 disagree, even trying to type a : in a file name gives 
an immediate popup warning.


Of course, that could be an Explorer limition, not NTFS per se.


On Fri, 10 Nov 2017, trebol wrote:




On Fri, 10 Nov 2017, Martin Husemann wrote:


On Fri, Nov 10, 2017 at 10:21:51AM +, trebol wrote:

Hello,

I'd appreciate it if someone could tell me how to copy a file from a ntfs
partition with a colon in its name. This character is used to get files
attributes, and I can't find a way to avoid it.


I may remember wrong, but ":" is not an allowed character in ntfs file
names, isn't it? Reserved characters are something like <>:"/\|?*
plus anything with the char value between 0 and 31.

Martin



Hello Martin, to be honest with you, I have no idea. I can't remember the 
last time I actually use a windows os. This is a pen drive from a friend I 
have to copy some files from. Maybe those files were created with linux. 
I'm complete sure that you can create a file in linux with colons in its 
name on a ntfs partition. If this is wrong, then is a linux's problem, 
forget about it.


I'll search for info.









Re: : in file's name using mount_ntfs (not fuse)

2017-11-10 Thread trebol


Well, ':' it seems to allowed. From

https://msdn.microsoft.com/en-us/library/windows/desktop/dd317748(v=vs.85).aspx

[...] In both NTFS and FAT file systems, the special file name characters 
are: '\', '/', '.', '?', and '*' [...]




On Fri, 10 Nov 2017, trebol wrote:




On Fri, 10 Nov 2017, Martin Husemann wrote:


On Fri, Nov 10, 2017 at 10:21:51AM +, trebol wrote:

Hello,

I'd appreciate it if someone could tell me how to copy a file from a ntfs
partition with a colon in its name. This character is used to get files
attributes, and I can't find a way to avoid it.


I may remember wrong, but ":" is not an allowed character in ntfs file
names, isn't it? Reserved characters are something like <>:"/\|?*
plus anything with the char value between 0 and 31.

Martin



Hello Martin, to be honest with you, I have no idea. I can't remember the 
last time I actually use a windows os. This is a pen drive from a friend I 
have to copy some files from. Maybe those files were created with linux. I'm 
complete sure that you can create a file in linux with colons in its name on 
a ntfs partition. If this is wrong, then is a linux's problem, forget about 
it.


I'll search for info.






Re: : in file's name using mount_ntfs (not fuse)

2017-11-10 Thread trebol



On Fri, 10 Nov 2017, Martin Husemann wrote:


On Fri, Nov 10, 2017 at 10:21:51AM +, trebol wrote:

Hello,

I'd appreciate it if someone could tell me how to copy a file from a ntfs
partition with a colon in its name. This character is used to get files
attributes, and I can't find a way to avoid it.


I may remember wrong, but ":" is not an allowed character in ntfs file
names, isn't it? Reserved characters are something like <>:"/\|?*
plus anything with the char value between 0 and 31.

Martin



Hello Martin, to be honest with you, I have no idea. I can't remember the 
last time I actually use a windows os. This is a pen drive from a friend I 
have to copy some files from. Maybe those files were created with linux. 
I'm complete sure that you can create a file in linux with colons in its 
name on a ntfs partition. If this is wrong, then is a linux's problem, 
forget about it.


I'll search for info.



Re: : in file's name using mount_ntfs (not fuse)

2017-11-10 Thread Martin Husemann
On Fri, Nov 10, 2017 at 10:21:51AM +, trebol wrote:
> Hello,
> 
> I'd appreciate it if someone could tell me how to copy a file from a ntfs
> partition with a colon in its name. This character is used to get files
> attributes, and I can't find a way to avoid it.

I may remember wrong, but ":" is not an allowed character in ntfs file
names, isn't it? Reserved characters are something like <>:"/\|?*
plus anything with the char value between 0 and 31.

Martin