rpms/pam_mount/devel pam_mount-1.4-fsck.patch,NONE,1.1
Till Maas
till at fedoraproject.org
Tue Dec 2 21:43:38 UTC 2008
Author: till
Update of /cvs/pkgs/rpms/pam_mount/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv14799
Added Files:
pam_mount-1.4-fsck.patch
Log Message:
add missing patch
pam_mount-1.4-fsck.patch:
--- NEW FILE pam_mount-1.4-fsck.patch ---
diff --git a/doc/mount.crypt.8 b/doc/mount.crypt.8
index fafddf8..6f54fe2 100644
--- a/doc/mount.crypt.8
+++ b/doc/mount.crypt.8
@@ -37,6 +37,9 @@ cipher.
Wait at most this many seconds for udev to create /dev/mapper/\fIname\fP after
calling cryptsetup(8). The default value is 0 seconds.
.TP
+\fBfsck\fP
+Run fsck on the container before mounting it.
+.TP
\fBfsk_cipher\fP
The OpenSSL cipher used for the filesystem key. The default is "aes\-256\-cbc".
.TP
diff --git a/src/mtcrypt.c b/src/mtcrypt.c
index b85a012..8820c0a 100644
--- a/src/mtcrypt.c
+++ b/src/mtcrypt.c
@@ -37,6 +37,7 @@
* @loop_device: loop device association, if any
* @crypto_device: crypto device
* @blkdev: true if @container is a block device
+ * @fsck: true if fsck should be performed
*/
struct mount_options {
const char *container, *mountpoint, *fstype;
@@ -47,6 +48,7 @@ struct mount_options {
unsigned int no_update, readonly;
int dm_timeout;
bool blkdev;
+ bool fsck;
};
/**
@@ -146,8 +148,7 @@ static void mtcr_parse_suboptions(const struct HXoptcb *cbi)
/* automatically determined from keyfile size */
l0g("keysize mount option ignored\n");
else if (strcmp(key, "fsck") == 0)
- /* not handled atm */
- l0g("fsck mount option not supported\n");
+ mo->fsck = true;
else if (strcmp(key, "loop") == 0)
/* automatically detected anyway */
l0g("loop mount option ignored\n");
@@ -272,8 +273,9 @@ static bool mtcr_get_mount_options(int *argc, const char ***argv,
static int mtcr_mount(struct mount_options *opt)
{
const char *mount_args[9];
+ const char *fsck_args[4];
struct stat sb;
- int ret, argk = 0;
+ int ret, argk;
FILE *fp;
hxmc_t *cd, *key;
@@ -307,6 +309,31 @@ static int mtcr_mount(struct mount_options *opt)
while (stat(cd, &sb) < 0 && errno == ENOENT && opt->dm_timeout-- > 0)
usleep(333333);
+ if (opt->fsck) {
+ argk = 0;
+ fsck_args[argk++] = "fsck";
+ fsck_args[argk++] = "-p";
+ fsck_args[argk++] = cd;
+ fsck_args[argk] = NULL;
+ assert(argk < ARRAY_SIZE(fsck_args));
+
+ arglist_llog(fsck_args);
+ ret = spawn_synchronous(fsck_args);
+
+ /*
+ * Return codes higher than 1 indicate that manual intervention
+ * is required, therefore abort the mount/login.
+ */
+ if (WIFEXITED(ret) && WEXITSTATUS(ret) > 1) {
+ fprintf(stderr, "Automatic fsck failed, manual "
+ "intervention required, exit status %d\n",
+ WEXITSTATUS(ret));
+ ehd_unload(cd, opt->blkdev);
+ return false;
+ }
+ }
+
+ argk = 0;
mount_args[argk++] = "mount";
mount_args[argk++] = "-n";
if (opt->fstype != NULL) {
More information about the fedora-extras-commits
mailing list