Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFileSystemWatcher not working with /etc/mtab
Forum Updated to NodeBB v4.3 + New Features

QFileSystemWatcher not working with /etc/mtab

Scheduled Pinned Locked Moved General and Desktop
13 Posts 5 Posters 7.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    loladiro
    wrote on 13 Aug 2011, 11:51 last edited by
    #2

    Judging from "this":http://qt.gitorious.org/qt-mobility/contacts/commit/e83fbfd/diffs patch applied to Qt Mobility, there is a bug in QFileSystemWatcher, preventing it from being used in /etc/mtab. Maybe the patch I liked to can help you, too.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on 13 Aug 2011, 11:57 last edited by
      #3

      Works for me -- are you returning to the event loop?

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

      1 Reply Last reply
      0
      • T Offline
        T Offline
        TheQtGuy
        wrote on 14 Aug 2011, 07:28 last edited by
        #4

        loladiro: I read that page before, but I didn't quite understood what was going on...

        peppe: I don't know what would be to return to the event loop, but my guess is that my code is correct, otherwise it wouldn't work with files inside /home directory right?

        @watcher = new QFileSystemWatcher(QStringList() << "/etc/mtab",this);
        connect(watcher, SIGNAL(fileChanged(const QString &)), this, SLOT(getPathFromFile(const QString &)));@

        If I change "/etc/mtab" to say a file in my home folder, the fileChanged signal is emitted, but not for "etc/mtab" file :(

        1 Reply Last reply
        0
        • L Offline
          L Offline
          loladiro
          wrote on 14 Aug 2011, 10:55 last edited by
          #5

          The patch to Qt Mobility I linked basically changes the QFilesSystemWatcher and uses its inotify backend for linux. I think it is pretty straight forward what is going on, and since it does exactly what you want (listening for new devices), it might be worth it for you to see what's going on and how they replaced the old QFileSystemWatcher syntax (in red) with inotify (in green).

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dangelog
            wrote on 14 Aug 2011, 11:04 last edited by
            #6

            Can you paste a small, correct, compilable example that shows your problem? I know QFSW is bugged, but it appears to be working fine for me (inotify backend, Linux 3.0).

            Software Engineer
            KDAB (UK) Ltd., a KDAB Group company

            1 Reply Last reply
            0
            • M Offline
              M Offline
              McLion
              wrote on 12 Sept 2014, 09:51 last edited by
              #7

              Sorry to dig this thread up and hijack it.
              How do you get an event when an USB device is plugged (ie. Memory stick as dev/sda1)?

              1 Reply Last reply
              0
              • J Offline
                J Offline
                jafarabadi.qt
                wrote on 12 Sept 2014, 09:59 last edited by
                #8

                Hi TheQtGuy
                i don't have any efficient solution but offer some idea:

                • Run Qt Creator as root :)
                  @sudo -b qtcreator@

                • your real-time access problem is with Dir o File? check it !

                say more about ur prob. and share ur experience dear ;)

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  McLion
                  wrote on 12 Sept 2014, 11:05 last edited by
                  #9

                  @ a.jafarabadi: ???

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    jafarabadi.qt
                    wrote on 12 Sept 2014, 11:38 last edited by
                    #10

                    excuse me friend because of my low english writing ability
                    i think that you want check your USB devices, and for doing it, you watch a file usign filewatcher that OS change it when a new usb connect or disconnect, but your watch doesn't work and does not determine any change in file.
                    now you want understand why this problem occured? YES?

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      McLion
                      wrote on 12 Sept 2014, 11:43 last edited by
                      #11

                      Not exactly.
                      If I attach a UBS memorystick it does not get mounted automatically so I can not monitor /etc/mtab.
                      I need to somehow catch the USB plug event and get the device path (i.e. /dev/sda1) and then handle the mount from my Qt code.

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        McLion
                        wrote on 12 Sept 2014, 11:59 last edited by
                        #12

                        .. or could QFileSystemWatcher used to monitor the /dev ?
                        This way I t could generate an event when an sd?? is added.

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          McLion
                          wrote on 23 Sept 2014, 15:59 last edited by
                          #13

                          Just like to add that this works as proposed using QFileSystemWatcher used to monitor the /dev. On the event I do some filtering using QDir ... that's it.

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved