1

It is possible mount a flash drive without read permission?

  • 2
    What do you mean by “without read permissions”? Do you want to prevent reading all the files and listing the directory contents? Will you at least allow traversing directories? What's the filesystem? What are you trying to achieve? – Gilles Apr 10 '14 at 22:26
  • @Gilles Do you want to prevent reading all the files and listing the directory contents? yes... that's exactly what I want. I'm working in a app (udev-independant) for controling flash drives permissions. – Raydel Miranda Apr 11 '14 at 12:39
  • So what's the filesystem? – Gilles Apr 11 '14 at 13:26
  • Well, right now I'm working with vfat. – Raydel Miranda Apr 11 '14 at 13:27
1

You can choose the permissions of the files and directories on a vfat filesystem in the mount options. Pass fmask to indicate the permission on files that are not set, and dmask for directories — the values are the same as in umask. For example, to allow non-root users to only traverse directories but not list their content, and create files and directories and overwrite existing files but not read back from any file, you can use fmask=055,dmask=044 (4 = block read permission, 5 = block read and execute permissions). You can assign a group with more or fewer permissions; for example, if you want only the creator group to be allowed to create directories, you can use the options gid=creator,fmask=055,dmask=046.

This is a handy way of preventing the creator of a file from reading back the data written to the file. However, this is a rare requirement, and it has the considerable downside of not allowing the creator of a file to read back the data written to the file.

  • Thanks, perfect!!! One last question, there is some way to do this with mount function (from "sys/mount.h")? – Raydel Miranda Apr 14 '14 at 15:31
  • @RaydelMiranda You'd normally do this by calling the mount program, or indirectly depending on whether you want to trigger the action from a hardware hook (e.g. udev) or from an unprivileged process. – Gilles Apr 14 '14 at 20:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.