Skip site navigation (1)Skip section navigation (2)
Date:      Mon,  2 Apr 2001 01:18:48 -0400 (EDT)
From:      "Michael Richards" <michael@fastmail.ca>
To:        freebsd-alpha@FreeBSD.ORG
Cc:        mjacob@feral.com
Subject:   Proposed Loader fix
Message-ID:  <3AC80BB8.000059.59989@frodo.searchcanada.ca>

next in thread | raw e-mail | index | archive | help

--------------Boundary-00=_C3G5WYN2Q7BNTT4D7TH0
Content-Type: Text/Plain
Content-Transfer-Encoding: 7bit

Hi.

Hate to be polluting the list with babble about how my 
underpowered :) brain is working on what I thought would be a simple 
loader problem. 

Here is the problem:
Every time open (in libstand) gets called, it must get info on the 
device through the devopen() call. The problem is, devopen() has no 
concept of whether the device is open or not so it blindly tries to 
open the device (even though it may already be open). This results in 
a call to prom_open which is causing the problems with some versions 
of SRM.

My proposed solution is:
Modify the devsw struct. Here is the original:
/*
 * Device switch
 */
struct devsw {
    const char  dv_name[8];
    int         dv_type;                /* opaque type constant, arch-
dependant */
    int         (*dv_init)(void);       /* early probe call */
    int         (*dv_strategy)(void *devdata, int rw, daddr_t blk, 
size_t size,
                               char *buf, size_t *rsize);
    int         (*dv_open)(struct open_file *f, ...);
    int         (*dv_close)(struct open_file *f);
    int         (*dv_ioctl)(struct open_file *f, u_long cmd, void 
*data);
    void        (*dv_print)(int verbose);       /* print device 
information */
    void        (*dv_cleanup)(void);
};

This appears to carry info about the device. So I say that I should 
be able to add a flag to it so it will not be opened multiple times.
Portability? No idea. It might cause everything to blow up. I'm 
really new to modifying OS level source, let alone changing data 
structures so I'm not sure the proper procedure or if this struct 
should even be mucked with.

   int         dv_opened;

Set this to 0 on initialisation, set it to 1 on open and set it to 0 
on close. This way each device can be opened once and only once no 
matter how many dev_open calls.

So this is my proposal. Feel free to comment on it. It will take a 
little hacking to get this change in, but if nobody takes exception 
to this, I'll do it and post patches.

-Michael
_________________________________________________________________
     http://fastmail.ca/ - Fast Free Web Email for Canadians
--------------Boundary-00=_C3G5WYN2Q7BNTT4D7TH0--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-alpha" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3AC80BB8.000059.59989>