make 'path' argument to ufs_open 'const char *' and fix the fallout.

This commit is contained in:
dsl 2003-08-18 15:45:27 +00:00
parent ad49f181fd
commit 8453fb0040
12 changed files with 72 additions and 128 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dosfs.c,v 1.6 2003/07/15 13:27:07 scw Exp $ */
/* $NetBSD: dosfs.c,v 1.7 2003/08/18 15:45:27 dsl Exp $ */
/*
* Copyright (c) 1996, 1998 Robert Nordier
@ -202,7 +202,7 @@ dosunmount(DOS_FS * fs)
* Open DOS file
*/
int
dosfs_open(char *path, struct open_file *fd)
dosfs_open(const char *path, struct open_file *fd)
{
const struct direntry *de;
DOS_FILE *f;

View File

@ -1,4 +1,4 @@
/* $NetBSD: dosfs.h,v 1.1 2000/11/02 00:25:05 thorpej Exp $ */
/* $NetBSD: dosfs.h,v 1.2 2003/08/18 15:45:27 dsl Exp $ */
/*
* Copyright (c) 1996, 1998 Robert Nordier
@ -27,9 +27,4 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
int dosfs_open(char *path, struct open_file *);
int dosfs_close(struct open_file *);
int dosfs_read(struct open_file *, void *, size_t, size_t *);
int dosfs_write(struct open_file *, void *, size_t, size_t *);
off_t dosfs_seek(struct open_file *, off_t, int);
int dosfs_stat(struct open_file *, struct stat *);
FS_DEF(dosfs);

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs.h,v 1.3 2003/08/07 16:32:27 agc Exp $ */
/* $NetBSD: lfs.h,v 1.4 2003/08/18 15:45:28 dsl Exp $ */
/*-
* Copyright (c) 1993
@ -31,16 +31,5 @@
* @(#)ufs.h 8.1 (Berkeley) 6/11/93
*/
int lfsv1_open(char *path, struct open_file *f);
int lfsv1_close(struct open_file *f);
int lfsv1_read(struct open_file *f, void *buf, size_t size, size_t *resid);
int lfsv1_write(struct open_file *f, void *buf, size_t size, size_t *resid);
off_t lfsv1_seek(struct open_file *f, off_t offset, int where);
int lfsv1_stat(struct open_file *f, struct stat *sb);
int lfsv2_open(char *path, struct open_file *f);
int lfsv2_close(struct open_file *f);
int lfsv2_read(struct open_file *f, void *buf, size_t size, size_t *resid);
int lfsv2_write(struct open_file *f, void *buf, size_t size, size_t *resid);
off_t lfsv2_seek(struct open_file *f, off_t offset, int where);
int lfsv2_stat(struct open_file *f, struct stat *sb);
FS_DEF(lfsv1);
FS_DEF(lfsv2);

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs.c,v 1.31 2003/03/18 19:20:09 mycroft Exp $ */
/* $NetBSD: nfs.c,v 1.32 2003/08/18 15:45:28 dsl Exp $ */
/*-
* Copyright (c) 1993 John Brezak
@ -112,7 +112,8 @@ struct nfs_iodesc {
struct nfs_iodesc nfs_root_node;
int nfs_getrootfh __P((struct iodesc *, char *, u_char *));
int nfs_lookupfh __P((struct nfs_iodesc *, char *, struct nfs_iodesc *));
int nfs_lookupfh __P((struct nfs_iodesc *, const char *, int,
struct nfs_iodesc *));
int nfs_readlink __P((struct nfs_iodesc *, char *));
ssize_t nfs_readdata __P((struct nfs_iodesc *, off_t, void *, size_t));
@ -184,12 +185,13 @@ nfs_getrootfh(d, path, fhp)
* Return zero or error number.
*/
int
nfs_lookupfh(d, name, newfd)
nfs_lookupfh(d, name, len, newfd)
struct nfs_iodesc *d;
char *name;
const char *name;
int len;
struct nfs_iodesc *newfd;
{
int len, rlen;
int rlen;
struct args {
u_char fh[NFS_FHSIZE];
n_long len;
@ -220,7 +222,6 @@ nfs_lookupfh(d, name, newfd)
bzero(args, sizeof(*args));
bcopy(d->fh, args->fh, sizeof(args->fh));
len = strlen(name);
if (len > sizeof(args->name))
len = sizeof(args->name);
bcopy(name, args->name, len);
@ -398,13 +399,13 @@ nfs_mount(sock, ip, path)
*/
int
nfs_open(path, f)
char *path;
const char *path;
struct open_file *f;
{
struct nfs_iodesc *newfd, *currfd;
char *cp;
const char *cp;
#ifndef NFS_NOSYMLINK
char *ncp;
const char *ncp;
int c;
char namebuf[NFS_MAXPATHLEN + 1];
char linkbuf[NFS_MAXPATHLEN + 1];
@ -462,12 +463,10 @@ nfs_open(path, f)
}
cp++;
}
*cp = '\0';
}
/* lookup a file handle */
error = nfs_lookupfh(currfd, ncp, newfd);
*cp = c;
error = nfs_lookupfh(currfd, ncp, cp - ncp, newfd);
if (error)
goto out;
@ -534,7 +533,7 @@ out:
/* XXX: Check for empty path here? */
error = nfs_lookupfh(&nfs_root_node, cp, currfd);
error = nfs_lookupfh(&nfs_root_node, cp, strlen(cp), currfd);
#endif
if (!error) {
f->f_fsdata = (void *)currfd;

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs.h,v 1.6 2003/08/07 16:32:28 agc Exp $ */
/* $NetBSD: nfs.h,v 1.7 2003/08/18 15:45:28 dsl Exp $ */
/*-
* Copyright (c) 1993
@ -29,13 +29,5 @@
* SUCH DAMAGE.
*/
int nfs_open __P((char *path, struct open_file *f));
int nfs_close __P((struct open_file *f));
int nfs_read __P((struct open_file *f, void *buf,
size_t size, size_t *resid));
int nfs_write __P((struct open_file *f, void *buf,
size_t size, size_t *resid));
off_t nfs_seek __P((struct open_file *f, off_t offset, int where));
int nfs_stat __P((struct open_file *f, struct stat *sb));
int nfs_mount __P((int, struct in_addr, char *));
FS_DEF(nfs);
int nfs_mount(int, struct in_addr, char *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: nullfs.c,v 1.6 2003/08/07 16:32:29 agc Exp $ */
/* $NetBSD: nullfs.c,v 1.7 2003/08/18 15:45:28 dsl Exp $ */
/*-
* Copyright (c) 1993
@ -67,7 +67,7 @@
*/
int
null_open(char *path, struct open_file *f)
null_open(const char *path, struct open_file *f)
{
return EIO;

View File

@ -1,4 +1,4 @@
/* $NetBSD: stand.h,v 1.49 2003/08/07 16:32:30 agc Exp $ */
/* $NetBSD: stand.h,v 1.50 2003/08/18 15:45:29 dsl Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -90,7 +90,7 @@
struct open_file;
#define FS_DEF(fs) \
extern int __CONCAT(fs,_open)(char *, struct open_file *); \
extern int __CONCAT(fs,_open)(const char *, struct open_file *); \
extern int __CONCAT(fs,_close)(struct open_file *); \
extern int __CONCAT(fs,_read)(struct open_file *, void *, \
size_t, size_t *); \
@ -105,7 +105,7 @@ struct open_file;
*/
#if !defined(LIBSA_SINGLE_FILESYSTEM)
struct fs_ops {
int (*open)(char *, struct open_file *);
int (*open)(const char *, struct open_file *);
int (*close)(struct open_file *);
int (*read)(struct open_file *, void *, size_t, size_t *);
int (*write)(struct open_file *, void *, size_t size, size_t *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: tftp.c,v 1.14 2003/03/18 19:20:09 mycroft Exp $ */
/* $NetBSD: tftp.c,v 1.15 2003/08/18 15:45:29 dsl Exp $ */
/*
* Copyright (c) 1996
@ -77,7 +77,7 @@ struct tftp_handle {
int islastblock; /* flag */
int validsize;
int off;
char *path; /* saved for re-requests */
const char *path; /* saved for re-requests */
struct {
u_char header[HEADER_SIZE];
struct tftphdr t;
@ -261,7 +261,7 @@ tftp_terminate(h)
int
tftp_open(path, f)
char *path;
const char *path;
struct open_file *f;
{
struct tftp_handle *tftpfile;

View File

@ -1,4 +1,4 @@
/* $NetBSD: tftp.h,v 1.3 2003/08/07 16:32:30 agc Exp $ */
/* $NetBSD: tftp.h,v 1.4 2003/08/18 15:45:29 dsl Exp $ */
/*
* Copyright (c) 1996
@ -105,13 +105,6 @@ struct tftphdr {
#define EEXISTS 6 /* file already exists */
#define ENOUSER 7 /* no such user */
int tftp_open __P((char *path, struct open_file *f));
int tftp_read __P((struct open_file *f, void *addr,
size_t size, size_t *resid));
int tftp_close __P((struct open_file *f));
int tftp_write __P((struct open_file *f, void *addr,
size_t size, size_t *resid));
int tftp_stat __P((struct open_file *f, struct stat *sb));
off_t tftp_seek __P((struct open_file *f, off_t offset, int where));
FS_DEF(tftp);
#define IPPORT_TFTP 69

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs.c,v 1.37 2003/08/18 08:00:52 dsl Exp $ */
/* $NetBSD: ufs.c,v 1.38 2003/08/18 15:45:30 dsl Exp $ */
/*-
* Copyright (c) 1993
@ -152,15 +152,15 @@ struct file {
daddr_t f_buf_blkno; /* block number of data block */
};
static int read_inode(ino_t, struct open_file *);
static int block_map(struct open_file *, daddr_t, daddr_t *);
static int buf_read_file(struct open_file *, char **, size_t *);
static int search_directory(const char *, struct open_file *, ino_t *);
static int read_inode(ino_t, struct open_file *);
static int block_map(struct open_file *, daddr_t, daddr_t *);
static int buf_read_file(struct open_file *, char **, size_t *);
static int search_directory(const char *, int, struct open_file *, ino_t *);
#ifdef LIBSA_FFSv1
static void ffs_oldfscompat(struct fs *);
static void ffs_oldfscompat(struct fs *);
#endif
#ifdef LIBSA_FFSv2
static int ffs_find_superblock(struct open_file *, struct fs *);
static int ffs_find_superblock(struct open_file *, struct fs *);
#endif
#ifdef LIBSA_LFS
@ -324,15 +324,14 @@ block_map(struct open_file *f, daddr_t file_block, daddr_t *disk_block_p)
* nindir[2] = NINDIR**3
* etc
*/
for (level = 0; level < NIADDR; level++) {
for (level = 0; ; level++) {
if (level == NIADDR)
/* Block number too high */
return (EFBIG);
if (file_block < fp->f_nindir[level])
break;
file_block -= fp->f_nindir[level];
}
if (level == NIADDR) {
/* Block number too high */
return (EFBIG);
}
ind_block_num = fp->f_di.di_ib[level];
@ -343,9 +342,8 @@ block_map(struct open_file *f, daddr_t file_block, daddr_t *disk_block_p)
}
if (fp->f_blkno[level] != ind_block_num) {
if (fp->f_blk[level] == (char *)0)
fp->f_blk[level] =
alloc(fs->fs_bsize);
if (fp->f_blk[level] == NULL)
fp->f_blk[level] = alloc(fs->fs_bsize);
twiddle();
rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
FSBTODB(fp->f_fs, ind_block_num),
@ -402,7 +400,7 @@ buf_read_file(struct open_file *f, char **buf_p, size_t *size_p)
if (rc)
return (rc);
if (fp->f_buf == (char *)0)
if (fp->f_buf == NULL)
fp->f_buf = alloc(fs->fs_bsize);
if (disk_block == 0) {
@ -439,21 +437,20 @@ buf_read_file(struct open_file *f, char **buf_p, size_t *size_p)
/*
* Search a directory for a name and return its
* i_number.
* inode number.
*/
static int
search_directory(const char *name, struct open_file *f, ino_t *inumber_p)
search_directory(const char *name, int length, struct open_file *f,
ino_t *inumber_p)
{
struct file *fp = (struct file *)f->f_fsdata;
struct direct *dp;
struct direct *edp;
char *buf;
size_t buf_size;
int namlen, length;
int namlen;
int rc;
length = strlen(name);
fp->f_seekp = 0;
while (fp->f_seekp < fp->f_di.di_size) {
rc = buf_read_file(f, &buf, &buf_size);
@ -462,9 +459,9 @@ search_directory(const char *name, struct open_file *f, ino_t *inumber_p)
dp = (struct direct *)buf;
edp = (struct direct *)(buf + buf_size);
while (dp < edp) {
for (;dp < edp; dp = (void *)((char *)dp + dp->d_reclen)) {
if (dp->d_ino == (ino_t)0)
goto next;
continue;
#if BYTE_ORDER == LITTLE_ENDIAN
if (fp->f_fs->fs_maxsymlinklen <= 0)
namlen = dp->d_type;
@ -472,13 +469,11 @@ search_directory(const char *name, struct open_file *f, ino_t *inumber_p)
#endif
namlen = dp->d_namlen;
if (namlen == length &&
!strcmp(name, dp->d_name)) {
!memcmp(name, dp->d_name, length)) {
/* found entry */
*inumber_p = dp->d_ino;
return (0);
}
next:
dp = (struct direct *)((char *)dp + dp->d_reclen);
}
fp->f_seekp += buf_size;
}
@ -514,10 +509,10 @@ ffs_find_superblock(struct open_file *f, struct fs *fs)
* Open a file.
*/
int
ufs_open(char *path, struct open_file *f)
ufs_open(const char *path, struct open_file *f)
{
#ifndef LIBSA_FS_SINGLECOMPONENT
char *cp, *ncp;
const char *cp, *ncp;
int c;
#endif
ino_t inumber;
@ -640,19 +635,9 @@ ufs_open(char *path, struct open_file *f)
/*
* Get next component of path name.
*/
{
int len = 0;
ncp = cp;
while ((c = *cp) != '\0' && c != '/') {
if (++len > MAXNAMLEN) {
rc = ENOENT;
goto out;
}
cp++;
}
*cp = '\0';
}
ncp = cp;
while ((c = *cp) != '\0' && c != '/')
cp++;
/*
* Look up component in current directory.
@ -662,8 +647,7 @@ ufs_open(char *path, struct open_file *f)
#ifndef LIBSA_NO_FS_SYMLINK
parent_inumber = inumber;
#endif
rc = search_directory(ncp, f, &inumber);
*cp = c;
rc = search_directory(ncp, cp - ncp, f, &inumber);
if (rc)
goto out;
@ -689,11 +673,10 @@ ufs_open(char *path, struct open_file *f)
goto out;
}
bcopy(cp, &namebuf[link_len], len + 1);
memmove(&namebuf[link_len], cp, len + 1);
if (link_len < fs->fs_maxsymlinklen) {
bcopy(fp->f_di.di_db, namebuf,
(unsigned)link_len);
memcpy(namebuf, fp->f_di.di_db, link_len);
} else {
/*
* Read file for symbolic link
@ -714,7 +697,7 @@ ufs_open(char *path, struct open_file *f)
if (rc)
goto out;
bcopy(buf, namebuf, (unsigned)link_len);
memcpy(namebuf, buf, link_len);
}
/*
@ -741,7 +724,7 @@ ufs_open(char *path, struct open_file *f)
#else /* !LIBSA_FS_SINGLECOMPONENT */
/* look up component in the current (root) directory */
rc = search_directory(path, f, &inumber);
rc = search_directory(path, strlen(path), f, &inumber);
if (rc)
goto out;
@ -758,10 +741,7 @@ out:
free(buf, fs->fs_bsize);
#endif
if (rc) {
if (fp->f_buf)
free(fp->f_buf, fp->f_fs->fs_bsize);
free(fp->f_fs, SBLOCKSIZE);
free(fp, sizeof(struct file));
ufs_close(f);
}
return (rc);
}
@ -773,8 +753,8 @@ ufs_close(struct open_file *f)
struct file *fp = (struct file *)f->f_fsdata;
int level;
f->f_fsdata = (void *)0;
if (fp == (struct file *)0)
f->f_fsdata = NULL;
if (fp == NULL)
return (0);
for (level = 0; level < NIADDR; level++) {
@ -815,7 +795,7 @@ ufs_read(struct open_file *f, void *start, size_t size, size_t *resid)
if (csize > buf_size)
csize = buf_size;
bcopy(buf, addr, csize);
memcpy(addr, buf, csize);
fp->f_seekp += csize;
addr += csize;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ustarfs.c,v 1.21 2003/03/18 19:20:09 mycroft Exp $ */
/* $NetBSD: ustarfs.c,v 1.22 2003/08/18 15:45:30 dsl Exp $ */
/* [Notice revision 2.2]
* Copyright (c) 1997, 1998 Avalon Computer Systems, Inc.
@ -391,7 +391,7 @@ init_volzero_sig(f)
int
ustarfs_open(path, f)
char *path;
const char *path;
struct open_file *f;
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: ustarfs.h,v 1.1 1998/09/24 05:23:34 ross Exp $ */
/* $NetBSD: ustarfs.h,v 1.2 2003/08/18 15:45:30 dsl Exp $ */
/* [Notice revision 2.2]
* Copyright (c) 1997, 1998 Avalon Computer Systems, Inc.
@ -34,9 +34,5 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
int ustarfs_open __P((char *, struct open_file *));
int ustarfs_close __P((struct open_file *));
int ustarfs_read __P((struct open_file *, void *, size_t, size_t *));
int ustarfs_write __P((struct open_file *, void *, size_t, size_t *));
off_t ustarfs_seek __P((struct open_file *, off_t, int));
int ustarfs_stat __P((struct open_file *, struct stat *));
FS_DEF(ustarfs);