git: b78d5b424145 - main - makefs: handle mtree link= for ZFS
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 12 Jan 2023 18:20:14 UTC
The branch main has been updated by brooks:
URL: https://cgit.FreeBSD.org/src/commit/?id=b78d5b42414518dd85b2ebf2f15ba8a742ead399
commit b78d5b42414518dd85b2ebf2f15ba8a742ead399
Author: Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2023-01-12 18:18:45 +0000
Commit: Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2023-01-12 18:18:45 +0000
makefs: handle mtree link= for ZFS
When a link target is specified use it rather than attempting to read
a potentially non-existant file.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D38028
---
usr.sbin/makefs/zfs/fs.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/usr.sbin/makefs/zfs/fs.c b/usr.sbin/makefs/zfs/fs.c
index b9cc860c2e29..3cf328122df8 100644
--- a/usr.sbin/makefs/zfs/fs.c
+++ b/usr.sbin/makefs/zfs/fs.c
@@ -297,15 +297,23 @@ fs_readlink(const fsnode *cur, struct fs_populate_arg *arg,
char *buf, size_t bufsz)
{
char path[PATH_MAX];
- ssize_t n;
int fd;
- fs_populate_path(cur, arg, path, sizeof(path), &fd);
+ if (cur->symlink != NULL) {
+ size_t n;
- n = readlinkat(fd, path, buf, bufsz - 1);
- if (n == -1)
- err(1, "readlinkat(%s)", cur->name);
- buf[n] = '\0';
+ n = strlcpy(buf, cur->symlink, bufsz);
+ assert(n < bufsz);
+ } else {
+ ssize_t n;
+
+ fs_populate_path(cur, arg, path, sizeof(path), &fd);
+
+ n = readlinkat(fd, path, buf, bufsz - 1);
+ if (n == -1)
+ err(1, "readlinkat(%s)", cur->name);
+ buf[n] = '\0';
+ }
}
static void