Closed benzea closed 2 years ago
I suppose, python usage would be:
env = os.environ.copy()
env.update(v.split('=', 1) for v in testbed.get_environ())
Thanks! TBH I don't really like this, it's sort of giving up on the idea of umockdev. Tomorrow morning I have a few hours in a train and I'll see if it's possible to mock the filesystem stat'ing enough to pacify udev without setting this env variable. If that fails, we can still add this.
@martinpitt, please have a look at my benzea/misc branch then!
Oh, so, I just realised that /proc/self/fd actually shows the path for a file descriptor. So, maybe that is sufficient and much easier to do it then. e.g.
ls -l /proc/self/fd 1000</sys/class/power_supply/BAT0/
@benzea : Right, that was my approach. See https://github.com/systemd/systemd/issues/23499#issuecomment-1140855325
Let's close this for now, then?
So, this adds a function returning an
char**
(same asg_get_environ
).Not sure what makes sense though. In python returning a dictionary would be more convenient. So maybe we should just expose both types of utility functions. This and a
GHashtTable
return or so.Or just hash table.
Note that I kind of tried to get things to work using an xattr instead. But, turns out, tmpfs does not allow setting arbitrary values. I did manage to get it to run (except for nix) by setting a special ACL on the file (
system.posix_acl_access
xattr), but that is just one bit of information, which could probable be done using a sticky bit already ...Or we could touch a
.umockdev
file in every device node, and thenopenat(fd, ".umockdev")
to decide on whether to override ...In conclusion, lets just do this, everything else is complicated and with questionable benefits.