Reputation: 463
To mount CIFS presently I use system() call in source, this works. If I try to run command manually on shell it works too.
$ mount -t cifs //IP/dir /mnt -o user=name,pass=PASS,domain=mydomain,nounix
$ mount.cifs //IP/dir /mnt -o user=name,pass=PASS,domain=mydomain,nounix
But if i replace the same command with exec() family i see errors.
if(fork() == 0)
{
if (execl("/bin/mount", "/bin/mount", "-t", "cifs", "//IP/dir", "/mnt",
"-o user=name,pass=PASS,domain=mydomain,nounix", (char*) NULL) < 0)
...
}
else
...
Error: mount: mounting cifs on //IP/dir /mnt failed: No such file or directory. It looks like mount directory "/mnt" is not recognized or not seen by mount process.
Tried below things but no luck:
What would be the cause here? How to see the command line parameters of the exec()'ed program ?
Version of mount:
mount.cifs version: 1.14-x
Regards, - AK
Upvotes: 1
Views: 329
Reputation: 463
Used strace()
to find the arguments passed to execl()
. Solved my issue by using system calls mount()
and umount()
.
Upvotes: 1
Reputation: 833
Presuming you have installed samba
sudo apt-get install samba
In the Global section of the file /etc/samba/smb.conf you should have this :-
workgroup = WORKGROUP
netbios name = PCNAME
name resolve order = bcast host
Change WORKGROUP and PCNAME accordingly. Set the name resolve order as shown in order to browse windows shares using Nautilus.
Upvotes: 0