Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serve a file as hidden file / system file #32

Open
PhilLehmann opened this issue Oct 22, 2017 · 10 comments
Open

Serve a file as hidden file / system file #32

PhilLehmann opened this issue Oct 22, 2017 · 10 comments

Comments

@PhilLehmann
Copy link
Contributor

Is it possible with winfsp (fuse) to set a file as hidden and system?

The reason I am asking is that I would like to add a desktop.ini to the virtual drive, but that file is only being evaluated by windows, if it is a system file. In addition to that, hiding it from the user would be great.

https://superuser.com/questions/882442/self-created-desktop-ini-does-not-work

I searched your and libfuse API docs and although they are great, maybe I lack the experience to search for the right needle in the haystack.

@SerCeMan
Copy link
Owner

Hi, @philrykoff!

I believe it is better to ask that question on the winfsp repo. As far as I understand, it is all about mapping unix-style fuse permission to windows permissions through winfsp. If it is possible on the fuse layer of winfsp then there should be no problem to do the same via jnr-fuse.

@PhilLehmann
Copy link
Contributor Author

PhilLehmann commented Oct 23, 2017

I was unsure whom to ask myself 😄

The creator of WinFSP commented on my request here winfsp/winfsp#114 (comment)

Basically, he is saying that osxfuse has extensions called chflags for similar requirements. Do you know about this feature of might it already be implemented in jnr-fuse? Please feel free to comment over there 😁

@PhilLehmann
Copy link
Contributor Author

Here is some info I found about chflags:

This indeed looks like it could be helpful. If we would have a somewhat similar API for OSX and Win, would that be something you would consider as an addition?

@PhilLehmann
Copy link
Contributor Author

@SerCeMan: billziss-gh implemented the changes needed in WinFSP (winfsp/winfsp#114).

It seems osxfuse has a similar implementation already done using chflags:
Usage in osxfuse: https://github.com/osxfuse/fuse/blob/master/example/fusexmp_fh.c#L299-L426
Apple man file: https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/chflags.1.html

For Linux, my only find was chattr, but that only works for ext2/3/4 file systems.

A proper solution would probably implement Windows and MacOS, optionally Linux. Based on the jnr-fuse code I already saw, I feel comfortable to implement the Windows part. I would have time in about two weeks to pick this up, if no one feels eager to do so beforehand. 😉

@billziss-gh
Copy link

@philrykoff ping me when you have such a PR ready. I may have suggestions on how to ensure that jnr-fuse remains backwards/forwards compatible with different versions of WinFsp. [Caveat: I am very rusty on Java.]

BTW, I am implementing these changes in cgofuse. Related issue is winfsp/cgofuse#20. You may want to keep an eye as I have to face similar compatibility issues. [E.g. what happens when the latest cgofuse is used with a version of WinFsp that does not have the FSP_FUSE_CAP_STAT_EX capability.]

@SerCeMan
Copy link
Owner

Based on the jnr-fuse code I already saw, I feel comfortable to implement the Windows part. I would have time in about two weeks to pick this up, if no one feels eager to do so beforehand.

That sounds great to me 👍 . Feel free to reach out if you need any help!

@billziss-gh
Copy link

The winfsp/cgofuse#20 issue is now closed. Most of it is not relevant to this discussion, except that it solves the problem of using a version of cgofuse with flags capability with a version of WinFsp that does not have this capability (e.g. latest cgofuse with WinFsp v1.1 which does not have BSD flags support).

Here is the relevant code from cgofuse:

    // during FUSE init
    conn->want |= conn->capable & FSP_FUSE_CAP_STAT_EX;
    cgofuse_stat_ex = 0 != (conn->want & FSP_FUSE_CAP_STAT_EX);

And:

    // during copy of Go struct stat to C struct stat
    if (cgofuse_stat_ex)
        ((struct fuse_stat_ex *)stbuf)->st_flags = flags;

Here is how this works. A newer version of WinFsp will pass FSP_FUSE_CAP_STAT_EX during init signifying that it supports BSD flags. So we respond that we want this capability. We also remember that the capability is supported so that we can copy the flags whenever we need to pass a struct stat from Go to C.

An older version of WinFsp will not pass FSP_FUSE_CAP_STAT_EX and no flags copying will happen.

Apologies if all this is too obvious.

@PhilLehmann
Copy link
Contributor Author

Documentation is never bad. Thanks for the helpful insights 👍

@billziss-gh
Copy link

Please note that WinFsp v1.2B3 has been released. It has support for BSD flags, chflags, setcrtime and setchgtime.

@fredolier
Copy link

fredolier commented Aug 10, 2019

Was this eventually implemented in jnr-fuse ?
I do not see whether it is actually done.

Edited: Would be appreciated if someone could show me how to get round this issue to be able to set the Windows extra-attibutes 'SYSTEM'/'READONLY'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants