Multiple mount_smbfs commands fail in bash script

Polytropon freebsd at edvax.de
Thu Sep 2 13:29:08 UTC 2010


On Thu, 02 Sep 2010 14:02:35 +0200, Bernard Scharp <freebsd-questions at itsacon.net> wrote:
> 
> > 
> > Could you post the script? Anything else would be pure guess work. You
> 
> Well, I can recreate it with something as simple as:
> 
> #!/usr/local/bin/bash
> mount_smbfs //user at remotehost/share1/ /tmp/mnt/
> mount_smbfs //user at remotehost/share2/ /tmp/mnt2/

Excuse me, it may just be a stupid question... but... why do
you use bash for this purpose? Do you require any special
bash feature that cannot be done using the standard shell,
sh? I often see the urge to use bash for scripting as a
typical "Linuxism", which is usually non-portable (if that
was your goal). FreeBSD's standard scripting shell is sh,
so why not use it until you reach the ends of its functionality?



Just a guess, regarding your initial question, as I don't have
experience with "Windows" related things: Did you have the
chance to monitor correct operations of your script in the
past? Did the mound and umount (!) calls work properly? Have
you checked your commands running them in the standard dialog
shell (csh)? I assume you're running them as root (or at least
with sufficient permissions), so I don't think the problem
is there, as the error message

mount_smbfs: can't get handle to requester (no /dev/nsmb* device)

doesn't look like refering to that problem.

The error message originates from /usr/src/contrib/smbfs/lib/smb/ctx.c;
having a look around, and remembering that you said

> [...] there are (by last count) 1170 /dev/nsmb* devices
> in /dev/ (is that normal?)

I found smb_ctx_gethandle() near line 600 (version 7 OS here):

        /*
         * well, no clone capabilities available - we have to scan
         * all devices in order to get free one
         */
         for (i = 0; i < 1024; i++) {
                 snprintf(buf, sizeof(buf), "/dev/%s%d", NSMB_NAME, i);
                 fd = open(buf, O_RDWR);
                 if (fd >= 0) {
                        ctx->ct_fd = fd;
                        return 0;
                 }
         }

The limit seems to be 1024, if I read that correctly - allthough
I'm considered a "C hacker", I'm no "OS-level C hacker". :-)

Afterwards, smb_ctx_lookup() fails and gives the error message
mentioned earlier.

Remove the /dev/nsmb* devices and try again. Make sure no other
SMB stuff is currently mounted, just to be sure, as I don't have
any idea what could fail.




-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list