hb_fsSetAttr()

108 views
Skip to first unread message

Daniele Campagna

unread,
Dec 6, 2016, 3:54:33 PM12/6/16
to harbou...@googlegroups.com
Hi all,

I am trying to create a hidden file from a windows program. I use
hb_fsSetAttr and hb_fsGetattr.

If the file is on a networked drive, V: in my environment, a Samba
shared folder on a Linux server, the operation returns TRUE, but fails,
while the same operation in the windows filesystem works as expected.

I don't know really filesystems intricacies so deeply, so can anybody
shed a light on this behaviour?

Dan

elch

unread,
Dec 8, 2016, 3:21:38 AM12/8/16
to Harbour Users, cyber...@tiscalinet.it

Hi Dan,


there is no 'hidden attribute' in Linux, at least not for FSs' i know of.

Theoretical you can rename such a file/directory to start with dot, e.g. '.hidden',

that is ment to be somehow equal to 'hidden' in Linux, but Win users may still see it.


regards

Rolf

Daniele Campagna

unread,
Dec 10, 2016, 4:44:06 PM12/10/16
to harbou...@googlegroups.com

Hi Rolf, thanks for the answer, but the problem here is not about any of the filesystems available under Linux, but about SAMBA, and how it maps the missing DOS flags.

I've found (hopefully) the answer: from SAMBA docs:

https://www.samba.org/samba/docs/using_samba/ch08.html

----------------
Note that there is no bit to specify that a file is executable. DOS and Windows NT filesystems identify executable files by giving them the extensions .exe, .com, .cmd, or .bat.

Consequently, there is no use for any of the three Unix executable bits that are present on a file in a Samba disk share. DOS files, however, have their own attributes that need to be preserved when they are stored in a Unix environment: the archive, system, and hidden bits. Samba can preserve these bits by reusing the executable permission bits of the file on the Unix side—if it is instructed to do so. Mapping these bits, however, has an unfortunate side effect: if a Windows user stores a file in a Samba share, and you view it on Unix with the ls -al command, some of the executable bits won't mean what you'd expect them to.

Three Samba options decide whether the bits are mapped: map archive, map system , and map hidden. These options map the archive, system, and hidden attributes to the owner, group, and world execute bits of the file, respectively. You can add these options to the [data] share, setting each of their values as follows:

    [data]
        map archive = yes
        map system = yes
        map hidden = yes

After that, try creating a file in the share under Unix—such as hello.java—and change the permissions of the file to 755. With these Samba options set, you should be able to check the permissions on the Windows side and see that each of the three values has been checked in the Properties dialog box. What about the read-only attribute? By default, Samba sets this whenever a file does not have the Unix owner write permission bit set. In other words, you can set this bit by changing the permissions of the file to 555.

The default value of the map archive option is yes, while the other two options have a default value of no. This is because many programs do not work properly if the archive bit is not stored correctly for DOS and Windows files. The system and hidden attributes, however, are not critical for a program's operation and are left to the discretion of the administrator.
---------------------

I was aware of the mapping of archive->executable bit, so that under Linux files in a shared folder used by Windows clients appear as executable (and under Windows appear with archive flag set), but forgot about the other 2 flags :-)

Dan

--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages