From: Luca Di Maio <luca.dimaio1@gmail.com>
To: linux-xfs@vger.kernel.org
Cc: Luca Di Maio <luca.dimaio1@gmail.com>,
dimitri.ledkov@chainguard.dev, smoser@chainguard.dev,
djwong@kernel.org, hch@infradead.org
Subject: [PATCH v6 1/4] proto: expose more functions from proto
Date: Wed, 23 Apr 2025 18:03:16 +0200 [thread overview]
Message-ID: <20250423160319.810025-2-luca.dimaio1@gmail.com> (raw)
In-Reply-To: <20250423160319.810025-1-luca.dimaio1@gmail.com>
In order to minimize code duplication, we want to expose more functions
from proto. This will simplify alternative implementations of filesystem
population.
Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
---
mkfs/proto.c | 33 ++++++++++++---------------------
mkfs/proto.h | 22 ++++++++++++++++++++++
2 files changed, 34 insertions(+), 21 deletions(-)
diff --git a/mkfs/proto.c b/mkfs/proto.c
index 7f56a3d..695e1a6 100644
--- a/mkfs/proto.c
+++ b/mkfs/proto.c
@@ -16,11 +16,7 @@
*/
static char *getstr(char **pp);
static void fail(char *msg, int i);
-static struct xfs_trans * getres(struct xfs_mount *mp, uint blocks);
-static void rsvfile(xfs_mount_t *mp, xfs_inode_t *ip, long long len);
static int newregfile(char **pp, char **fname);
-static void rtinit(xfs_mount_t *mp);
-static off_t filesize(int fd);
static int slashes_are_spaces;
/*
@@ -115,7 +111,7 @@ res_failed(
fail(_("cannot reserve space"), i);
}
-static struct xfs_trans *
+struct xfs_trans *
getres(
struct xfs_mount *mp,
uint blocks)
@@ -196,7 +192,7 @@ getdirentname(
return p;
}
-static void
+void
rsvfile(
xfs_mount_t *mp,
xfs_inode_t *ip,
@@ -242,7 +238,7 @@ rsvfile(
fail(_("committing space for a file failed"), error);
}
-static void
+void
writesymlink(
struct xfs_trans *tp,
struct xfs_inode *ip,
@@ -303,7 +299,7 @@ writefile_range(
}
}
-static void
+void
writefile(
struct xfs_inode *ip,
const char *fname,
@@ -410,7 +406,7 @@ writeattr(
fail(_("setting xattr value"), error);
}
-static void
+void
writeattrs(
struct xfs_inode *ip,
const char *fname,
@@ -467,7 +463,7 @@ newregfile(
return fd;
}
-static void
+void
newdirent(
struct xfs_mount *mp,
struct xfs_trans *tp,
@@ -498,7 +494,7 @@ newdirent(
}
}
-static void
+void
newdirectory(
xfs_mount_t *mp,
xfs_trans_t *tp,
@@ -512,7 +508,7 @@ newdirectory(
fail(_("directory create error"), error);
}
-static struct xfs_parent_args *
+struct xfs_parent_args *
newpptr(
struct xfs_mount *mp)
{
@@ -526,12 +522,7 @@ newpptr(
return ret;
}
-struct cred {
- uid_t cr_uid;
- gid_t cr_gid;
-};
-
-static int
+int
creatproto(
struct xfs_trans **tpp,
struct xfs_inode *dp,
@@ -594,7 +585,7 @@ creatproto(
}
/* Create a new metadata root directory. */
-static int
+int
create_metadir(
struct xfs_mount *mp)
{
@@ -1151,7 +1142,7 @@ rtinit_groups(
/*
* Allocate the realtime bitmap and summary inodes, and fill in data if any.
*/
-static void
+void
rtinit(
struct xfs_mount *mp)
{
@@ -1161,7 +1152,7 @@ rtinit(
rtinit_nogroups(mp);
}
-static off_t
+off_t
filesize(
int fd)
{
diff --git a/mkfs/proto.h b/mkfs/proto.h
index be1ceb4..9abb9b8 100644
--- a/mkfs/proto.h
+++ b/mkfs/proto.h
@@ -5,10 +5,32 @@
*/
#ifndef MKFS_PROTO_H_
#define MKFS_PROTO_H_
+struct cred {
+ uid_t cr_uid;
+ gid_t cr_gid;
+};
char *setup_proto(char *fname);
void parse_proto(struct xfs_mount *mp, struct fsxattr *fsx, char **pp,
int proto_slashes_are_spaces);
void res_failed(int err);
+struct xfs_trans *getres(struct xfs_mount *mp, uint blocks);
+struct xfs_parent_args *newpptr(struct xfs_mount *mp);
+void writesymlink(struct xfs_trans *tp, struct xfs_inode *ip,
+ char *buf, int len);
+void writefile(struct xfs_inode *ip, const char *fname, int fd);
+void writeattrs(struct xfs_inode *ip, const char *fname, int fd);
+void rsvfile(xfs_mount_t *mp, xfs_inode_t *ip, long long len);
+void newdirent(struct xfs_mount *mp, struct xfs_trans *tp,
+ struct xfs_inode *pip, struct xfs_name *name,
+ struct xfs_inode *ip, struct xfs_parent_args *ppargs);
+void newdirectory(xfs_mount_t *mp, xfs_trans_t *tp,
+ xfs_inode_t *dp, xfs_inode_t *pdp);
+int creatproto(struct xfs_trans **tpp, struct xfs_inode *dp,
+ mode_t mode, xfs_dev_t rdev, struct cred *cr,
+ struct fsxattr *fsx, struct xfs_inode **ipp);
+long filesize(int fd);
+void rtinit(struct xfs_mount *mp);
+int create_metadir(struct xfs_mount *mp);
#endif /* MKFS_PROTO_H_ */
--
2.49.0
next prev parent reply other threads:[~2025-04-23 16:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-23 16:03 [PATCH v6 0/4] mkfs: add ability to populate filesystem from directory Luca Di Maio
2025-04-23 16:03 ` Luca Di Maio [this message]
2025-04-23 16:03 ` [PATCH v6 2/4] populate: add ability to populate a filesystem from a directory Luca Di Maio
2025-04-23 20:23 ` Darrick J. Wong
2025-04-24 16:09 ` Luca Di Maio
2025-04-24 22:00 ` Darrick J. Wong
2025-04-25 13:10 ` Christoph Hellwig
2025-04-25 15:00 ` Darrick J. Wong
2025-04-25 17:58 ` Luca Di Maio
2025-04-23 16:03 ` [PATCH v6 3/4] mkfs: add -P flag " Luca Di Maio
2025-04-23 20:09 ` Darrick J. Wong
2025-04-24 12:01 ` Luca Di Maio
2025-04-24 21:55 ` Darrick J. Wong
2025-04-23 16:03 ` [PATCH v6 4/4] man: document " Luca Di Maio
2025-04-23 20:03 ` [PATCH v6 0/4] mkfs: add ability to populate filesystem from directory Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250423160319.810025-2-luca.dimaio1@gmail.com \
--to=luca.dimaio1@gmail.com \
--cc=dimitri.ledkov@chainguard.dev \
--cc=djwong@kernel.org \
--cc=hch@infradead.org \
--cc=linux-xfs@vger.kernel.org \
--cc=smoser@chainguard.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox