Skip to content

Commit

Permalink
14121 loader: net_open() should not replace f->f_devdata
Browse files Browse the repository at this point in the history
Reviewed by: Klaus Ziegler <klausz@haus-gisela.de>
Approved by: Robert Mustacchi <rm@fingolfin.org>
  • Loading branch information
tsoome committed Nov 5, 2021
1 parent 4fd0933 commit 6538c7b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion usr/src/boot/Makefile.version
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,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)-2021.09.25.1
BOOT_VERSION = $(LOADER_VERSION)-2021.09.29.1
4 changes: 3 additions & 1 deletion usr/src/boot/lib/libstand/nfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ nfs_readdata(struct nfs_iodesc *d, off_t off, void *addr, size_t len)
int
nfs_open(const char *upath, struct open_file *f)
{
struct devdesc *dev;
struct iodesc *desc;
struct nfs_iodesc *currfd = NULL;
char buf[2 * NFS_V3MAXFHSIZE + 3];
Expand All @@ -479,6 +480,7 @@ nfs_open(const char *upath, struct open_file *f)
if (netproto != NET_NFS)
return (EINVAL);

dev = f->f_devdata;
#ifdef NFS_DEBUG
if (debug)
printf("nfs_open: %s (rootpath=%s)\n", upath, rootpath);
Expand All @@ -491,7 +493,7 @@ nfs_open(const char *upath, struct open_file *f)
if (f->f_dev->dv_type != DEVT_NET)
return (EINVAL);

if (!(desc = socktodesc(*(int *)(f->f_devdata))))
if (!(desc = socktodesc(*(int *)(dev->d_opendata))))
return (EINVAL);

/* Bind to a reserved port. */
Expand Down
7 changes: 5 additions & 2 deletions usr/src/boot/lib/libstand/tftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
/*
* Simple TFTP implementation for libsa.
* Assumes:
* - socket descriptor (int) at open_file->f_devdata
* - socket descriptor (int) at dev->d_opendata, dev stored at
* open_file->f_devdata
* - server host IP in global rootip
* Restrictions:
* - read only
Expand Down Expand Up @@ -429,6 +430,7 @@ tftp_getnextblock(struct tftp_handle *h)
static int
tftp_open(const char *path, struct open_file *f)
{
struct devdesc *dev;
struct tftp_handle *tftpfile;
struct iodesc *io;
int res;
Expand All @@ -449,7 +451,8 @@ tftp_open(const char *path, struct open_file *f)
return (ENOMEM);

tftpfile->tftp_blksize = TFTP_REQUESTED_BLKSIZE;
tftpfile->iodesc = io = socktodesc(*(int *)(f->f_devdata));
dev = f->f_devdata;
tftpfile->iodesc = io = socktodesc(*(int *)(dev->d_opendata));
if (io == NULL) {
free(tftpfile);
return (EINVAL);
Expand Down
8 changes: 5 additions & 3 deletions usr/src/boot/sys/boot/common/dev_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ net_init(void)

/*
* Called by devopen after it sets f->f_dev to our devsw entry.
* This opens the low-level device and sets f->f_devdata.
* This opens the low-level device and sets dev->d_opendata.
* This is declared with variable arguments...
*/
static int
Expand Down Expand Up @@ -193,20 +193,22 @@ net_open(struct open_file *f, ...)
}
}
netdev_opens++;
f->f_devdata = &netdev_sock;
dev->d_opendata = &netdev_sock;
return (error);
}

static int
net_close(struct open_file *f)
{
struct devdesc *dev;

#ifdef NETIF_DEBUG
if (debug)
printf("%s: opens=%d\n", __func__, netdev_opens);
#endif

f->f_devdata = NULL;
dev = f->f_devdata;
dev->d_opendata = NULL;

return (0);
}
Expand Down

0 comments on commit 6538c7b

Please sign in to comment.