Results 1 to 2 of 2

Thread: QFileSystemWatcher not working with /etc/mtab

  1. #1
    Join Date
    Aug 2011
    Posts
    1
    Qt products
    Qt3
    Platforms
    MacOS X

    Default QFileSystemWatcher not working with /etc/mtab

    I'll try to be brief:

    My program should automatically sense when a USB device is plugged and also where that device was mounted. So far I've been able to sense the usb device plugged, as well as getting which device was inserted (i.e. /dev/sdc1).

    Knowing the device (i.e. /dev/sdc1) I can then simply look inside /etc/mtab to match that device with its mount point (i.e. /media/USBDRIVE). However when I try to find that device inside /etc/mtab, I get nothing, but if I tell the program to wait 1 second before trying to search inside /etc/mtab, it works, meaning my program was actually trying to find the device before it was actually added to /etc/mtab

    So what I did was instead of waiting 1 second to search in /etc/mtab, I created a QFileSystemWatcher for that file:

    Qt Code:
    1. QFileSystemWatcher watcher = new QFileSystemWatcher(QStringList() << "/etc/mtab",this);
    To copy to clipboard, switch view to plain text mode 

    But watcher never detects any change in /etc/mtab! Even if try /proc/mounts which is the same file... What is weird is that for any file inside /home, QFileSystemWatcher will work, but for /etc or /proc files it won't work.

    I will thank you guys for any help, since the 1 second wait is not the best approach..

  2. #2
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: QFileSystemWatcher not working with /etc/mtab

    Just in case QFileSystemWatcher has a bug, you could try the Linux API equivalent: http://linux.die.net/man/2/inotify_add_watch

Similar Threads

  1. QFIleSystemWatcher
    By jayreddy in forum Qt Programming
    Replies: 1
    Last Post: 15th December 2009, 08:21
  2. QFileSystemWatcher problem!!
    By Raajesh in forum Qt Programming
    Replies: 0
    Last Post: 23rd June 2008, 17:46
  3. QFileSystemWatcher
    By Kumosan in forum Qt Programming
    Replies: 2
    Last Post: 18th March 2008, 20:52
  4. QFileSystemWatcher
    By minty in forum Qt Programming
    Replies: 13
    Last Post: 22nd May 2007, 15:39
  5. Need help with QFileSystemWatcher
    By L.Marvell in forum Qt Programming
    Replies: 1
    Last Post: 18th August 2006, 13:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.