erofs-utils: add manifest input support
RFC 3/7 erofs-utils: lib: add erofs_build_shared_xattrs() helper
In reply to Wenyuan XuExtract shared xattr serialization from the local-directory scan so it can also be used with xattrs already attached to inodes.
Add erofs_build_shared_xattrs() to select shared entries without freeing inline entries. Retain an extra reference to shared entries until xattr manager cleanup.
--- include/erofs/xattr.h | 2 ++ lib/xattr.c | 52 +++++++++++++++++++++++++++++++++---------- 2 files changed, 42 insertions(+), 12 deletions(-)
include/erofs/xattr.h +2 -0
@@ -32,6 +32,8 @@ int erofs_prepare_xattr_ibody(struct erofs_inode *inode, bool noroom);char *erofs_export_xattr_ibody (struct erofs_inode *inode);int erofs_load_shared_xattrs_from_path (struct erofs_sb_info *sbi,const char *path,long inlinexattr_tolerance); +int erofs_build_shared_xattrs (struct erofs_sb_info *sbi, +long inlinexattr_tolerance);int erofs_xattr_insert_name_prefix (const char *prefix);int erofs_xattr_set_ishare_prefix (struct erofs_sb_info *sbi,const char *prefix);
lib/xattr.c +40 -12
73 lines not on this page · raw message
Signature · 1 line
2.43.0
RFC 1/7 erofs-utils: mkfs: init root inode in local source mode
In reply to Wenyuan Xu--- include/erofs/inode.h | 2 ++ lib/inode.c | 30 ++++-------------------------- mkfs/main.c | 8 +++++++- 3 files changed, 13 insertions(+), 27 deletions(-)
include/erofs/inode.h +2 -0
@@ -42,6 +42,8 @@ int erofs_allocate_inode_bh_data(struct erofs_inode *inode, erofs_blk_t nblocks,bool erofs_dentry_is_wht (struct erofs_sb_info *sbi,struct erofs_dentry *d);int __erofs_fill_inode (struct erofs_importer *im,struct erofs_inode *inode,struct stat *st,const char *path); +int erofs_fill_inode (struct erofs_importer *im,struct erofs_inode *inode, +struct stat *st,const char *path);struct erofs_inode *erofs_new_inode (struct erofs_sb_info *sbi);int erofs_importer_load_tree (struct erofs_importer *im,bool rebuild,bool incremental);
lib/inode.c +4 -26
@@ -1334,7 +1334,7 @@ int __erofs_fill_inode(struct erofs_importer *im, struct erofs_inode *inode,return 0 ; } -static int erofs_fill_inode (struct erofs_importer *im,struct erofs_inode *inode, +int erofs_fill_inode (struct erofs_importer *im,struct erofs_inode *inode,struct stat *st,const char *path) {const struct erofs_importer_params *params = im->params;
@@ -2251,30 +2251,6 @@ struct erofs_mkfs_buildtree_ctx {struct erofs_importer *im;bool rebuild, incremental; }; -#ifndef EROFS_MT_ENABLED -#define __erofs_mkfs_build_tree erofs_mkfs_build_tree -#endif - -static int __erofs_mkfs_build_tree (const struct erofs_mkfs_btctx *ctx) -{ -struct erofs_importer *im = ctx->im; - -if (!ctx->rebuild) { -struct erofs_importer_params *params = im->params; -struct stat st; -int err; - - err =lstat (params->source, &st); -if (err) -return -errno; - - err =erofs_fill_inode (im, im->root, &st, params->source); -if (err) -return err; - } -return erofs_mkfs_dump_tree (ctx); -} -#ifdef EROFS_MT_ENABLED #ifdef HAVE_SYS_RESOURCE_H
@@ -2339,7 +2315,7 @@ static int erofs_mkfs_build_tree(struct erofs_mkfs_btctx *ctx)if (err) goto fail; - err =__erofs_mkfs_build_tree (ctx); + err =erofs_mkfs_dump_tree (ctx);erofs_mkfs_go (ctx, ~0 ,NULL ,0 ); err2 =pthread_join (sbi->dfops_worker, &retval);DBG_BUGON (!q->exited);
@@ -2358,6 +2334,8 @@ fail:free (q);return err; } +#else +#define erofs_mkfs_build_tree erofs_mkfs_dump_tree#endif int erofs_importer_load_tree(struct erofs_importer *im, bool rebuild,
mkfs/main.c +7 -1
@@ -1987,7 +1987,13 @@ int main(int argc, char **argv) } importer.root = root; -if (source_mode ==EROFS_MKFS_SOURCE_TAR ) { +if (source_mode ==EROFS_MKFS_SOURCE_LOCALDIR ) { +struct stat st; + + err =lstat (cfg.c_src_path, &st); +if (!err) + err =erofs_fill_inode (&importer, importer.root, &st, cfg.c_src_path); + }else if (source_mode ==EROFS_MKFS_SOURCE_TAR ) {while (!(err =tarerofs_parse_tar (&importer, &erofstar))) ; }else if (source_mode ==EROFS_MKFS_SOURCE_REBUILD ) {
Signature · 1 line
2.43.0
cover erofs-utils: add manifest input support
Hi,
This series adds manifest input support to mkfs.erofs. It lets callers specify the image tree and metadata without first creating a matching staging directory, while reading regular file contents from a backing directory. Only entries listed in the manifest are imported; source directories are not scanned recursively.
This series is based on origin/experimental-tests.
Usage:
mkfs.erofs --manifest=manifest.txt out.erofs basedir/
The manifest accepts two record formats, which can be mixed:
PATH PAYLOAD SIZE MODE UID GID RDEV MTIME [KEY=VALUE ...] PATH PAYLOAD
The complete record syntax is inspired by composefs's "mkcomposefs --from-file" format, documented in composefs-dump(5) [1]. This series uses eight fixed fields with PAYLOAD immediately after PATH, omitting the NLINK, CONTENT and DIGEST fields from the composefs format.
Complete records specify metadata and xattrs explicitly. Regular file payloads identify backing files relative to basedir, symlink payloads provide link contents, and a MODE beginning with @ creates a hard link to an earlier entry. Fields unused for a file type are not parsed and can be written as '-'.
Two-field records import metadata, contents and xattrs from the backing file using local import policies. Symlinks are imported without following their targets, and source hard links are preserved unless --hard-dereference is specified.
PATH must start with '/', with the root directory defined first and parents preceding their children. Duplicate paths and xattr keys are rejected. String fields support \xXY byte escapes, including binary xattr values. MTIME uses seconds.nanoseconds, where 1.1 means one second and one nanosecond.
Both formats support regular file compression, xattr name prefixes and shared xattrs. They also work with --incremental=data: the manifest provides the update tree, matching directories are merged, and directory metadata comes from the new records. No on-disk format changes are required.
Patch 1 moves local root inode initialization to the local source path. Patches 2 and 3 add helpers for duplicate xattr detection and building shared xattrs from already loaded inodes. Patches 4 and 5 implement the complete and two-field formats. Patches 6 and 7 add documentation and regression coverage.
Test 033 covers file types, metadata, hard links, escaping, binary and shared xattrs, name prefixes, malformed records, compression and incremental updates. It checks images using dump.erofs and fsck.erofs.
Please apply the fix in [2] before running test 033.
[1] https://man.archlinux.org/man/composefs-dump.5.en
[2] https://lore.kernel.org/all/[email protected]/
Feedback on the record formats and importer integration is welcome.
Wenyuan Xu (7):
erofs-utils: mkfs: init root inode in local source mode
erofs-utils: lib: add erofs_inode_has_xattr helper
erofs-utils: lib: add erofs_build_shared_xattrs() helper
erofs-utils: mkfs: add manifest input mode
erofs-utils: mkfs: support two-field manifest records
erofs-utils: man: document manifest input formats
erofs-utils: tests: cover manifest input
include/erofs/inode.h | 2 + include/erofs/manifest.h | 17 ++ include/erofs/xattr.h | 3 + lib/Makefile.am | 3 +- lib/inode.c | 30 +- lib/manifest.c | 527 ++++++++++++++++++++++++++++++++ lib/xattr.c | 62 +++- man/mkfs.erofs.1 | 114 +++++++ mkfs/main.c | 43 ++- tests/Makefile.am | 3 + tests/erofs/033 | 637 +++++++++++++++++++++++++++++++++++++++ tests/erofs/033.out | 2 + 12 files changed, 1403 insertions(+), 40 deletions(-) create mode 100644 include/erofs/manifest.h create mode 100644 lib/manifest.c create mode 100755 tests/erofs/033 create mode 100644 tests/erofs/033.out
Signature · 1 line
2.43.0
RFC 5/7 erofs-utils: mkfs: support two-field manifest records
Accept PATH PAYLOAD records alongside complete manifest records. Import metadata and xattrs from the backing file using local import policies, without recursively scanning directories. Read symbolic links without following their targets.
Preserve source hard links unless hard dereferencing is requested, and count only entries imported into the image. Allow explicit hard links to refer to entries imported from backing files.
--- lib/manifest.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 2 deletions(-)
lib/manifest.c +86 -2
@@ -175,6 +175,75 @@ enum erofs_manifest_field { EROFS_MANIFEST_FIELD_COUNT, }; +static struct erofs_inode *erofs_manifest_load_local (struct erofs_importer *im, +struct erofs_inode *parent,char *payload) +{ +struct erofs_inode *inode; +struct stat st; +char *path; +size_t len; +int ret; + +/* PAYLOAD */ +if (erofs_manifest_decode (payload, false, &len) || *payload !='/' ) +return ERR_PTR (-EINVAL ); +if (asprintf (&path,"%s%s" , im->params->source, payload) <0 ) +return ERR_PTR (-ENOMEM ); + + ret =lstat (path, &st) ? -errno :0 ; +if (ret) + goto out_path; +if (!S_ISDIR (st.st_mode) && !im->params->hard_dereference) { + inode =erofs_iget (st.st_dev, st.st_ino); +if (inode) { +free (path); +if (inode->i_nlink ==UINT_MAX ) { +erofs_iput (inode); +return ERR_PTR (-EOVERFLOW ); + } + ++inode->i_nlink; +return inode; + } + } + + inode =erofs_new_inode (im->sbi); +if (IS_ERR (inode)) { + ret =PTR_ERR (inode); + goto out_path; + } + ret =erofs_fill_inode (im, inode, &st, path); +if (ret) + goto out_inode; + inode->i_parent = parent; + inode->datasource =EROFS_INODE_DATA_SOURCE_LOCALPATH ; +if (S_ISLNK (inode->i_mode)) { + inode->i_link =malloc (st.st_size); +if (!inode->i_link) { + ret = -ENOMEM ; + goto out_inode; + } +if (readlink (path, inode->i_link, st.st_size) <0 ) { + ret = -errno; + goto out_inode; + } + } + +if (!im->params->no_xattrs) { +/* XATTR */ + ret =erofs_scan_file_xattrs (inode); +if (ret) + goto out_inode; + } + +free (path); +return inode; +out_inode: +erofs_iput (inode); +out_path: +free (path); +return ERR_PTR (ret); +} +static int erofs_manifest_parse_record (struct erofs_importer *im,struct erofs_inode *sentinel,char *line) {
@@ -183,7 +252,7 @@ static int erofs_manifest_parse_record(struct erofs_importer *im,struct erofs_dentry *d;char *f[EROFS_MANIFEST_FIELD_COUNT ], *token, *dot;char name[EROFS_NAME_LEN +1 ]; -bool hardlink, is_root; +bool hardlink, is_root, short_record = false;u64 mode, size =0 , uid, gid, rdev =0 , sec, nsec;size_t len;int i, ret = -EINVAL ;
@@ -196,8 +265,13 @@ static int erofs_manifest_parse_record(struct erofs_importer *im,do { token =strsep (&line," " ); }while (token && !*token); -if (!token) +if (!token) { +if (i ==EROFS_MANIFEST_PAYLOAD +1 ) { + short_record = true; +break ; + }return -EINVAL ; + } f[i] = token; }
@@ -212,6 +286,16 @@ static int erofs_manifest_parse_record(struct erofs_importer *im,return -EEXIST ; is_root = parent == sentinel; +if (short_record) { + inode =erofs_manifest_load_local (im, parent, + f[EROFS_MANIFEST_PAYLOAD ]); +if (IS_ERR (inode)) +return PTR_ERR (inode); +if (is_root && !S_ISDIR (inode->i_mode)) + goto out; + goto link; + } +/* MODE */ hardlink = f[EROFS_MANIFEST_MODE ][0 ] =='@' ;if (hardlink) {
Signature · 1 line
2.43.0
RFC 4/7 erofs-utils: mkfs: add manifest input mode
In reply to Wenyuan XuAdd --manifest=FILE to build an inode tree from explicit path, payload, metadata and xattr records without scanning the source directory. Regular file payloads are resolved relative to the source directory.
Support escaped strings, binary xattr values, hard links and special files. Reject duplicate paths and xattr keys, require parents before children, and report malformed records with their line and field.
Build shared xattrs from the loaded tree and mark directories containing whiteouts before passing the tree to the importer.
--- include/erofs/manifest.h | 17 ++ lib/Makefile.am | 3 +- lib/manifest.c | 443 +++++++++++++++++++++++++++++++++++++++ mkfs/main.c | 35 ++++ 4 files changed, 497 insertions(+), 1 deletion(-) create mode 100644 include/erofs/manifest.h create mode 100644 lib/manifest.c
include/erofs/manifest.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0+ OR MIT */ +#ifndef __EROFS_MANIFEST_H +#define __EROFS_MANIFEST_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +struct erofs_importer ; +int erofs_manifest_load (struct erofs_importer *im,const char *filename); + +#ifdef __cplusplus +} +#endif + +#endif
lib/Makefile.am +2 -1
@@ -20,6 +20,7 @@ noinst_HEADERS = $(top_srcdir)/include/erofs_fs.h \ $(top_srcdir)/include/erofs/xattr.h \ $(top_srcdir)/include/erofs/compress_hints.h \ $(top_srcdir)/include/erofs/importer.h \ + $(top_srcdir)/include/erofs/manifest.h \ $(top_srcdir)/lib/liberofs_base64.h \ $(top_srcdir)/lib/liberofs_cache.h \ $(top_srcdir)/lib/liberofs_chunk.h \
@@ -44,7 +45,7 @@ liberofs_la_SOURCES = config.c io.c cache.c super.c inode.c xattr.c exclude.c \ compress_hints.c sha256.c blobchunk.c dir.c \ fragments.c dedupe.c uuid_unparse.c uuid.c tar.c \ block_list.c rebuild.c diskbuf.c bitops.c dedupe_ext.c \ - vmdk.c metabox.c global.c importer.c base64.c + vmdk.c metabox.c global.c importer.c base64.c manifest.c liberofs_la_CFLAGS = -Wall ${libuuid_CFLAGS} -I$(top_srcdir)/include liberofs_la_LIBADD = $(LIBEROFS_LIBS)
lib/manifest.c new file +443 -0
443 lines not on this page · raw message
mkfs/main.c +35 -0
@@ -24,6 +24,7 @@#include "erofs/exclude.h" #include "erofs/block_list.h" #include "erofs/compress_hints.h" +#include "erofs/manifest.h" #include "../lib/compressor.h" #include "../lib/liberofs_chunk.h" #include "../lib/liberofs_gzran.h"
@@ -105,6 +106,7 @@ static struct option long_options[] = { {"MZ", optional_argument, NULL, 537}, {"xattr-prefix", required_argument, NULL, 538}, {"xattr-inode-digest", optional_argument, NULL, 539}, + {"manifest", required_argument, NULL, 540}, {0, 0, 0, 0}, };
@@ -212,6 +214,7 @@ static void usage(int argc, char **argv)" --hard-dereference dereference hardlinks, add links as separate inodes\n" " --ignore-mtime use build time instead of strict per-file modification time\n" " --max-extent-bytes=# set maximum decompressed extent size # in bytes\n" +" --manifest=FILE build an uncompressed image from a manifest and basedir\n" " --mount-point=X X=prefix of target fs path (default: /)\n" " --preserve-mtime keep per-file modification time strictly\n" " --offset=# skip # bytes at the beginning of IMAGE.\n"
@@ -324,8 +327,10 @@ static enum {EROFS_MKFS_SOURCE_S3 ,EROFS_MKFS_SOURCE_OCI ,EROFS_MKFS_SOURCE_REBUILD , +EROFS_MKFS_SOURCE_MANIFEST , } source_mode; +static const char *manifest_file;static unsigned int rebuild_src_count;static LIST_HEAD (rebuild_src_list);static u8 fixeduuid[16 ];
@@ -971,6 +976,7 @@ static int mkfs_parse_sources(int argc, char *argv[], int optind)char *s;switch (source_mode) { +case EROFS_MKFS_SOURCE_MANIFEST :case EROFS_MKFS_SOURCE_LOCALDIR : err =lstat ((s = argv[optind++]), &st);if (err) {
@@ -986,6 +992,8 @@ static int mkfs_parse_sources(int argc, char *argv[], int optind)return -ENOENT ; }erofs_set_fs_root (cfg.c_src_path); + }else if (source_mode ==EROFS_MKFS_SOURCE_MANIFEST ) { +return -ENOTDIR ; }else { cfg.c_src_path =strdup (s);if (!cfg.c_src_path)
@@ -1497,6 +1505,14 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params,return err; }break ; +case 540 : +if (manifest_file) { +erofs_err ("duplicate manifest file" ); +return -EINVAL ; + } + manifest_file = optarg; + source_mode =EROFS_MKFS_SOURCE_MANIFEST ; +break ;case 'V' :version ();exit (0 );
@@ -1970,6 +1986,14 @@ int main(int argc, char **argv) err =PTR_ERR (root); goto exit; } + }else if (source_mode ==EROFS_MKFS_SOURCE_MANIFEST ) { + err =erofs_xattr_flush_name_prefixes (&importer, + mkfs_plain_xattr_pfx); +if (err) { +erofs_err ("failed to flush long xattr prefixes: %s" , +erofs_strerror (err)); + goto exit; + } }else { err =erofs_xattr_flush_name_prefixes (&importer, mkfs_plain_xattr_pfx);
@@ -1993,6 +2017,17 @@ int main(int argc, char **argv) err =lstat (cfg.c_src_path, &st);if (!err) err =erofs_fill_inode (&importer, importer.root, &st, cfg.c_src_path); + }else if (source_mode ==EROFS_MKFS_SOURCE_MANIFEST ) { + err =erofs_manifest_load (&importer, manifest_file); +if (err) + goto exit; + root = importer.root; + + err =erofs_build_shared_xattrs (&g_sbi, mkfscfg.inlinexattr_tolerance); +if (err) { +erofs_err ("failed to build shared xattrs: %s" ,erofs_strerror (err)); + goto exit; + } }else if (source_mode ==EROFS_MKFS_SOURCE_TAR ) {while (!(err =tarerofs_parse_tar (&importer, &erofstar))) ;
Signature · 1 line
2.43.0
RFC 6/7 erofs-utils: man: document manifest input formats
In reply to Wenyuan XuDocument complete and two-field manifest records, path handling, metadata policies, hard links and shared xattrs.
--- man/mkfs.erofs.1 | 114 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+)
man/mkfs.erofs.1 +114 -0
@@ -32,6 +32,10 @@ other EROFS image(s), see \fIREBUILD MODE\fR below .RE .SH OPTIONS .TP +.BI "\-\-manifest=" FILE +Build an image from a manifest and a base directory. +See \fIMANIFEST INPUT MODE\fR below. +.TP .BI "\-b " block-size Set the fundamental block size of the filesystem in bytes. In other words, specify the smallest amount of data that can be accessed at a time. The
@@ -224,6 +228,9 @@ The current source-specific support for \fIMODE\fR: .I Local directory source Only \fBdata\fR is supported. \fBrvsp\fR and \fB0\fR will be ignored. .TP +.I Manifest source (\fB\-\-manifest\fR) +\fBdata\fR is supported with both complete and short records. +.TP .I Tar source (\fB\-\-tar\fR) \fBdata\fR and \fBrvsp\fR are supported. \fB0\fR will be ignored. Note that \fBrvsp\fR takes precedence over \fB--tar=i\fR or \fB--tar=headerball\fR.
@@ -331,6 +338,11 @@ The current source-specific support for \fIMODE\fR: .I Local directory source Only \fBdata\fR is supported. \fBrvsp\fR and \fB0\fR will be ignored. .TP +.I Manifest source (\fB\-\-manifest\fR) +\fBdata\fR is supported with both complete and short records. +See \fIMANIFEST INPUT MODE\fR below for incremental usage and parent +directory requirements. +.TP .I Tar source (\fB\-\-tar\fR) \fBdata\fR and \fBrvsp\fR are supported. \fB0\fR will be ignored. Note that \fBrvsp\fR takes precedence over \fB--tar=i\fR or \fB--tar=headerball\fR.
@@ -497,6 +509,108 @@ Display help string and exit. .TP \fB\-V\fR, \fB\-\-version\fR Print the version number and exit. +.SH MANIFEST INPUT MODE +With \fB--manifest=FILE\fR, \fISOURCE\fR is a base directory supplying backing +files. The manifest defines the image tree for a clean build, or the update +tree for an incremental build; source directories are not recursively scanned. +Two record formats may be mixed in the same file: +.PP +.nf +PATH PAYLOAD +PATH PAYLOAD SIZE MODE UID GID RDEV MTIME [KEY=VALUE ...] +.fi +.PP +Exactly two fields select the short format. Three through seven fields are +invalid. Eight or more fields select the complete format. +.PP +Both formats support regular file compression with \fB-z\fR, using the same +compression options as local-directory input. Without \fB-z\fR, regular file +data is stored uncompressed. +.PP +In the short format, PAYLOAD is a backing path beginning with /, appended +directly to SOURCE after decoding. Repeated slashes and . or .. components +are resolved by the host filesystem. A directory record imports only that +directory, not its children. +.PP +The field descriptions below apply to complete records unless noted. +.PP +Records are separated by newlines; the last newline is optional. Blank records +and comments are not supported. Unused fields require a nonempty placeholder +('-' is preferred as a placeholder) but are not parsed. +.PP +In both formats, PATH names an image entry and must begin with /. The first record +must define the root directory. Every parent directory must precede its children, +and duplicate paths are errors. Repeated and trailing slashes in PATH are skipped. +Individual . and .. components are forbidden. +.TP +.B Regular files +PAYLOAD begins with / and is interpreted relative to the base directory, not +the host root. The decoded PAYLOAD is appended directly to the base directory; +repeated slashes and . or .. components are resolved by the host filesystem, +as are symlinks. The source must be a regular file whose size +exactly equals SIZE, including for empty files. RDEV is unused. +.TP +.B Directories +SIZE, PAYLOAD and RDEV are unused. A record describes only the directory itself; +its size is computed from the generated directory entries. +.TP +.B Symbolic links +PAYLOAD is the link content; repeated slashes are preserved. +SIZE must equal its decoded byte length. RDEV is unused. +.TP +.B Hard links +A MODE beginning with @ denotes a hard link. PATH creates the new entry and +PAYLOAD names an already defined non-directory entry in the image. Only the +leading @ in MODE is examined; all other fields and xattrs are ignored. +Hard links to earlier hard links are supported. +Repeated and trailing slashes in PAYLOAD are skipped. +An explicit @ hard link may refer to a previously defined short record. +.TP +.B Character/block devices, sockets and FIFOs +SIZE and PAYLOAD are unused. RDEV is the decimal value of stat.st_rdev; +use zero for sockets and FIFOs. +.PP +MODE is an octal stat.st_mode, including file type bits; arbitrary leading zeros +are accepted. SIZE, UID, GID and RDEV are unsigned decimal integers within the +supported ranges. MTIME is nonnegative seconds.nanoseconds since the Unix +epoch. It is not a floating-point value: 1.1 means one second plus one nanosecond. +Nanoseconds must be between 0 and 999999999. +.PP +PATH, used PAYLOAD fields and xattrs encode special bytes as \fB\exXY\fR, +where XY is a two-digit hexadecimal byte, with either letter case accepted. +For example, a space is \fB\ex20\fR and a backslash is \fB\ex5c\fR. +An equals sign within an xattr key or value must be encoded as \fB\ex3d\fR; +it may appear literally in PATH and PAYLOAD. +NUL is forbidden in paths, symlink contents and xattr keys, but is permitted in +xattr values. Empty xattr values are supported. Repeated keys within one record +are rejected after decoding the keys. Keys must use a supported EROFS xattr +namespace and be at most 255 bytes; values must fit the on-disk 16-bit length field. +Identical keys and values used by more than the \fB-x\fR threshold of distinct +inodes are stored as shared xattrs. +.PP +For example, using data from \fIbasedir/source\fR: +.PP +.nf +/ - - 40755 0 0 - 1.0 +/file /source 3 100644 1000 1000 - 1.1 user.note=hello\ex20world +/link /file - @ - - - - +/symlink file 4 120777 1000 1000 - 1.0 +.fi +.PP +.nf +mkfs.erofs --manifest=manifest.txt out.erofs basedir +.fi +.PP +Both formats support \fB--incremental=data\fR (or \fB--incremental\fR) with +an existing image as DESTINATION and a backing directory as SOURCE: +.PP +.nf +mkfs.erofs --incremental=data --manifest=updates.txt base.erofs updates/ +.fi +.PP +The manifest must still define the root directory first and each parent before +its children, even when those directories already exist in the image. +.PP .SH NOTES .TP .B REBUILD MODE
Signature · 1 line
2.43.0
RFC 2/7 erofs-utils: lib: add erofs_inode_has_xattr helper
In reply to Wenyuan XuAllow callers to check whether an inode already has an in-memory xattr with a given name without exposing the internal xattr structures.
--- include/erofs/xattr.h | 1 + lib/xattr.c | 10 ++++++++++ 2 files changed, 11 insertions(+)
include/erofs/xattr.h +1 -0
@@ -45,6 +45,7 @@ int erofs_setxattr(struct erofs_inode *inode, int index, const char *name, const void *value, size_t size);int erofs_vfs_setxattr (struct erofs_inode *inode,const char *name,const void *value,size_t size); +bool erofs_inode_has_xattr (struct erofs_inode *inode,const char *name);int erofs_set_opaque_xattr (struct erofs_inode *inode);void erofs_clear_opaque_xattr (struct erofs_inode *inode);bool erofs_get_opaque_from_disk (struct erofs_inode *inode);
lib/xattr.c +10 -0
@@ -579,6 +579,16 @@ int erofs_vfs_setxattr(struct erofs_inode *inode, const char *name,return erofs_setxattr (inode,0 , name, value, size); } +bool erofs_inode_has_xattr (struct erofs_inode *inode,const char *name) +{ +struct erofs_inode_xattr_node *node; + +list_for_each_entry (node, &inode->i_xattrs, list) +if (!strcmp (node->item->kvbuf, name)) +return true; +return false; +} +static void erofs_removexattr (struct erofs_inode *inode,const char *key) {struct erofs_inode_xattr_node *node, *n;
Signature · 1 line
2.43.0
RFC 7/7 erofs-utils: tests: cover manifest input
In reply to Wenyuan XuAdd test 033 for complete and two-field records, metadata, path validation, hard links, symbolic links and whiteouts.
Check binary xattrs, name prefixes, shared storage and local import options using the existing dump and fsck tools.
--- tests/Makefile.am | 3 + tests/erofs/033 | 637 ++++++++++++++++++++++++++++++++++++++++++++ tests/erofs/033.out | 2 + 3 files changed, 642 insertions(+) create mode 100755 tests/erofs/033 create mode 100644 tests/erofs/033.out
tests/Makefile.am +3 -0
@@ -135,6 +135,9 @@ TESTS += erofs/031 # 032 - check that the xattr layout does not depend on listxattr(2) order TESTS += erofs/032 +# 033 - manifest rebuild input and validation +TESTS += erofs/033 + # NEW TEST CASE HERE # TESTS += erofs/999
tests/erofs/033 new file +637 -0
637 lines not on this page · raw message
tests/erofs/033.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 033 +Silence is golden
Signature · 1 line
2.43.0