Hi, there are filesystem-specific options (e.g. _PC_2_SYMLINKS) which cannot expressed currently with variables of libdiskfs (that is, which libdiskfs does not know). My proposal is to add a new function, optionally overridable by filesystems-specific implementation, to return custom pathconf replies, eventually overriding those already returned by the diskfs/netfs io_pathconf.
Attached there is a prototype, without comments nor copyright; of couse a final version would also cover libnetfs, and more filesystems currently in hurd.git. AFAICT, this solution should maintain source and binary compatibility, and a filesystem providing such diskfs_pathconf implementation should run fine even with an older libdisks (but I did not test this case). What do you think about this solution? -- Pino Toscano
--- a/libdiskfs/diskfs.h
+++ b/libdiskfs/diskfs.h
@@ -553,6 +553,9 @@
DISKFS_READONLY true. */
error_t diskfs_node_reload (struct node *node);
+/* The user may define this function. */
+error_t diskfs_pathconf (struct node *np, int name, int *value);
+
/* If this function is nonzero (and diskfs_shortcut_symlink is set) it
is called to set a symlink. If it returns EINVAL or isn't set,
then the normal method (writing the contents into the file data) is
--- /dev/null
+++ b/libdiskfs/pathconf.c
@@ -0,0 +1,8 @@
+#include "priv.h"
+
+error_t
+diskfs_pathconf (struct node *np, int name, int *value)
+{
+ return EINVAL;
+}
+
--- a/libdiskfs/io-pathconf.c
+++ b/libdiskfs/io-pathconf.c
@@ -30,6 +30,10 @@
if (!cred)
return EOPNOTSUPP;
+ error_t err = diskfs_pathconf (cred->po->np, name, value);
+ if (err != EINVAL)
+ return err;
+
switch (name)
{
case _PC_LINK_MAX:
--- a/tmpfs/tmpfs.c
+++ b/tmpfs/tmpfs.c
@@ -98,6 +98,22 @@
return 0;
}
+error_t
+diskfs_pathconf (struct node *np, int name, int *value)
+{
+ switch (name)
+ {
+ case _PC_2_SYMLINKS:
+ *value = 1;
+ break;
+
+ default:
+ return EINVAL;
+ }
+
+ return 0;
+}
+
int diskfs_synchronous = 0;
static const struct argp_option options[] =
--- a/libdiskfs/Makefile
+++ b/libdiskfs/Makefile
@@ -51,7 +51,7 @@
remount.c console.c disk-pager.c \
name-cache.c direnter.c dirrewrite.c dirremove.c lookup.c dead-name.c \
validate-mode.c validate-group.c validate-author.c validate-flags.c \
- validate-rdev.c validate-owner.c extra-version.c
+ validate-rdev.c validate-owner.c extra-version.c pathconf.c
SRCS = $(OTHERSRCS) $(FSSRCS) $(IOSRCS) $(FSYSSRCS) $(IFSOCKSRCS)
installhdrs = diskfs.h diskfs-pager.h
signature.asc
Description: This is a digitally signed message part.
