Coder Social home page Coder Social logo

Comments (8)

phpony avatar phpony commented on July 28, 2024 1

Done.

from cryptor.

phpony avatar phpony commented on July 28, 2024

After some experiments findmnt was found to be a bit problematic, but mountpoint -q works like a charm.

from cryptor.

phpony avatar phpony commented on July 28, 2024

mountpoint is a part of utiul-linux project and is, as the documentation of the project itself says, a random collection of Linuxยฎ utilities. This project is packaged in most distributions under the name util-linux and is installed by default. So relying on mountpoint command is a safe choice in most cases.

from cryptor.

moson-mo avatar moson-mo commented on July 28, 2024

Actually I just noticed there is GLib.Mount (not sure why I have not seen this earlier ๐Ÿคท๐Ÿป).
With that we can get a list of mounts and it would also allow unmounting. That would be much nicer than calling external programs ๐Ÿ˜‰.

Let me know if you want to give it a shot to implement it with this, otherwise I'll have a look when time allows.

from cryptor.

phpony avatar phpony commented on July 28, 2024

Yes, GLib.Mount looks just like what was needed. Seems like it can be used both for monitoring current state of mounts and for unmounting them. I'll pull off my PR for now then and will try to code this better approach.

from cryptor.

phpony avatar phpony commented on July 28, 2024

After a bit of testing now I'm not so sure about it. GLib.Mount it's not the same as a unix mount, and so the monitor.get_mounts () method results are limited to very specific cases. The mounts it provides are filtered according to gvfs ruleset, so basically it returns and subscribes to events only for mounts in /media, $HOME or /run/media/$USER folders.

For example, in my system when I do mkdir /home/phpony/test && gocryptfs /some/crypto /home/phpony/test than monitor.get_mounts () returns a single mount with mount.get_root ().get_path () => /home/phpony/test and I'm able to monitor and determine it's state via GLib.Mount. But when I do mkdir /mnt/test && gocryptfs /some/crypto /mnt/test the monitor.get_mounts () returns zero mounts.

There's an option to do gocryptfs /some/crypto /mnt/test -o x-gvfs-show that allows to monitor /mnt/test via GLib.Mount (and makes this mount pop in Nautilus sidebar as ejectable drive), but again - this will work only for vaults that were mounted with this option from the start, so it's not universal and is very limited too.

Alas I found all this limitations non-intuitive and too obstructive for our case. Neither of my gocryptfs mounts are in those 3 folders so GLib.Mount is just not working for me. mountpoint -q on the other hand works for any mount wherever it is if user has access to it.

While struggling with GLib.Mount I've created a better wrapper for is_mounted checks, so at least I can provide a better PR with old mountpoint way, if you're interested.

from cryptor.

moson-mo avatar moson-mo commented on July 28, 2024

oof, that's unfortunate. Thanks for checking.

There is also: https://valadoc.org/gio-unix-2.0/GLib.UnixMountEntry.html

foreach (unowned var mount in UnixMountEntry.get (null)) {
    print("%s\n", mount.get_mount_path ());
}

That might do it ๐Ÿค” (at least for checking if it's mounted I guess)

from cryptor.

phpony avatar phpony commented on July 28, 2024

Can confirm, this function works fine:

      private void capture_mounts () {
           foreach (var vault in config.vaults) {
               vault.is_mounted = false;
           }
           foreach (unowned var mount in UnixMountEntry.get (null)) {
               foreach (var vault in config.vaults) {
                   if (vault.mount_point == mount.get_mount_path ()) {
                      vault.is_mounted = true;
                   }
               }
           }
       }

Will create a PR from this a bit later.

from cryptor.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.