5 Replies
      Latest reply on Jul 15, 2019 12:26 PM by eskimo
      lakshmi_s Level 1 Level 1 (0 points)

        We are watching for DFS target mounted on smb volume using NSWorkSpace’s NSWorkspaceDidMountNotification notification in our code. But didMount notification is inconsistent and not reliable. Only for the first time, didMount notification is notified. Later on we are not getting notified with didMount notification, though notification is successful.

         

        Is there any other better approach to be notified on DFS junction mount?

        • Re: What is the appropriate way to get notified on DFS junction mount in smb server on Mac OS?
          eskimo Apple Staff Apple Staff (11,625 points)

          DFS junction mounts have always been a bit of a weird edge case on the Mac.  Does triggering this DFS junction mount actually change the mount list, as reported by, say, the mount tool?

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"

            • Re: What is the appropriate way to get notified on DFS junction mount in smb server on Mac OS?
              lakshmi_s Level 1 Level 1 (0 points)

              Yes mount command line tool provided the mounted volume list and DFS mounted volume is available in that.

               

              But in our case, we have no clue if it is DFS junction, mounted or not. We need DFS mount successful event to further communicate on named pipes. The other way is polling to mount tool in regular intervals.

               

              Is there any way when we get notified on DFS mount to user mode or even kernel mode, where we can further communicate to our server after DFS mount successful?

                • Re: What is the appropriate way to get notified on DFS junction mount in smb server on Mac OS?
                  eskimo Apple Staff Apple Staff (11,625 points)

                  If the DFS junction mounts show up in the volume list, it should be feasible to be notified about them coming and going [1], you just have to choose the right API for those notifications [2].  Have you tried the Darwin notify API (defined in <notify.h>) with one of the kNotifyVFSXXX keys (defined in <notify_keys.h>)?

                  ps You can test this without writing any code using NotifyTool.

                  Share and Enjoy

                  Quinn “The Eskimo!”
                  Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                  let myEmail = "eskimo" + "1" + "@apple.com"

                  [1] I was worried that they were being processed entirely within the SMB file system, which would hide them from the volume list and hence prevent standard volume list notifications from being sent.

                  [2] IIRC, NSWorkspace specifically excludes network volumes from its volume notification machinery.

                    • Re: What is the appropriate way to get notified on DFS junction mount in smb server on Mac OS?
                      lakshmi_s Level 1 Level 1 (0 points)

                      Can you please share some documentation on kNotifyVFSXXX and kNotify, on how exactly I can get notified on smb dfs mount.

                       

                      Also is there any simplified way I can get notified through mount command line tool. I observed "#define VQ_MOUNT        0x0008  /* new filesystem arrived */", but not sure on usage of it.

                       

                      Thanks in advance.

                        • Re: What is the appropriate way to get notified on DFS junction mount in smb server on Mac OS?
                          eskimo Apple Staff Apple Staff (11,625 points)

                          VQ_MOUNT is part of the low-level interface between kernel and user space.  I recommend avoiding it if you can.

                          Can you please share some documentation on kNotifyVFSXXX and kNotify, on how exactly I can get notified on smb dfs mount.

                          The Darwin notify API is a general-purpose system-wide notification mechanism.  To learn more, read the notify man page.

                          If you look in <notify_keys.h>, you’ll see there are a bunch of constants for specific Darwin notifications.  For example, kNotifyVFSMount expands to com.apple.system.kernel.mount.  You can play around with these notifications using NotifyTool.  To continue the above example, here’s how you’d listen for volume mounts:

                          $ NotifyTool listen com.apple.system.kernel.mount
                          Listening using a file descriptor:

                          On mounting a volume, you’ll see a notification posted:

                          $ NotifyTool listen com.apple.system.kernel.mount
                          Listening using a file descriptor:
                          com.apple.system.kernel.mount (6)

                          To see how that works under the covers, look at the code for NotifyTool itself.

                          Share and Enjoy

                          Quinn “The Eskimo!”
                          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                          let myEmail = "eskimo" + "1" + "@apple.com"