Comments (8)
Done.
from cryptor.
After some experiments findmnt
was found to be a bit problematic, but mountpoint -q
works like a charm.
from cryptor.
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.
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.
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.
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.
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cryptor.