tvl-depot/src/libstore
Shea Levy cc63db1dd5 makeStoreWritable: Ask forgiveness, not permission
It is surprisingly impossible to check if a mountpoint is a bind mount
on Linux, and in my previous commit I forgot to check if /nix/store was
even a mountpoint at all. statvfs.f_flag is not populated with MS_BIND
(and even if it were, my check was wrong in the previous commit).

Luckily, the semantics of mount with MS_REMOUNT | MS_BIND make both
checks unnecessary: if /nix/store is not a mountpoint, then mount will
fail with EINVAL, and if /nix/store is not a bind-mount, then it will
not be made writable. Thus, if /nix/store is not a mountpoint, we fail
immediately (since we don't know how to make it writable), and if
/nix/store IS a mountpoint but not a bind-mount, we fail at first write
(see below for why we can't check and fail immediately).

Note that, due to what is IMO buggy behavior in Linux, calling mount
with MS_REMOUNT | MS_BIND on a non-bind readonly mount makes the
mountpoint appear writable in two places: In the sixth (but not the
10th!) column of mountinfo, and in the f_flags member of struct statfs.
All other syscalls behave as if the mount point were still readonly (at
least for Linux 3.9-rc1, but I don't think this has changed recently or
is expected to soon). My preferred semantics would be for MS_REMOUNT |
MS_BIND to fail on a non-bind mount, as it doesn't make sense to remount
a non bind-mount as a bind mount.
2013-03-25 19:00:16 +01:00
..
build.cc Revert "Prevent config.h from being clobbered" 2013-03-08 01:24:59 +01:00
derivations.cc Only substitute wanted outputs of a derivation 2012-11-26 17:15:09 +01:00
derivations.hh Only substitute wanted outputs of a derivation 2012-11-26 17:15:09 +01:00
gc.cc Revert "Prevent config.h from being clobbered" 2013-03-08 01:24:59 +01:00
globals.cc Revert "Prevent config.h from being clobbered" 2013-03-08 01:24:59 +01:00
globals.hh Revert "Prevent config.h from being clobbered" 2013-03-08 01:24:59 +01:00
local-store.cc makeStoreWritable: Ask forgiveness, not permission 2013-03-25 19:00:16 +01:00
local-store.hh Revert "Prevent config.h from being clobbered" 2013-03-08 01:24:59 +01:00
Makefile.am Add builtin constants ‘langVersion’ and ‘nixVersion’ 2012-11-27 13:29:55 +01:00
misc.cc nix-store -q --roots: Respect the gc-keep-outputs/gc-keep-derivations settings 2012-12-20 18:41:44 +01:00
misc.hh nix-store -q --roots: Respect the gc-keep-outputs/gc-keep-derivations settings 2012-12-20 18:41:44 +01:00
optimise-store.cc Revert "Prevent config.h from being clobbered" 2013-03-08 01:24:59 +01:00
pathlocks.cc Set the close-on-exec flag on file descriptors 2012-03-05 20:29:00 +01:00
pathlocks.hh Use "#pragma once" to prevent repeated header file inclusion 2012-07-18 14:59:03 -04:00
references.cc Use data() instead of c_str() where appropriate 2012-02-09 18:27:45 +01:00
references.hh Use "#pragma once" to prevent repeated header file inclusion 2012-07-18 14:59:03 -04:00
remote-store.cc Revert "Prevent config.h from being clobbered" 2013-03-08 01:24:59 +01:00
remote-store.hh nix-store -q --roots: Respect the gc-keep-outputs/gc-keep-derivations settings 2012-12-20 18:41:44 +01:00
schema.sql * Store the size of a store path in the database (to be precise, the 2010-11-16 17:11:46 +00:00
store-api.cc Merge branch 'master' into no-manifests 2012-08-27 11:09:07 -04:00
store-api.hh nix-store -q --roots: Respect the gc-keep-outputs/gc-keep-derivations settings 2012-12-20 18:41:44 +01:00
worker-protocol.hh Revert "Prevent config.h from being clobbered" 2013-03-08 01:24:59 +01:00