aboutsummaryrefslogtreecommitdiff
path: root/libdiskfs/diskfs.h
diff options
context:
space:
mode:
Diffstat (limited to 'libdiskfs/diskfs.h')
-rw-r--r--libdiskfs/diskfs.h600
1 files changed, 219 insertions, 381 deletions
diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h
index 8cada32f..2051e41d 100644
--- a/libdiskfs/diskfs.h
+++ b/libdiskfs/diskfs.h
@@ -1,5 +1,7 @@
/* Definitions for fileserver helper functions
- Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
+
+ Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2007, 2008,
+ 2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -18,13 +20,20 @@
#ifndef _HURD_DISKFS
#define _HURD_DISKFS
-#include <argp.h>
#include <assert.h>
#include <unistd.h>
#include <rwlock.h>
#include <hurd/ports.h>
#include <hurd/fshelp.h>
#include <hurd/iohelp.h>
+#include <idvec.h>
+#include <features.h>
+
+#ifdef DISKFS_DEFINE_EXTERN_INLINE
+#define DISKFS_EXTERN_INLINE
+#else
+#define DISKFS_EXTERN_INLINE __extern_inline
+#endif
/* Each user port referring to a file points to one of these
(with the aid of the ports library). */
@@ -33,8 +42,7 @@ struct protid
struct port_info pi; /* libports info block */
/* User identification */
- uid_t *uids, *gids;
- int nuids, ngids;
+ struct iouser *user;
/* Object this refers to */
struct peropen *po;
@@ -44,15 +52,23 @@ struct protid
struct shared_io *mapped;
};
-/* One of these is created for each node opened by dir_pathtrans. */
+/* One of these is created for each node opened by dir_lookup. */
struct peropen
{
int filepointer;
int lock_status;
int refcnt;
int openstat;
- mach_port_t dotdotport; /* dotdot from ROOT through this peropen */
+
struct node *np;
+
+ /* The parent of the translator's root node. */
+ mach_port_t root_parent;
+
+ /* If this node is in a shadow tree, the parent of its root. */
+ mach_port_t shadow_root_parent;
+ /* If in a shadow tree, its root node in this translator. */
+ struct node *shadow_root;
};
/* A unique one of these exists for each node currently in use (and
@@ -64,12 +80,11 @@ struct node
struct disknode *dn;
- struct stat dn_stat;
- int istranslated;
+ io_statbuf_t dn_stat;
/* Stat has been modified if one of the following four fields
is nonzero. Also, if one of the dn_set_?time fields is nonzero,
- the appropriate dn_stat.st_?time field needs to be updated. */
+ the appropriate dn_stat.st_?tim field needs to be updated. */
int dn_set_ctime;
int dn_set_atime;
int dn_set_mtime;
@@ -90,11 +105,17 @@ struct node
struct conch conch;
- struct dirmod *dirmod_reqs;
+ struct modreq *dirmod_reqs;
+ unsigned int dirmod_tick;
- off_t allocsize;
+ struct modreq *filemod_reqs;
+ unsigned int filemod_tick;
- int cache_id;
+ loff_t allocsize;
+
+ ino64_t cache_id;
+
+ int author_tracks_uid;
};
/* Possibly lookup types for diskfs_lookup call */
@@ -106,23 +127,25 @@ enum lookup_type
RENAME,
};
-/* Pending directory modification request */
-struct dirmod
+/* Pending directory and file modification request */
+struct modreq
{
mach_port_t port;
- struct dirmod *next;
+ struct modreq *next;
};
/* Special flag for diskfs_lookup. */
#define SPEC_DOTDOT 0x10000000
+struct argp; /* opaque in this file */
+struct argp_child; /* opaque in this file */
+struct store; /* opaque in this file */
+struct store_parsed; /* opaque in this file */
/* Declarations of variables the library sets. */
extern mach_port_t diskfs_default_pager; /* send right */
-extern mach_port_t diskfs_exec_ctl; /* send right */
-extern mach_port_t diskfs_exec; /* send right */
extern auth_t diskfs_auth_server_port; /* send right */
/* The io_identity identity port for the filesystem. */
@@ -133,10 +156,20 @@ extern mach_port_t diskfs_fsys_identity;
file systems, to give the procserver. */
extern char **diskfs_argv;
-/* When this is a bootstrap filesystem, the command line options passed from
- the kernel. If not a bootstrap filesystem, it is 0, so it can be used to
- distinguish between the two cases. */
-extern char *diskfs_boot_flags;
+/* When this is a bootstrap filesystem, the multiboot kernel command
+ line passed from the kernel. If not a bootstrap filesystem, it is
+ 0. As such, it can be used to distinguish between the two cases.
+ Note: this is only valid after the arguments have been parsed by,
+ for example, diskfs_init_main. */
+extern const char *diskfs_boot_command_line;
+#define diskfs_boot_filesystem() (diskfs_boot_command_line != 0)
+
+/* When this is a bootstrap filesystem, nonzero if starting each bootstrap
+ program should pause for a keystroke, for debugging purposes. */
+extern int _diskfs_boot_pause;
+
+/* Name of the init program run when this is a bootstrap filesystem. */
+extern const char *diskfs_boot_init_program;
/* Hold this lock while do fsys level operations. Innocuous users can just
hold a reader lock, and anyone who's going to do nasty things that would
@@ -155,6 +188,9 @@ extern spin_lock_t diskfs_node_refcnt_lock;
extern int pager_port_type;
+/* Whether the filesystem is currently writable or not. */
+extern int diskfs_readonly;
+
struct pager;
@@ -178,7 +214,7 @@ struct dirstat;
/* The user must define this variable; it should be the size in bytes
of a struct dirstat. */
-extern size_t diskfs_dirstat_size;
+extern const size_t diskfs_dirstat_size;
/* The user must define this variable; it is the maximum number of
links to any one file. The implementation of dir_rename does not know
@@ -186,14 +222,20 @@ extern size_t diskfs_dirstat_size;
reimplement dir_rename yourself. */
extern int diskfs_link_max;
+/* The user must define this variable; it is the maximum length of
+ a single pathname component (i.e. file name within directory).
+ The filesystem code does not use this for anything, but it is
+ returned to user queries for _PC_NAME_MAX. */
+extern int diskfs_name_max;
+
/* The user must define this variable; it is the maximum number of
- symlinks to be traversed within a single call to dir_pathtrans.
- If this is exceeded, dir_pathtrans will return ELOOP. */
+ symlinks to be traversed within a single call to dir_lookup.
+ If this is exceeded, dir_lookup will return ELOOP. */
extern int diskfs_maxsymlinks;
-/* The user must define this variable and set it if the filesystem
- should be readonly. */
-extern int diskfs_readonly;
+/* This variable is defined by diskfs; the user should set it if
+ the filesystem media cannot be made writeable. */
+extern int diskfs_hard_readonly;
/* The user must define this variable. Set this to be the node
of root of the filesystem. */
@@ -203,11 +245,13 @@ extern struct node *diskfs_root_node;
filesystem server. */
extern char *diskfs_server_name;
-/* The user must define these variables. Set these to be the major, minor,
- and edit version numbers. */
-extern int diskfs_major_version;
-extern int diskfs_minor_version;
-extern int diskfs_edit_version;
+/* The user must define this variables. Set this to be the server
+ version number. */
+extern char *diskfs_server_version;
+
+/* The user may define this variable. Set this to be any additional
+ version specification that should be printed for --version. */
+extern char *diskfs_extra_version;
/* The user may define this variable. This should be nonzero iff the
filesystem format supports shortcutting symlink translation.
@@ -239,8 +283,17 @@ int diskfs_shortcut_ifsock;
thread is started up (in diskfs_spawn_first_threa). */
extern int diskfs_default_sync_interval;
+/* The user must define this variable, which should be a string that somehow
+ identifies the particular disk this filesystem is interpreting. It is
+ generally only used to print messages or to distinguish instances of the
+ same filesystem type from one another. If this filesystem accesses no
+ external media, then define this to be 0. */
+extern char *diskfs_disk_name;
+
/* The user must define this function. Set *STATFSBUF with
- appropriate values to reflect the current state of the filesystem. */
+ appropriate values to reflect the current state of the filesystem.
+ The buffer will be initialized to all zeros by the caller;
+ the caller will set f_namelen to diskfs_name_max. */
error_t diskfs_set_statfs (fsys_statfsbuf_t *statfsbuf);
/* The user must define this function. Lookup in directory DP (which
@@ -282,7 +335,8 @@ error_t diskfs_set_statfs (fsys_statfsbuf_t *statfsbuf);
Return EAGAIN if NAME refers to the `..' of this filesystem's root.
Return EIO if appropriate.
*/
-error_t diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type,
+error_t diskfs_lookup_hard (struct node *dp,
+ const char *name, enum lookup_type type,
struct node **np, struct dirstat *ds,
struct protid *cred);
@@ -292,7 +346,7 @@ error_t diskfs_lookup_hard (struct node *dp, char *name, enum lookup_type type,
has been locked continuously since that call and DS is as that call
set it, NP is locked. CRED identifies the user responsible
for the call (to be used only to validate directory growth). */
-error_t diskfs_direnter_hard (struct node *dp, char *name,
+error_t diskfs_direnter_hard (struct node *dp, const char *name,
struct node *np, struct dirstat *ds,
struct protid *cred);
@@ -331,7 +385,7 @@ error_t diskfs_drop_dirstat (struct node *dp, struct dirstat *ds);
then there is no limit on *DATACNT; if N is -1, then there is no limit
on AMT. */
error_t diskfs_get_directs (struct node *dp, int entry, int n,
- char **data, u_int *datacnt,
+ char **data, size_t *datacnt,
vm_size_t bufsiz, int *amt);
/* The user must define this function. For locked node NP (for which
@@ -343,7 +397,8 @@ error_t diskfs_get_translator (struct node *np, char **namep, u_int *namelen);
/* The user must define this function. For locked node NP, set
the name of the translating program to be NAME, length NAMELEN. CRED
identifies the user responsible for the call. */
-error_t diskfs_set_translator (struct node *np, char *name, u_int namelen,
+error_t diskfs_set_translator (struct node *np,
+ const char *name, u_int namelen,
struct protid *cred);
/* The user must define this function. Truncate locked node NP to be SIZE
@@ -351,20 +406,20 @@ error_t diskfs_set_translator (struct node *np, char *name, u_int namelen,
long, do nothing.) If this is a symlink (and diskfs_shortcut_symlink
is set) then this should clear the symlink, even if
diskfs_create_symlink_hook stores the link target elsewhere. */
-error_t diskfs_truncate (struct node *np, off_t size);
+error_t diskfs_truncate (struct node *np, loff_t size);
/* The user must define this function. Grow the disk allocated to locked node
NP to be at least SIZE bytes, and set NP->allocsize to the actual
allocated size. (If the allocated size is already SIZE bytes, do
nothing.) CRED identifies the user responsible for the call. */
-error_t diskfs_grow (struct node *np, off_t size, struct protid *cred);
+error_t diskfs_grow (struct node *np, loff_t size, struct protid *cred);
/* The user must define this function. Write to disk (synchronously
iff WAIT is nonzero) from format-specific buffers any non-paged
metadata. If CLEAN is nonzero, then after this is written the
filesystem will be absolutely clean, and the non-paged metadata can
so indicate. */
-void diskfs_set_hypermetadata (int wait, int clean);
+error_t diskfs_set_hypermetadata (int wait, int clean);
/* The user must define this function. Allocate a new node to be of
mode MODE in locked directory DP (don't actually set the mode or
@@ -462,7 +517,7 @@ void diskfs_shutdown_pager ();
/* The user must define this function. Return a memory object port (send
right) for the file contents of NP. PROT is the maximum allowable
- access. */
+ access. On errors, return MACH_PORT_NULL and set errno. */
mach_port_t diskfs_get_filemap (struct node *np, vm_prot_t prot);
/* The user must define this function. Return true if there are pager
@@ -502,7 +557,7 @@ error_t diskfs_node_reload (struct node *node);
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
used. If it returns any other error, it is returned to the user. */
-error_t (*diskfs_create_symlink_hook)(struct node *np, char *target);
+error_t (*diskfs_create_symlink_hook)(struct node *np, const char *target);
/* If this function is nonzero (and diskfs_shortcut_symlink is set) it
is called to read the contents of a symlink. If it returns EINVAL or
@@ -512,33 +567,6 @@ error_t (*diskfs_read_symlink_hook)(struct node *np, char *target);
/* The library exports the following functions for general use */
-/* Returns the name and a send right for the mach device on which the file
- NAME is stored, and returns it in DEV_NAME (which is malloced) and PORT.
- Other values returned are START, the first valid offset, SIZE, the the
- number of blocks after START, and BLOCK_SIZE, the units in which the
- device is addressed.
-
- The device is opened for reading, and if the diskfs global variable
- DISKFS_READONLY is false, writing. */
-error_t diskfs_get_file_device (char *name,
- char **dev_name, mach_port_t *port,
- off_t *start, off_t *size, size_t *block_size);
-
-/* Returns a send right to for the mach device called NAME, and returns it in
- PORT. Other values returned are START, the first valid offset, SIZE, the
- the number of blocks after START, and BLOCK_SIZE, the units in which the
- device is addressed.
-
- The device is opened for reading, and if the diskfs global variable
- DISKFS_READ_ONLY is false, writing.
-
- If NAME cannot be opened and this is a bootstrap filesystem, the user will
- be prompted for new names until a valid one is found. */
-error_t diskfs_get_mach_device (char *name,
- mach_port_t *port,
- off_t *start, off_t *size, size_t *block_size);
-
-
/* Call this after arguments have been parsed to initialize the library.
You must call this before calling any other diskfs functions, and after
parsing diskfs options. */
@@ -553,8 +581,9 @@ mach_port_t diskfs_startup_diskfs (mach_port_t bootstrap, int flags);
/* Call this after all format-specific initialization is done (except
for setting diskfs_root_node); at this point the pagers should be
- ready to go. */
-void diskfs_spawn_first_thread (void);
+ ready to go. DEMUXER is the demuxer to user. Normally, this is
+ just diskfs_demuxer. */
+void diskfs_spawn_first_thread (ports_demuxer_type demuxer);
/* Once diskfs_root_node is set, call this if we are a bootstrap
filesystem. If you call this, then the library will call
@@ -574,240 +603,30 @@ void diskfs_node_update (struct node *np, int wait);
/* Add a hard reference to a node. If there were no hard
references previously, then the node cannot be locked
(because you must hold a hard reference to hold the lock). */
-extern inline void
-diskfs_nref (struct node *np)
-{
- int new_hardref;
- spin_lock (&diskfs_node_refcnt_lock);
- np->references++;
- new_hardref = (np->references == 1);
- spin_unlock (&diskfs_node_refcnt_lock);
- if (new_hardref)
- {
- mutex_lock (&np->lock);
- diskfs_new_hardrefs (np);
- mutex_unlock (&np->lock);
- }
-}
+void diskfs_nref (struct node *np);
/* Unlock node NP and release a hard reference; if this is the last
hard reference and there are no links to the file then request
soft references to be dropped. */
-extern inline void
-diskfs_nput (struct node *np)
-{
- int tried_drop_softrefs = 0;
-
- loop:
- spin_lock (&diskfs_node_refcnt_lock);
- assert (np->references);
- np->references--;
- if (np->references + np->light_references == 0)
- diskfs_drop_node (np);
- else if (np->references == 0 && !tried_drop_softrefs)
- {
- spin_unlock (&diskfs_node_refcnt_lock);
- diskfs_lost_hardrefs (np);
- if (!np->dn_stat.st_nlink)
- {
- /* There are no links. If there are soft references that
- can be dropped, we can't let them postpone deallocation.
- So attempt to drop them. But that's a user-supplied
- routine, which might result in further recursive calls to
- the ref-counting system. So we have to reacquire our
- reference around the call to forestall disaster. */
- spin_lock (&diskfs_node_refcnt_lock);
- np->references++;
- spin_unlock (&diskfs_node_refcnt_lock);
-
- diskfs_try_dropping_softrefs (np);
-
- /* But there's no value in looping forever in this
- routine; only try to drop soft refs once. */
- tried_drop_softrefs = 1;
-
- /* Now we can drop the reference back... */
- goto loop;
- }
- mutex_unlock (&np->lock);
- }
- else
- {
- spin_unlock (&diskfs_node_refcnt_lock);
- mutex_unlock (&np->lock);
- }
-}
+void diskfs_nput (struct node *np);
/* Release a hard reference on NP. If NP is locked by anyone, then
this cannot be the last hard reference (because you must hold a
hard reference in order to hold the lock). If this is the last
hard reference and there are no links, then request soft references
to be dropped. */
-extern inline void
-diskfs_nrele (struct node *np)
-{
- int tried_drop_softrefs = 0;
-
- loop:
- spin_lock (&diskfs_node_refcnt_lock);
- assert (np->references);
- np->references--;
- if (np->references + np->light_references == 0)
- {
- mutex_lock (&np->lock);
- diskfs_drop_node (np);
- }
- else if (np->references == 0)
- {
- mutex_lock (&np->lock);
- spin_unlock (&diskfs_node_refcnt_lock);
- diskfs_lost_hardrefs (np);
- if (!np->dn_stat.st_nlink && !tried_drop_softrefs)
- {
- /* Same issue here as in nput; see that for explanation */
- spin_lock (&diskfs_node_refcnt_lock);
- np->references++;
- spin_unlock (&diskfs_node_refcnt_lock);
-
- diskfs_try_dropping_softrefs (np);
- tried_drop_softrefs = 1;
-
- /* Now we can drop the reference back... */
- mutex_unlock (&np->lock);
- goto loop;
- }
- mutex_unlock (&np->lock);
- }
- else
- spin_unlock (&diskfs_node_refcnt_lock);
-}
+void diskfs_nrele (struct node *np);
/* Add a light reference to a node. */
-extern inline void
-diskfs_nref_light (struct node *np)
-{
- spin_lock (&diskfs_node_refcnt_lock);
- np->light_references++;
- spin_unlock (&diskfs_node_refcnt_lock);
-}
+void diskfs_nref_light (struct node *np);
/* Unlock node NP and release a light reference */
-extern inline void
-diskfs_nput_light (struct node *np)
-{
- spin_lock (&diskfs_node_refcnt_lock);
- assert (np->light_references);
- np->light_references--;
- if (np->references + np->light_references == 0)
- diskfs_drop_node (np);
- else
- {
- spin_unlock (&diskfs_node_refcnt_lock);
- mutex_unlock (&np->lock);
- }
-}
+void diskfs_nput_light (struct node *np);
/* Release a light reference on NP. If NP is locked by anyone, then
this cannot be the last reference (because you must hold a
hard reference in order to hold the lock). */
-extern inline void
-diskfs_nrele_light (struct node *np)
-{
- spin_lock (&diskfs_node_refcnt_lock);
- assert (np->light_references);
- np->light_references--;
- if (np->references + np->light_references == 0)
- {
- mutex_lock (&np->lock);
- diskfs_drop_node (np);
- }
- else
- spin_unlock (&diskfs_node_refcnt_lock);
-}
-
-/* Return nonzero iff the user identified by CRED has uid UID. */
-extern inline int
-diskfs_isuid (uid_t uid, struct protid *cred)
-{
- int i;
- for (i = 0; i < cred->nuids; i++)
- if (cred->uids[i] == uid)
- return 1;
- return 0;
-}
-
-/* Return nonzero iff the user identified by CRED has group GRP. */
-extern inline int
-diskfs_groupmember (uid_t grp, struct protid *cred)
-{
- int i;
- for (i = 0; i < cred->ngids; i++)
- if (cred->gids[i] == grp)
- return 1;
- return 0;
-}
-
-/* Check to see if the user identified by CRED is permitted to do
- owner-only operations on node NP; if so, return 0; if not, return
- EPERM. */
-extern inline error_t
-diskfs_isowner (struct node *np, struct protid *cred)
-{
- /* Permitted if the user is the owner, superuser, or if the user
- is in the group of the file and has the group ID as their user
- ID. (This last is colloquially known as `group leader'.) */
- if (diskfs_isuid (np->dn_stat.st_uid, cred) || diskfs_isuid (0, cred)
- || (diskfs_groupmember (np->dn_stat.st_gid, cred)
- && diskfs_isuid (np->dn_stat.st_gid, cred)))
- return 0;
- else
- return EPERM;
-}
-
-/* Check to see is the user identified by CRED is permitted to do
- operation OP on node NP. Op is one of S_IREAD, S_IWRITE, or S_IEXEC.
- Return 0 if the operation is permitted and EACCES if not. */
-extern inline error_t
-diskfs_access (struct node *np, int op, struct protid *cred)
-{
- int gotit;
- if (diskfs_isuid (0, cred))
- gotit = 1;
- else if (cred->nuids == 0 && (np->dn_stat.st_mode & S_IUSEUNK))
- gotit = np->dn_stat.st_mode & (op << S_IUNKSHIFT);
- else if (!diskfs_isowner (np, cred))
- gotit = np->dn_stat.st_mode & op;
- else if (diskfs_groupmember (np->dn_stat.st_gid, cred))
- gotit = np->dn_stat.st_mode & (op >> 3);
- else
- gotit = np->dn_stat.st_mode & (op >> 6);
- return gotit ? 0 : EACCES;
-}
-
-/* Check to see if the user identified by CRED is allowed to modify
- directory DP with respect to existing file NP. This is the same
- as diskfs_access (dp, S_IWRITE, cred), except when the directory
- has the sticky bit set. (If there is no existing file NP, then
- 0 can be passed.) */
-extern inline error_t
-diskfs_checkdirmod (struct node *dp, struct node *np,
- struct protid *cred)
-{
- error_t err;
-
- /* The user must be able to write the directory, but if the directory
- is sticky, then the user must also be either the owner of the directory
- or the file. */
- err = diskfs_access (dp, S_IWRITE, cred);
- if (err)
- return err;
-
- if ((dp->dn_stat.st_mode & S_ISVTX) && np && !diskfs_isuid (0, cred)
- && diskfs_isowner (dp, cred) && diskfs_isowner (np, cred))
- return EACCES;
-
- return 0;
-}
+void diskfs_nrele_light (struct node *np);
/* Reading and writing of files. this is called by other filesystem
routines and handles extension of files automatically. NP is the
@@ -819,7 +638,7 @@ diskfs_checkdirmod (struct node *dp, struct node *np,
extension). For reads, *AMTREAD is filled with the amount actually
read. */
error_t
-diskfs_node_rdwr (struct node *np, char *data, off_t off,
+diskfs_node_rdwr (struct node *np, char *data, loff_t off,
size_t amt, int dir, struct protid *cred,
size_t *amtread);
@@ -832,7 +651,15 @@ diskfs_node_rdwr (struct node *np, char *data, off_t off,
fully completed. */
void
diskfs_notice_dirchange (struct node *dp, enum dir_changed_type type,
- char *name);
+ const char *name);
+
+/* Send notifications to users who have requested them with
+ file_notice_changes for file NP. The type of modification is TYPE.
+ START and END identify the affected region of the file's data.
+ This should be called after the change is fully completed. */
+void
+diskfs_notice_filechange (struct node *np, enum file_changed_type type,
+ loff_t start, loff_t end);
/* Create a new node structure with DS as its physical disknode.
The new node will have one hard reference and no light references. */
@@ -846,6 +673,11 @@ struct node *diskfs_make_node (struct disknode *dn);
either be LOOKUP, CREATE, RENAME, or REMOVE. CRED identifies the
user making the call.
+ NAME will have leading and trailing slashes stripped. It is an
+ error if there are internal slashes. NAME will be modified in
+ place if there are slashes in it; it is therefore an error to
+ specify a constant NAME which contains slashes.
+
If the name is found, return zero, and (if NP is nonzero) set *NP
to point to the node for it, locked. If the name is not found,
return ENOENT, and (if NP is nonzero) set *NP to zero. If NP is
@@ -884,10 +716,11 @@ struct node *diskfs_make_node (struct disknode *dn);
Return ENOENT if NAME isn't in the directory.
Return EAGAIN if NAME refers to the `..' of this filesystem's root.
Return EIO if appropriate.
-
- This function is a wrapper for diskfs_lookup_hard.
+
+ This function is a wrapper for diskfs_lookup_hard.
*/
-error_t diskfs_lookup (struct node *dp, char *name, enum lookup_type type,
+error_t diskfs_lookup (struct node *dp,
+ const char *name, enum lookup_type type,
struct node **np, struct dirstat *ds,
struct protid *cred);
@@ -898,7 +731,7 @@ error_t diskfs_lookup (struct node *dp, char *name, enum lookup_type type,
responsible for the call (to be used only to validate directory
growth). This function is a wrapper for diskfs_direnter_hard. */
error_t
-diskfs_direnter (struct node *dp, char *name, struct node *np,
+diskfs_direnter (struct node *dp, const char *name, struct node *np,
struct dirstat *ds, struct protid *cred);
/* This will only be called after a successful call to diskfs_lookup
@@ -910,7 +743,8 @@ diskfs_direnter (struct node *dp, char *name, struct node *np,
name of OLDNP inside DP; it is this reference which is being
rewritten. This function is a wrapper for diskfs_dirrewrite_hard. */
error_t diskfs_dirrewrite (struct node *dp, struct node *oldnp,
- struct node *np, char *name, struct dirstat *ds);
+ struct node *np, const char *name,
+ struct dirstat *ds);
/* This will only be called after a successful call to diskfs_lookup
of type REMOVE; this call should remove the name found from the
@@ -920,10 +754,10 @@ error_t diskfs_dirrewrite (struct node *dp, struct node *oldnp,
function is a wrapper for diskfs_dirremove_hard. The entry being
removed has name NAME and refers to NP. */
error_t diskfs_dirremove (struct node *dp, struct node *np,
- char *name, struct dirstat *ds);
+ const char *name, struct dirstat *ds);
/* Return the node corresponding to CACHE_ID in *NPP. */
-error_t diskfs_cached_lookup (int cache_id, struct node **npp);
+error_t diskfs_cached_lookup (ino64_t cache_id, struct node **npp);
/* Create a new node. Give it MODE; if that includes IFDIR, also
initialize `.' and `..' in the new directory. Return the node in NPP.
@@ -933,29 +767,49 @@ error_t diskfs_cached_lookup (int cache_id, struct node **npp);
DIR must always be provided as at least a hint for disk allocation
strategies. */
error_t
-diskfs_create_node (struct node *dir, char *name, mode_t mode,
+diskfs_create_node (struct node *dir, const char *name, mode_t mode,
struct node **newnode, struct protid *cred,
struct dirstat *ds);
-/* Create and return a protid for an existing peropen PO in CRED. The uid
- set is UID (length NUIDS); the gid set is GID (length NGIDS). The node
- PO->np must be locked. */
-error_t diskfs_create_protid (struct peropen *po, uid_t *uids, int nuids,
- uid_t *gids, int ngids, struct protid **cred);
+/* Create and return a protid for an existing peropen PO in CRED,
+ referring to user USER. The node PO->np must be locked. */
+error_t diskfs_create_protid (struct peropen *po, struct iouser *user,
+ struct protid **cred);
/* Build and return in CRED a protid which has no user identification, for
peropen PO. The node PO->np must be locked. */
error_t diskfs_start_protid (struct peropen *po, struct protid **cred);
/* Finish building protid CRED started with diskfs_start_protid;
- the uid set is UID (length NUIDS); the gid set is GID (length NGIDS). */
-void diskfs_finish_protid (struct protid *cred, uid_t *uids, int nuids,
- gid_t *gids, int nguds);
+ the user to install is USER. */
+void diskfs_finish_protid (struct protid *cred, struct iouser *user);
-/* Create and return a new peropen structure on node NP with open
- flags FLAGS. */
-struct peropen *diskfs_make_peropen (struct node *np, int flags,
- mach_port_t dotdotnode);
+extern struct protid * diskfs_begin_using_protid_port (file_t port);
+
+extern void diskfs_end_using_protid_port (struct protid *cred);
+
+#if defined(__USE_EXTERN_INLINES) || defined(DISKFS_DEFINE_EXTERN_INLINE)
+
+/* Called by MiG to translate ports into struct protid *.
+ fsmutations.h arranges for this to happen for the io and
+ fs interfaces. */
+DISKFS_EXTERN_INLINE struct protid *
+diskfs_begin_using_protid_port (file_t port)
+{
+ return ports_lookup_port (diskfs_port_bucket, port, diskfs_protid_class);
+}
+
+/* Called by MiG after server routines have been run; this
+ balances begin_using_protid_port, and is arranged for the io
+ and fs interfaces by fsmutations.h. */
+DISKFS_EXTERN_INLINE void
+diskfs_end_using_protid_port (struct protid *cred)
+{
+ if (cred)
+ ports_port_deref (cred);
+}
+
+#endif /* Use extern inlines. */
/* Called when a protid CRED has no more references. (Because references\
to protids are maintained by the port management library, this is
@@ -963,14 +817,23 @@ struct peropen *diskfs_make_peropen (struct node *np, int flags,
free the structure for us. */
void diskfs_protid_rele (void *arg);
+/* Create a new peropen structure on node NP with open flags FLAGS in
+ *PPO. The initial values for the root_parent, shadow_root, and
+ shadow_root_parent fields are copied from CONTEXT if it's non-zero,
+ otherwise they are zeroed. */
+error_t
+diskfs_make_peropen (struct node *np, int flags,
+ struct peropen *context, struct peropen **ppo);
+
/* Decrement the reference count on a peropen structure. */
void diskfs_release_peropen (struct peropen *po);
/* Node NP has just been found in DIR with NAME. If NP is null, that
means that this name has been confirmed as absent in the directory. */
-void diskfs_enter_lookup_cache (struct node *dir, struct node *np, char *name);
+void diskfs_enter_lookup_cache (struct node *dir, struct node *np,
+ const char *name);
-/* Purge all references in the cache to NP as a node inside
+/* Purge all references in the cache to NP as a node inside
directory DP. */
void diskfs_purge_lookup_cache (struct node *dp, struct node *np);
@@ -978,7 +841,7 @@ void diskfs_purge_lookup_cache (struct node *dp, struct node *np);
anything entry at all, then return 0. If the entry is confirmed to
not exist, then return -1. Otherwise, return NP for the entry, with
a newly allocated reference. */
-struct node *diskfs_check_lookup_cache (struct node *dir, char *name);
+struct node *diskfs_check_lookup_cache (struct node *dir, const char *name);
/* Rename directory node FNP (whose parent is FDP, and which has name
FROMNAME in that directory) to have name TONAME inside directory
@@ -991,9 +854,9 @@ struct node *diskfs_check_lookup_cache (struct node *dir, char *name);
if that is not true for your format, you have to redefine this
function.*/
error_t
-diskfs_rename_dir (struct node *fdp, struct node *fnp, char *fromname,
- struct node *tdp, char *toname, struct protid *fromcred,
- struct protid *tocred);
+diskfs_rename_dir (struct node *fdp, struct node *fnp, const char *fromname,
+ struct node *tdp, const char *toname,
+ struct protid *fromcred, struct protid *tocred);
/* Clear the `.' and `..' entries from directory DP. Its parent is
PDP, and the user responsible for this is identified by CRED. Both
@@ -1014,11 +877,15 @@ error_t diskfs_clear_directory (struct node *dp, struct node *pdp,
error_t
diskfs_init_dir (struct node *dp, struct node *pdp, struct protid *cred);
-/* If NP->dn_set_ctime is set, then modify NP->dn_stat.st_ctime
+/* If disk is not readonly and the noatime option is not enabled, set
+ NP->dn_set_atime. */
+void diskfs_set_node_atime (struct node *np);
+
+/* If NP->dn_set_ctime is set, then modify NP->dn_stat.st_ctim
appropriately; do the analogous operation for atime and mtime as well. */
void diskfs_set_node_times (struct node *np);
-/* Shutdown the filesystem; flags are as for fsys_shutdown. */
+/* Shutdown the filesystem; flags are as for fsys_goaway. */
error_t diskfs_shutdown (int flags);
/* Change an active filesystem between read-only and writable modes, setting
@@ -1049,14 +916,12 @@ error_t diskfs_set_sync_interval (int interval);
/* Parse and execute the runtime options in ARGZ & ARGZ_LEN. EINVAL is
returned if some option is unrecognized. The default definition of this
routine will parse them using DISKFS_RUNTIME_ARGP, which see. */
-error_t diskfs_set_options (char *argz, size_t argz_len);
+error_t diskfs_set_options (const char *argz, size_t argz_len);
-/* Return an argz string describing the current options. Fill *ARGZ
- with a pointer to newly malloced storage holding the list and *LEN
- to the length of that storage. The default definition of this routine
- simply initializes *ARGZ and *ARGZ_LEN to 0 and calls
- diskfs_append_std_options. */
-error_t diskfs_get_options (char **argz, unsigned *argz_len);
+/* Append to the malloced string *ARGZ of length *ARGZ_LEN a NUL-separated
+ list of the arguments to this translator. The default definition of this
+ routine simply calls diskfs_append_std_options. */
+error_t diskfs_append_args (char **argz, size_t *argz_len);
/* If this is defined or set to an argp structure, it will be used by the
default diskfs_set_options to handle runtime option parsing. The default
@@ -1071,12 +936,19 @@ extern const struct argp diskfs_std_runtime_argp;
/* An argp structure for the standard diskfs command line arguments. The
user may call argp_parse on this to parse the command line, chain it onto
the end of his own argp structure, or ignore it completely. */
-extern const struct argp diskfs_std_startup_argp;
+extern const struct argp diskfs_startup_argp;
+
+/* An argp structure for the standard diskfs command line arguments plus a
+ store specification. The address of a location in which to return the
+ resulting struct store_parsed structure should be passed as the input
+ argument to argp_parse; see the declaration for STORE_ARGP in
+ <hurd/store.h> for more information. */
+extern const struct argp diskfs_store_startup_argp;
/* *Appends* to ARGZ & ARGZ_LEN '\0'-separated options describing the standard
diskfs option state (note that unlike diskfs_get_options, ARGZ & ARGZ_LEN
must already have a sane value). */
-error_t diskfs_append_std_options (char **argz, unsigned *argz_len);
+error_t diskfs_append_std_options (char **argz, size_t *argz_len);
/* Demultiplex incoming messages on ports created by libdiskfs. */
int diskfs_demuxer (mach_msg_header_t *, mach_msg_header_t *);
@@ -1089,67 +961,33 @@ int diskfs_check_readonly (void);
fsys, interrupt, and notify interfaces. All the server routines
have the prefix `diskfs_S_'; `in' arguments of type file_t or io_t
appear as `struct protid *' to the stub. */
+
+
+/* All-in-one initialization function for diskfs filesystems using
+ libstore. This parses arguments using STARTUP_ARGP (defaulting to
+ diskfs_store_startup_argp if it's null; note that the ARGP_IN_ORDER
+ flag is always used); it calls diskfs_init_diskfs; it opens the
+ store with store_parsed_open, and sets diskfs_hard_readonly and
+ diskfs_readonly if the store is unwritable; it calls
+ diskfs_spawn_first_thread; finally, it returns the store and its
+ description in *STORE and *STORE_PARSED, and the bootstrap port in
+ *BOOTSTRAP. The caller should pass *BOOTSTRAP to
+ diskfs_startup_diskfs after setting diskfs_root_node.
+ (See <argp.h> and <hurd/store.h>.)
+
+ This call cannot return failure; if it encounters a fatal problem,
+ it prints a diagnostic on stderr (or the console) and exits the
+ program. */
+struct store *diskfs_init_main (struct argp *startup_argp,
+ int argc, char **argv,
+ struct store_parsed **store_parsed,
+ mach_port_t *bootstrap);
/* The following are optional convenience routines and global variable, which
can be used by any user program that uses a mach device to hold the
underlying filesystem. */
-/* A pointer to an argp structure for the standard diskfs command line
- arguments, that also parses a device argument. The user may call
- argp_parse on this to parse the command line, chain it onto the end of his
- own argp structure, or ignore it completely. */
-extern const struct argp diskfs_std_device_startup_argp;
-
-/* The following two are set by the preceding argument parser: */
-/* The device specifier given on the command line. */
-extern char *diskfs_device_arg;
-/* True if --machdev was specified, meaning that DISKFS_DEVICE_ARG names a
- mach device and not a filesystem device node. */
-extern int diskfs_use_mach_device;
-
-/* Uses the values of DISKFS_DEVICE_ARG and DISKFS_USE_MACH_DEVICE, and
- attempts to open the device and set the values of DISKFS_DEVICE,
- DISKFS_DEVICE_NAME, DISKFS_DEVICE_START, DISKFS_DEVICE_SIZE, and
- DISKFS_DEVICE_BLOCK_SIZE. */
-extern error_t diskfs_device_open ();
-
-/* A mach device port for the device we're using. */
-extern mach_port_t diskfs_device;
-
-/* The mach device name of DISKFS_DEVICE. May be 0 if unknown. */
-extern char *diskfs_device_name;
-
-/* The first valid block of DISKFS_DEVICE, in units of
- DISKFS_DEVICE_BLOCK_SIZE. */
-extern off_t diskfs_device_start;
-
-/* The usable size of DISKFS_DEVICE, in units of DISKFS_DEVICE_BLOCK_SIZE. */
-extern off_t diskfs_device_size;
-
-/* The unit of addressing for DISKFS_DEVICE. */
-extern unsigned diskfs_device_block_size;
-
-/* Some handy calculations based on DISKFS_DEVICE_BLOCK_SIZE. */
-/* Log base 2 of DEVICE_BLOCK_SIZE, or 0 if it's not a power of two. */
-extern unsigned diskfs_log2_device_block_size;
-/* Log base 2 of the number of device blocks in a vm page. This number is
- only valid if DISKFS_LOG2_DEVICE_BLOCK_SIZE is not 0. */
-extern unsigned diskfs_log2_device_blocks_per_page;
-
-/* Write disk block ADDR with DATA of LEN bytes to DISKFS_DEVICE, waiting for
- completion. ADDR is offset by DISKFS_DEVICE_START. If an error occurs,
- EIO is returned. */
-error_t diskfs_device_write_sync (off_t addr, vm_address_t data, size_t len);
-
-/* Read disk block ADDR from DISKFS_DEVICE; put the address of the data in
- DATA; read LEN bytes. Always *DATA should be a full page no matter what.
- ADDR is offset by DISKFS_DEVICE_START. If an error occurs, EIO is
- returned. */
-error_t diskfs_device_read_sync (off_t addr, vm_address_t *data, size_t len);
-
/* Make errors go somewhere reasonable. */
void diskfs_console_stdio ();
-
#endif /* hurd/diskfs.h */
-