diff options
-rw-r--r-- | libmount/src/context.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/libmount/src/context.c b/libmount/src/context.c index 2e2a161dd..614d3f3b5 100644 --- a/libmount/src/context.c +++ b/libmount/src/context.c @@ -1676,14 +1676,21 @@ int mnt_context_prepare_update(struct libmnt_context *cxt) cxt->syscall_status)); return 0; } + if (!cxt->update) { + const char *name = cxt->mtab_writable ? cxt->mtab_path : cxt->utab_path; + + if (cxt->action == MNT_ACT_UMOUNT && is_file_empty(name)) { + DBG(CXT, mnt_debug_h(cxt, + "skip update: umount, no table")); + return 0; + } + cxt->update = mnt_new_update(); if (!cxt->update) return -ENOMEM; - mnt_update_set_filename(cxt->update, - cxt->mtab_writable ? cxt->mtab_path : cxt->utab_path, - !cxt->mtab_writable); + mnt_update_set_filename(cxt->update, name, !cxt->mtab_writable); } if (cxt->action == MNT_ACT_UMOUNT) |