aboutsummaryrefslogtreecommitdiffstats
path: root/libmount/src/hook_mount.c
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2024-05-22 10:52:04 +0200
committerKarel Zak <kzak@redhat.com>2024-05-22 10:52:04 +0200
commitc40235720ee0a742f4d8aca2333e1ccad726269a (patch)
tree618a8b90ddba17d7aa7608c860c560b4d3d66e99 /libmount/src/hook_mount.c
parent6b871f465b436a792623bb9492ada9d51e22b4ba (diff)
downloadutil-linux-c40235720ee0a742f4d8aca2333e1ccad726269a.tar.gz
libmount: add functions to use error buffer
* Add mnt_context_set_errmsg() and mnt_context_append_errmsg() functions. * Replace custom code with mnt_context_syscall_save_status() function. * Optionally use syscall name when generating error message. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/hook_mount.c')
-rw-r--r--libmount/src/hook_mount.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/libmount/src/hook_mount.c b/libmount/src/hook_mount.c
index c85c92b983..6b7caff853 100644
--- a/libmount/src/hook_mount.c
+++ b/libmount/src/hook_mount.c
@@ -70,8 +70,7 @@ static void save_fd_messages(struct libmnt_context *cxt, int fd)
uint8_t buf[BUFSIZ];
int rc;
- free(cxt->syscall_errmsg);
- cxt->syscall_errmsg = NULL;
+ mnt_context_set_errmsg(cxt, NULL);
while ((rc = read(fd, buf, sizeof(buf))) != -1) {
if (rc > 0 && buf[rc - 1] == '\n')
@@ -80,10 +79,7 @@ static void save_fd_messages(struct libmnt_context *cxt, int fd)
if (rc < 3 || strncmp((char *) buf, "e ", 2) != 0)
continue;
- if (cxt->syscall_errmsg)
- strappend(&cxt->syscall_errmsg, "; ");
-
- strappend(&cxt->syscall_errmsg, ((char *) buf) + 2);
+ mnt_context_append_errmsg(cxt, ((char *) buf) + 2);
}
}