0

I need to check if mounted is online in script. and complete that check in maximum time of 1 second.

I tried:

  1. smbclient -L -U user%pass - but it takes too much time, and makes a trash in destination serwer logfile because of relogin

  2. stat /mnt/samba/file - but it stucks when the samba share is offline

Maybe one of You will help to find another way to complete that?

Destination samba is using SMB3.0 protocole.

Regards

Mario Bash
  • 39
  • 8
  • Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. – jww Sep 12 '18 at 15:33
  • 1
    You are not right. This is strictle on-topic. So how to develop software whitch is samba related? I need to write a test in scripts. – Mario Bash Sep 26 '18 at 13:58

1 Answers1

0

From programmatic viewpoint it's harder than it seems. To check for sure I'd say you have to create a file there or try to read a directory. However linux doesn't support asynchronous open system call And the same is the reason why utilities are hung for a long timeout (which should be about 2 minutes I guess, it's TCP-death minimum timeout) So if you are going to implement this you should impose some smaller timeout, trying to make stat or open call on a destination folder and just terminate the thread (or send a signal there) when the timeout is expired.

dev_null
  • 1,907
  • 1
  • 16
  • 25
  • I might be really off here as I've never used samba before, but couldn't OP use `timeout` of a number that's just slightly higher than a successful read attempt on the command reading a file? E.g. if it shouldn't take more than 1 second to read a file off it, OP could use `timeout 2` or something like that, and then check the output of the command. (To be clear: I'm talking about the UNIX tool [timeout](https://www.gnu.org/software/coreutils/manual/html_node/timeout-invocation.html).) – confetti Sep 12 '18 at 16:59
  • @confetti stat is a syscall and you can't interrupt kernel processes what are waiting for IO. That is the root of the problem. May the user space return but then you have a zombie kernel process. – Mario Bash Sep 17 '18 at 16:06