Multiple mount_smbfs commands fail in bash script

2010-09-02 Thread Bernard Scharp
Hi all,

I'm having some problems with a bash script.

It's a backup script that periodically checks if a list of systems is
online, and if so, uses samba to mount a specified list of shares,
rsyncs them to a local directory and unmounts again.

This used to run fine till a few months ago (I don't know what the
trigger was that caused them to first fail).

Now, when the script is run, it gives the following error when mounting
the shares:

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

Which is strange, as there are (by last count) 1170 /dev/nsmb* devices
in /dev/ (is that normal?)

Searching the internet, FreeBSD and Samba mailing lists gave me no
recent info, and the old info wasn't helpful.

I've narrowed it down to the point where I think it's caused by one
process trying to open two (or more) shares at the same time. (a simple
script mounting two shares gives the same error).

I can mount the shares from the command line without problems, it's only
in the bash script it gives me problems.

~/.nsmbrc and /etc/nsmb.conf are correct, smbd, nmbd and winbindd are
running. The system is FreeBSD 8.0 Stable.

Anyone got any suggestions?

Regards,
Bernard
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Multiple mount_smbfs commands fail in bash script

2010-09-02 Thread Bernard Scharp

 
 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 //u...@remotehost/share1/ /tmp/mnt/
mount_smbfs //u...@remotehost/share2/ /tmp/mnt2/


 also might consider posting this on the BASH mail forum:
 
   bug-b...@gnu.org
 
 although you might have to subscribe first:
 
   http://lists.gnu.org/mailman/listinfo/bug-bash
 

I'l look into that, (though I doubt this is a bash issue).

Thanks!
Bernard

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Multiple mount_smbfs commands fail in bash script

2010-09-02 Thread Bernard Scharp
On 02/09/2010 15:29, Polytropon wrote:
 On Thu, 02 Sep 2010 14:02:35 +0200, Bernard Scharp 
 freebsd-questi...@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 //u...@remotehost/share1/ /tmp/mnt/
 mount_smbfs //u...@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?

The script above is a (heavily) reduced version, used to isolate the
problem. The real script is much longer, and uses a bunch of logic to
walk through a list of different systems (each with their own lists of
shares, loaded from external files), taking snapshots of the previous
backup, logging which systems were backed up, rolling back operations if
a backup fails, etc.

 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.

I am running it as root, and I just tried running the (test)script
(without the bash reference) under a csh shell, and got the same error,
so it's not a bash problem.

As for monitoring the operations of the script, it has worked fine
before (for several years), so I'm pretty sure the code is correct.

 
 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. :-)

Neither am I. Hadn't even thought of grepping in /usr/src for the error
message :-)

 
 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.
 

Can I just `rm /dev/nsmbX` them? (messing in /dev/ is a level of FreeBSD
I'm not familiar with)

Thanks for all your help!

Bernard
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org