Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [solved] opening file /proc/mounts works, file length 0
Forum Updated to NodeBB v4.3 + New Features

[solved] opening file /proc/mounts works, file length 0

Scheduled Pinned Locked Moved Mobile and Embedded
3 Posts 2 Posters 1.1k Views 2 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.
  • G Offline
    G Offline
    GregWilsonLindberg
    wrote on last edited by GregWilsonLindberg
    #1

    I'm trying to set up monitoring of usb flash drive insertions and removals. I've got udev monitoring working, but when I try to open /proc/mounts to map the /dev device to a file system mount point, i.e. /media/... the file open for /proc/mounts works, but the file length is zero. If I cat the file I get all of the mount data. The permissions are read for everybody. /proc/mounts is symlinked to /proc/self/mounts and that is symlinked to /proc/processID/mounts. I'm wondering if there is some kind of a problem with thying to open a symlinked file, or just because it is symlinked through the processID. If I trace the symlinks through QFile, /proc/mounts points to /proc/self/mounts which then shows points to "". This would imply that /proc/self/mounts is the end of the chain, but if the links are examined in a shell, then /proc/self/mounts points the processID link.

    Any insight into what might be happening would be greatly appreciated.
    Regards,

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      The file /proc/self/mounts is not a real file. Take a look on man proc. The size of a file is 0 because it does not take any space on a harddrive. It is a reference to a structure in a kernel memory. You can read with it with QFile using readAll() or other read... functions.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        GregWilsonLindberg
        wrote on last edited by
        #3

        Thanks for the clue bat, I know it's not a real file, but I wasn't thinking of the implications of that. I started out using a while loop with file.atEnd() as the terminal condition, but that won't work as you pointed out. I'll just have to read til I get a no more data return from readline() .

        Again, Thanks.

        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