Here is a patch for adding a stub write function to libstand,
so that you could, for example, reimplement in FORTH the
nextboot utility, which was murdered when the new boot loader
was added.

This only implements a stub function, but it has comments
that indicate the needed semantics in the presence of doing
a write to a technically unmounted raw disk, so that it
doesn't screw up your FS image.

This is necewssary precursor work for actually supporting
the fwrite FORTH verb in the previous patch (it'll fail to
do the write in both cases, so neither are harmful).

Please commit... K PLZ THX.

-- Terry
Index: libstand/ufs.c
===================================================================
RCS file: /home/cvs/FreeBSD/src/lib/libstand/ufs.c,v
retrieving revision 1.5.6.1
diff -u -r1.5.6.1 ufs.c
--- libstand/ufs.c      2000/05/04 13:47:53     1.5.6.1
+++ libstand/ufs.c      2001/08/29 00:36:19
@@ -82,6 +82,7 @@
 static int     ufs_open(const char *path, struct open_file *f);
 static int     ufs_close(struct open_file *f);
 static int     ufs_read(struct open_file *f, void *buf, size_t size, size_t *resid);
+static int     ufs_write(struct open_file *f, void *buf, size_t size, size_t *resid);
 static off_t   ufs_seek(struct open_file *f, off_t offset, int where);
 static int     ufs_stat(struct open_file *f, struct stat *sb);
 static int     ufs_readdir(struct open_file *f, struct dirent *d);
@@ -91,7 +92,7 @@
        ufs_open,
        ufs_close,
        ufs_read,
-       null_write,
+       ufs_write,
        ufs_seek,
        ufs_stat,
        ufs_readdir
@@ -613,6 +614,21 @@
        free(fp->f_fs);
        free(fp);
        return (0);
+}
+
+/*
+ * Copy kernel memory into a portion of a file.
+ * Cross block boundaries when necessary, but do not exceed
+ * the orginal length of the file, nor truncate it.
+ */
+static int
+ufs_write(f, start, size, resid)
+       struct open_file *f;
+       void *start;
+       size_t size;
+       size_t *resid;  /* out */
+{
+       return (ENOENT);        /* NOTIMP! */
 }

 /*

Reply via email to