2

I am porting an application from Windows to Linux (specifically Ubuntu 14.04). The application needs to write data to a network shared volume on a NAS.

On Windows, my application can access the SMB3 shared volume on the NAS as long as these conditions are met:

  1. it knows the UNC path of the SMB3 shared volume
  2. the account under which the application runs is authorized (i.e. same username and password between the client and the server).

I don't need an extra step of mounting or mapping the SMB3 shared volume outside of the application.

Is it possible to achieve a similar effect on Linux? The important point is that I don't want to touch fstab or autofs, if possible. I want configuration for my application to be centralized. If I have to modify fstab or setup autofs rules, then I'm starting to spread configuration all over the place, from the point of view of my application. The network shared volume is only used by this particular application; The rest of the system doesn't care.

The NAS supports either SMB2/3 or NFSv3/v4, and I have no opinion regarding using one protocol over another.

1
  • If you plan on using native file system semantics (ie a path) then you must use mount (or automount). Otherwise your program will need to be a native SMB client. Sep 1, 2016 at 2:22

1 Answer 1

1

You don't need root access to mount filesystems, thanks to FUSE. There is a FUSE driver for Samba: smbnetfs.

I didn't use it much and it was a long time ago but I recall it being not completely straightforward to configure if the server had peculiarities. That may or may not be a problem depending on your setup and on how far your NAT deviates from the basic protocol. You need to give it a list of servers or domains that it will access.

Alternatively, link your application with the GVfs libraries. (This doesn't require using Gnome libraries for your user interface.) You need to use the GIO functions instead of open or fopen, and that way you can specify files over alternate backends including smb. GVfs requires rewriting some of your application instead of just accessing a particular directory, but has the benefit that you don't need any configuration beyond supplying the credentials (typically by recording them in gnome-keyring).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .