summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2018-03-10 21:39:12 -0800
committerJoshua M. Clulow <josh@sysmgr.org>2018-03-10 21:39:12 -0800
commitcf837ed8ca7273a1e7b940fb7b52eb12ae1d5ea6 (patch)
tree819abed5f7292a797db54cd5eeb7a2f10f2daa00
parentd0b12b660e0741581d18f1f3a7d5268e0a5f1806 (diff)
downloadillumos-joyent-cf837ed8ca7273a1e7b940fb7b52eb12ae1d5ea6.tar.gz
9198 libstand: Const-ify buffer argument of write(2) analog
Reviewed by: C Fraire <cfraire@me.com> Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Andy Fiddaman <omnios@citrus-it.co.uk> Approved by: Joshua M. Clulow <josh@sysmgr.org>
-rw-r--r--usr/src/boot/Makefile.version2
-rw-r--r--usr/src/boot/lib/libstand/cd9660.c11
-rw-r--r--usr/src/boot/lib/libstand/nfs.c12
-rw-r--r--usr/src/boot/lib/libstand/nullfs.c28
-rw-r--r--usr/src/boot/lib/libstand/stand.h8
-rw-r--r--usr/src/boot/lib/libstand/tftp.c10
-rw-r--r--usr/src/boot/lib/libstand/ufs.c13
-rw-r--r--usr/src/boot/lib/libstand/write.c9
-rw-r--r--usr/src/boot/sys/boot/userboot/userboot/host.c15
-rw-r--r--usr/src/boot/sys/boot/zfs/zfs.c13
10 files changed, 38 insertions, 83 deletions
diff --git a/usr/src/boot/Makefile.version b/usr/src/boot/Makefile.version
index af557cc15f..6b7ed90fc4 100644
--- a/usr/src/boot/Makefile.version
+++ b/usr/src/boot/Makefile.version
@@ -33,4 +33,4 @@ LOADER_VERSION = 1.1
# Use date like formatting here, YYYY.MM.DD.XX, without leading zeroes.
# The version is processed from left to right, the version number can only
# be increased.
-BOOT_VERSION = $(LOADER_VERSION)-2018.2.22.1
+BOOT_VERSION = $(LOADER_VERSION)-2018.2.24.1
diff --git a/usr/src/boot/lib/libstand/cd9660.c b/usr/src/boot/lib/libstand/cd9660.c
index 8b8aa36d6c..845df147cd 100644
--- a/usr/src/boot/lib/libstand/cd9660.c
+++ b/usr/src/boot/lib/libstand/cd9660.c
@@ -32,7 +32,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
/*
* Stand-alone ISO9660 file reading package.
@@ -66,8 +65,6 @@ static int cd9660_open(const char *path, struct open_file *f);
static int cd9660_close(struct open_file *f);
static int cd9660_read(struct open_file *f, void *buf, size_t size,
size_t *resid);
-static int cd9660_write(struct open_file *f, void *buf, size_t size,
- size_t *resid);
static off_t cd9660_seek(struct open_file *f, off_t offset, int where);
static int cd9660_stat(struct open_file *f, struct stat *sb);
static int cd9660_readdir(struct open_file *f, struct dirent *d);
@@ -86,7 +83,7 @@ struct fs_ops cd9660_fsops = {
cd9660_open,
cd9660_close,
cd9660_read,
- cd9660_write,
+ null_write,
cd9660_seek,
cd9660_stat,
cd9660_readdir
@@ -556,12 +553,6 @@ again:
return (0);
}
-static int
-cd9660_write(struct open_file *f __unused, void *start __unused, size_t size __unused, size_t *resid __unused)
-{
- return EROFS;
-}
-
static off_t
cd9660_seek(struct open_file *f, off_t offset, int where)
{
diff --git a/usr/src/boot/lib/libstand/nfs.c b/usr/src/boot/lib/libstand/nfs.c
index 27f7f182f4..1cf8f5af0b 100644
--- a/usr/src/boot/lib/libstand/nfs.c
+++ b/usr/src/boot/lib/libstand/nfs.c
@@ -125,7 +125,6 @@ struct nfs_iodesc {
int nfs_open(const char *path, struct open_file *f);
static int nfs_close(struct open_file *f);
static int nfs_read(struct open_file *f, void *buf, size_t size, size_t *resid);
-static int nfs_write(struct open_file *f, void *buf, size_t size, size_t *resid);
static off_t nfs_seek(struct open_file *f, off_t offset, int where);
static int nfs_stat(struct open_file *f, struct stat *sb);
static int nfs_readdir(struct open_file *f, struct dirent *d);
@@ -137,7 +136,7 @@ struct fs_ops nfs_fsops = {
nfs_open,
nfs_close,
nfs_read,
- nfs_write,
+ null_write,
nfs_seek,
nfs_stat,
nfs_readdir
@@ -704,15 +703,6 @@ ret:
return (0);
}
-/*
- * Not implemented.
- */
-int
-nfs_write(struct open_file *f, void *buf, size_t size, size_t *resid)
-{
- return (EROFS);
-}
-
off_t
nfs_seek(struct open_file *f, off_t offset, int where)
{
diff --git a/usr/src/boot/lib/libstand/nullfs.c b/usr/src/boot/lib/libstand/nullfs.c
index e4c0b7cbc4..78b0940ba8 100644
--- a/usr/src/boot/lib/libstand/nullfs.c
+++ b/usr/src/boot/lib/libstand/nullfs.c
@@ -1,6 +1,6 @@
/* $NetBSD: nullfs.c,v 1.1 1996/01/13 22:25:39 leo Exp $ */
-/*-
+/*
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
*
@@ -15,7 +15,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -61,45 +61,51 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
#include "stand.h"
/*
* Null filesystem
*/
-int null_open (const char *path, struct open_file *f)
+int
+null_open(const char *path, struct open_file *f)
{
return EINVAL;
}
-int null_close(struct open_file *f)
+int
+null_close(struct open_file *f)
{
return 0;
}
-int null_read (struct open_file *f, void *buf, size_t size, size_t *resid)
+int
+null_read(struct open_file *f, void *buf, size_t size, size_t *resid)
{
return EIO;
}
-int null_write (struct open_file *f, void *buf, size_t size, size_t *resid)
+int
+null_write(struct open_file *f, const void *buf, size_t size, size_t *resid)
{
- return EIO;
+ return EROFS;
}
-off_t null_seek (struct open_file *f, off_t offset, int where)
+off_t
+null_seek(struct open_file *f, off_t offset, int where)
{
errno = EIO;
return -1;
}
-int null_stat (struct open_file *f, struct stat *sb)
+int
+null_stat(struct open_file *f, struct stat *sb)
{
return EIO;
}
-int null_readdir(struct open_file *f, struct dirent *d)
+int
+null_readdir(struct open_file *f, struct dirent *d)
{
return EIO;
}
diff --git a/usr/src/boot/lib/libstand/stand.h b/usr/src/boot/lib/libstand/stand.h
index 40d4d34bcb..c445d684a1 100644
--- a/usr/src/boot/lib/libstand/stand.h
+++ b/usr/src/boot/lib/libstand/stand.h
@@ -27,7 +27,7 @@
* From $NetBSD: stand.h,v 1.22 1997/06/26 19:17:40 drochner Exp $
*/
-/*-
+/*
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
*
@@ -104,7 +104,7 @@ struct fs_ops {
int (*fo_close)(struct open_file *f);
int (*fo_read)(struct open_file *f, void *buf,
size_t size, size_t *resid);
- int (*fo_write)(struct open_file *f, void *buf,
+ int (*fo_write)(struct open_file *f, const void *buf,
size_t size, size_t *resid);
off_t (*fo_seek)(struct open_file *f, off_t offset, int where);
int (*fo_stat)(struct open_file *f, struct stat *sb);
@@ -282,7 +282,7 @@ extern int open(const char *, int);
extern int close(int);
extern void closeall(void);
extern ssize_t read(int, void *, size_t);
-extern ssize_t write(int, void *, size_t);
+extern ssize_t write(int, const void *, size_t);
extern struct dirent *readdirfd(int);
extern void srandom(u_long seed);
@@ -369,7 +369,7 @@ extern void nullsys(void);
extern int null_open(const char *path, struct open_file *f);
extern int null_close(struct open_file *f);
extern int null_read(struct open_file *f, void *buf, size_t size, size_t *resid);
-extern int null_write(struct open_file *f, void *buf, size_t size, size_t *resid);
+extern int null_write(struct open_file *f, const void *buf, size_t size, size_t *resid);
extern off_t null_seek(struct open_file *f, off_t offset, int where);
extern int null_stat(struct open_file *f, struct stat *sb);
extern int null_readdir(struct open_file *f, struct dirent *d);
diff --git a/usr/src/boot/lib/libstand/tftp.c b/usr/src/boot/lib/libstand/tftp.c
index 39cd1466fe..c1ce0e3b80 100644
--- a/usr/src/boot/lib/libstand/tftp.c
+++ b/usr/src/boot/lib/libstand/tftp.c
@@ -65,7 +65,6 @@ static int tftp_open(const char *path, struct open_file *f);
static int tftp_close(struct open_file *f);
static int tftp_parse_oack(struct tftp_handle *h, char *buf, size_t len);
static int tftp_read(struct open_file *f, void *buf, size_t size, size_t *resid);
-static int tftp_write(struct open_file *f, void *buf, size_t size, size_t *resid);
static off_t tftp_seek(struct open_file *f, off_t offset, int where);
static int tftp_set_blksize(struct tftp_handle *h, const char *str);
static int tftp_stat(struct open_file *f, struct stat *sb);
@@ -80,7 +79,7 @@ struct fs_ops tftp_fsops = {
tftp_open,
tftp_close,
tftp_read,
- tftp_write,
+ null_write,
tftp_seek,
tftp_stat,
null_readdir
@@ -563,13 +562,6 @@ tftp_close(struct open_file *f)
return (0);
}
-static int
-tftp_write(struct open_file *f __unused, void *start __unused, size_t size __unused,
- size_t *resid __unused /* out */)
-{
- return (EROFS);
-}
-
static int
tftp_stat(struct open_file *f, struct stat *sb)
{
diff --git a/usr/src/boot/lib/libstand/ufs.c b/usr/src/boot/lib/libstand/ufs.c
index 9a16c6b6e6..e31d9d55c9 100644
--- a/usr/src/boot/lib/libstand/ufs.c
+++ b/usr/src/boot/lib/libstand/ufs.c
@@ -1,6 +1,6 @@
/* $NetBSD: ufs.c,v 1.20 1998/03/01 07:15:39 ross Exp $ */
-/*-
+/*
* Copyright (c) 2002 Networks Associates Technology, Inc.
* All rights reserved.
*
@@ -83,7 +83,8 @@
#include "string.h"
static int ufs_open(const char *path, struct open_file *f);
-static int ufs_write(struct open_file *f, void *buf, size_t size, size_t *resid);
+static int ufs_write(struct open_file *f, const void *buf, size_t size,
+ size_t *resid);
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 off_t ufs_seek(struct open_file *f, off_t offset, int where);
@@ -130,7 +131,7 @@ struct file {
static int read_inode(ino_t, struct open_file *);
static int block_map(struct open_file *, ufs2_daddr_t, ufs2_daddr_t *);
static int buf_read_file(struct open_file *, char **, size_t *);
-static int buf_write_file(struct open_file *, char *, size_t *);
+static int buf_write_file(struct open_file *, const char *, size_t *);
static int search_directory(char *, struct open_file *, ino_t *);
/*
@@ -300,7 +301,7 @@ block_map(f, file_block, disk_block_p)
static int
buf_write_file(f, buf_p, size_p)
struct open_file *f;
- char *buf_p;
+ const char *buf_p;
size_t *size_p; /* out */
{
struct file *fp = (struct file *)f->f_fsdata;
@@ -758,14 +759,14 @@ ufs_read(f, start, size, resid)
static int
ufs_write(f, start, size, resid)
struct open_file *f;
- void *start;
+ const void *start;
size_t size;
size_t *resid; /* out */
{
struct file *fp = (struct file *)f->f_fsdata;
size_t csize;
int rc = 0;
- char *addr = start;
+ const char *addr = start;
csize = size;
while ((size != 0) && (csize != 0)) {
diff --git a/usr/src/boot/lib/libstand/write.c b/usr/src/boot/lib/libstand/write.c
index 9e02f083f2..96fc5c3457 100644
--- a/usr/src/boot/lib/libstand/write.c
+++ b/usr/src/boot/lib/libstand/write.c
@@ -61,16 +61,12 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include "stand.h"
ssize_t
-write(fd, dest, bcount)
- int fd;
- void *dest;
- size_t bcount;
+write(int fd, const void *dest, size_t bcount)
{
struct open_file *f = &files[fd];
size_t resid;
@@ -82,7 +78,8 @@ write(fd, dest, bcount)
if (f->f_flags & F_RAW) {
twiddle(4);
errno = (f->f_dev->dv_strategy)(f->f_devdata, F_WRITE,
- btodb(f->f_offset), bcount, dest, &resid);
+ btodb(f->f_offset), bcount, __DECONST(void *, dest),
+ &resid);
if (errno)
return (-1);
f->f_offset += resid;
diff --git a/usr/src/boot/sys/boot/userboot/userboot/host.c b/usr/src/boot/sys/boot/userboot/userboot/host.c
index db88c61eca..c15d9d7e41 100644
--- a/usr/src/boot/sys/boot/userboot/userboot/host.c
+++ b/usr/src/boot/sys/boot/userboot/userboot/host.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 2011 Google, Inc.
* All rights reserved.
*
@@ -25,7 +25,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
/*
* Read from the host filesystem
@@ -74,16 +73,6 @@ host_read(struct open_file *f, void *start, size_t size, size_t *resid)
return (CALLBACK(read, f->f_fsdata, start, size, resid));
}
-/*
- * Don't be silly - the bootstrap has no business writing anything.
- */
-static int
-host_write(struct open_file *f, void *start, size_t size, size_t *resid)
-{
-
- return (EROFS);
-}
-
static off_t
host_seek(struct open_file *f, off_t offset, int where)
{
@@ -183,7 +172,7 @@ struct fs_ops host_fsops = {
host_open,
host_close,
host_read,
- host_write,
+ null_write,
host_seek,
host_stat,
host_readdir
diff --git a/usr/src/boot/sys/boot/zfs/zfs.c b/usr/src/boot/sys/boot/zfs/zfs.c
index 3dbb955e55..3efd491431 100644
--- a/usr/src/boot/sys/boot/zfs/zfs.c
+++ b/usr/src/boot/sys/boot/zfs/zfs.c
@@ -50,7 +50,6 @@
#define ZFS_BE_LAST 8
static int zfs_open(const char *path, struct open_file *f);
-static int zfs_write(struct open_file *f, void *buf, size_t size, size_t *resid);
static int zfs_close(struct open_file *f);
static int zfs_read(struct open_file *f, void *buf, size_t size, size_t *resid);
static off_t zfs_seek(struct open_file *f, off_t offset, int where);
@@ -64,7 +63,7 @@ struct fs_ops zfs_fsops = {
zfs_open,
zfs_close,
zfs_read,
- zfs_write,
+ null_write,
zfs_seek,
zfs_stat,
zfs_readdir
@@ -170,16 +169,6 @@ zfs_read(struct open_file *f, void *start, size_t size, size_t *resid /* out */)
return (0);
}
-/*
- * Don't be silly - the bootstrap has no business writing anything.
- */
-static int
-zfs_write(struct open_file *f, void *start, size_t size, size_t *resid /* out */)
-{
-
- return (EROFS);
-}
-
static off_t
zfs_seek(struct open_file *f, off_t offset, int where)
{