diff options
author | Werner Koch <wk@gnupg.org> | 2009-10-28 13:02:15 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2009-10-28 13:02:15 +0100 |
commit | a1b614285518c1e4928919b905e992f35f4a3224 (patch) | |
tree | b8b0fdbc2459188fcdef689b32b17cf40871f644 /g13/mountinfo.c | |
parent | 2009-10-20 Marcus Brinkmann <marcus@g10code.com> (diff) | |
download | gnupg2-a1b614285518c1e4928919b905e992f35f4a3224.tar.xz gnupg2-a1b614285518c1e4928919b905e992f35f4a3224.zip |
[scd] Memory leak fix.
[g13] Send MOUNTPOINT status line
Diffstat (limited to 'g13/mountinfo.c')
-rw-r--r-- | g13/mountinfo.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/g13/mountinfo.c b/g13/mountinfo.c index 100c1e475..07c6240d4 100644 --- a/g13/mountinfo.c +++ b/g13/mountinfo.c @@ -43,6 +43,10 @@ struct mounttable_s char *mountpoint; /* Name of the mounttype. */ int conttype; /* Type of the container. */ unsigned int rid; /* Identifier of the runner task. */ + struct { + unsigned int remove:1; /* True if the mountpoint shall be removed + on umount. */ + } flags; }; @@ -55,7 +59,7 @@ size_t mounttable_size; /* Add CONTAINER,MOUNTPOINT,CONTTYPE,RID to the mounttable. */ gpg_error_t mountinfo_add_mount (const char *container, const char *mountpoint, - int conttype, unsigned int rid) + int conttype, unsigned int rid, int remove_flag) { size_t idx; mtab_t m; @@ -96,6 +100,7 @@ mountinfo_add_mount (const char *container, const char *mountpoint, } m->conttype = conttype; m->rid = rid; + m->flags.remove = !!remove_flag; m->in_use = 1; return 0; @@ -125,6 +130,16 @@ mountinfo_del_mount (const char *container, const char *mountpoint, for (idx=0, m = mounttable; idx < mounttable_size; idx++, m++) if (m->in_use && m->rid == rid) { + if (m->flags.remove && m->mountpoint) + { + /* FIXME: This does not always work because the umount may + not have completed yet. We should add the mountpoints + to an idle queue and retry a remove. */ + if (rmdir (m->mountpoint)) + log_error ("error removing mount point `%s': %s\n", + m->mountpoint, + gpg_strerror (gpg_error_from_syserror ())); + } m->in_use = 0; xfree (m->container); m->container = NULL; @@ -177,7 +192,8 @@ mountinfo_dump_all (void) for (idx=0, m = mounttable; idx < mounttable_size; idx++, m++) if (m->in_use) - log_info ("mtab[%d] %s on %s type %d rid %u\n", - idx, m->container, m->mountpoint, m->conttype, m->rid); + log_info ("mtab[%d] %s on %s type %d rid %u%s\n", + idx, m->container, m->mountpoint, m->conttype, m->rid, + m->flags.remove?" [remove]":""); } |