VFS: complete the devmajor_t/devminor_t switch

Change-Id: I9f809283f19d577cf7e02705fdbb2310ae2b6cba
This commit is contained in:
David van Moolenbroek 2014-08-26 16:39:02 +00:00
parent 391516dd77
commit 3b4688844f
6 changed files with 29 additions and 30 deletions

View File

@ -110,7 +110,8 @@ int do_mapdriver(void)
* etc), and its label. This label is registered with DS, and allows us to * etc), and its label. This label is registered with DS, and allows us to
* retrieve the driver's endpoint. * retrieve the driver's endpoint.
*/ */
int r, major, slot; int r, slot;
devmajor_t major;
endpoint_t endpoint; endpoint_t endpoint;
vir_bytes label_vir; vir_bytes label_vir;
size_t label_len; size_t label_len;
@ -165,7 +166,8 @@ int do_mapdriver(void)
void dmap_unmap_by_endpt(endpoint_t proc_e) void dmap_unmap_by_endpt(endpoint_t proc_e)
{ {
/* Lookup driver in dmap table by endpoint and unmap it */ /* Lookup driver in dmap table by endpoint and unmap it */
int major, r; devmajor_t major;
int r;
for (major = 0; major < NR_DEVICES; major++) { for (major = 0; major < NR_DEVICES; major++) {
if (dmap_driver_match(proc_e, major)) { if (dmap_driver_match(proc_e, major)) {
@ -233,7 +235,7 @@ void init_dmap(void)
/*===========================================================================* /*===========================================================================*
* dmap_driver_match * * dmap_driver_match *
*===========================================================================*/ *===========================================================================*/
int dmap_driver_match(endpoint_t proc, int major) int dmap_driver_match(endpoint_t proc, devmajor_t major)
{ {
if (major < 0 || major >= NR_DEVICES) return(0); if (major < 0 || major >= NR_DEVICES) return(0);
if (dmap[major].dmap_driver != NONE && dmap[major].dmap_driver == proc) if (dmap[major].dmap_driver != NONE && dmap[major].dmap_driver == proc)
@ -246,7 +248,7 @@ int dmap_driver_match(endpoint_t proc, int major)
* dmap_by_major * * dmap_by_major *
*===========================================================================*/ *===========================================================================*/
struct dmap * struct dmap *
get_dmap_by_major(int major) get_dmap_by_major(devmajor_t major)
{ {
if (major < 0 || major >= NR_DEVICES) return(NULL); if (major < 0 || major >= NR_DEVICES) return(NULL);
if (dmap[major].dmap_driver == NONE) return(NULL); if (dmap[major].dmap_driver == NONE) return(NULL);
@ -261,8 +263,7 @@ void dmap_endpt_up(endpoint_t proc_e, int is_blk)
/* A device driver with endpoint proc_e has been restarted. Go tell everyone /* A device driver with endpoint proc_e has been restarted. Go tell everyone
* that might be blocking on it that this device is 'up'. * that might be blocking on it that this device is 'up'.
*/ */
devmajor_t major;
int major;
struct dmap *dp; struct dmap *dp;
struct worker_thread *worker; struct worker_thread *worker;
@ -303,8 +304,8 @@ struct dmap *get_dmap(endpoint_t proc_e)
{ {
/* See if 'proc_e' endpoint belongs to a valid dmap entry. If so, return a /* See if 'proc_e' endpoint belongs to a valid dmap entry. If so, return a
* pointer */ * pointer */
devmajor_t major;
int major;
for (major = 0; major < NR_DEVICES; major++) for (major = 0; major < NR_DEVICES; major++)
if (dmap_driver_match(proc_e, major)) if (dmap_driver_match(proc_e, major))
return(&dmap[major]); return(&dmap[major]);

View File

@ -209,7 +209,7 @@ void invalidate_filp(struct filp *rfilp)
/*===========================================================================* /*===========================================================================*
* invalidate_filp_by_char_major * * invalidate_filp_by_char_major *
*===========================================================================*/ *===========================================================================*/
void invalidate_filp_by_char_major(int major) void invalidate_filp_by_char_major(devmajor_t major)
{ {
struct filp *f; struct filp *f;

View File

@ -50,7 +50,8 @@ static void update_bspec(dev_t dev, endpoint_t fs_e, int send_drv_e)
*/ */
struct vnode *vp; struct vnode *vp;
struct dmap *dp; struct dmap *dp;
int r, major; devmajor_t major;
int r;
for (vp = &vnode[0]; vp < &vnode[NR_VNODES]; ++vp) for (vp = &vnode[0]; vp < &vnode[NR_VNODES]; ++vp)
if (vp->v_ref_count > 0 && S_ISBLK(vp->v_mode) && vp->v_sdev == dev) { if (vp->v_ref_count > 0 && S_ISBLK(vp->v_mode) && vp->v_sdev == dev) {

View File

@ -84,7 +84,8 @@ int do_creat(void)
int common_open(char path[PATH_MAX], int oflags, mode_t omode) int common_open(char path[PATH_MAX], int oflags, mode_t omode)
{ {
/* Common code from do_creat and do_open. */ /* Common code from do_creat and do_open. */
int b, r, exist = TRUE, major_dev; int b, r, exist = TRUE;
devmajor_t major_dev;
dev_t dev; dev_t dev;
mode_t bits; mode_t bits;
struct filp *filp, *filp2; struct filp *filp, *filp2;

View File

@ -40,7 +40,7 @@ void cdev_reply(void);
int bdev_open(dev_t dev, int access); int bdev_open(dev_t dev, int access);
int bdev_close(dev_t dev); int bdev_close(dev_t dev);
void bdev_reply(void); void bdev_reply(void);
void bdev_up(int major); void bdev_up(devmajor_t major);
int do_ioctl(void); int do_ioctl(void);
/* dmap.c */ /* dmap.c */
@ -48,10 +48,10 @@ void lock_dmap(struct dmap *dp);
void unlock_dmap(struct dmap *dp); void unlock_dmap(struct dmap *dp);
int do_mapdriver(void); int do_mapdriver(void);
void init_dmap(void); void init_dmap(void);
int dmap_driver_match(endpoint_t proc, int major); int dmap_driver_match(endpoint_t proc, devmajor_t major);
void dmap_endpt_up(endpoint_t proc_nr, int is_blk); void dmap_endpt_up(endpoint_t proc_nr, int is_blk);
struct dmap *get_dmap(endpoint_t proc_e); struct dmap *get_dmap(endpoint_t proc_e);
struct dmap *get_dmap_by_major(int major); struct dmap *get_dmap_by_major(devmajor_t major);
void dmap_unmap_by_endpt(endpoint_t proc_nr); void dmap_unmap_by_endpt(endpoint_t proc_nr);
int map_service(struct rprocpub *rpub); int map_service(struct rprocpub *rpub);
@ -76,7 +76,7 @@ void unlock_filp(struct filp *filp);
void unlock_filps(struct filp *filp1, struct filp *filp2); void unlock_filps(struct filp *filp1, struct filp *filp2);
void invalidate_filp(struct filp *); void invalidate_filp(struct filp *);
void invalidate_filp_by_endpt(endpoint_t proc_e); void invalidate_filp_by_endpt(endpoint_t proc_e);
void invalidate_filp_by_char_major(int major); void invalidate_filp_by_char_major(devmajor_t major);
void close_filp(struct filp *fp); void close_filp(struct filp *fp);
int do_copyfd(void); int do_copyfd(void);
@ -328,8 +328,8 @@ int do_select(void);
void init_select(void); void init_select(void);
void select_callback(struct filp *, int ops); void select_callback(struct filp *, int ops);
void select_forget(void); void select_forget(void);
void select_reply1(endpoint_t driver_e, int minor, int status); void select_reply1(endpoint_t driver_e, devminor_t minor, int status);
void select_reply2(endpoint_t driver_e, int minor, int status); void select_reply2(endpoint_t driver_e, devminor_t minor, int status);
void select_timeout_check(minix_timer_t *); void select_timeout_check(minix_timer_t *);
void select_unsuspend_by_endpt(endpoint_t proc); void select_unsuspend_by_endpt(endpoint_t proc);

View File

@ -362,7 +362,8 @@ static int select_request_char(struct filp *f, int *ops, int block)
* result processing to be deferred. This function MUST NOT block its calling * result processing to be deferred. This function MUST NOT block its calling
* thread. The given filp may or may not be locked. * thread. The given filp may or may not be locked.
*/ */
int r, rops, major; devmajor_t major;
int r, rops;
struct dmap *dp; struct dmap *dp;
major = major(f->filp_vno->v_sdev); major = major(f->filp_vno->v_sdev);
@ -596,7 +597,7 @@ static void select_cancel_filp(struct filp *f)
/* Reduce the number of select users of this filp. This function MUST NOT block /* Reduce the number of select users of this filp. This function MUST NOT block
* its calling thread. * its calling thread.
*/ */
dev_t major; devmajor_t major;
assert(f); assert(f);
assert(f->filp_selectors > 0); assert(f->filp_selectors > 0);
@ -729,8 +730,8 @@ void select_timeout_check(minix_timer_t *timer)
void select_unsuspend_by_endpt(endpoint_t proc_e) void select_unsuspend_by_endpt(endpoint_t proc_e)
{ {
/* Revive blocked processes when a driver has disappeared */ /* Revive blocked processes when a driver has disappeared */
devmajor_t major;
int fd, s, major; int fd, s;
struct selectentry *se; struct selectentry *se;
struct filp *f; struct filp *f;
@ -765,15 +766,12 @@ void select_unsuspend_by_endpt(endpoint_t proc_e)
/*===========================================================================* /*===========================================================================*
* select_reply1 * * select_reply1 *
*===========================================================================*/ *===========================================================================*/
void select_reply1(driver_e, minor, status) void select_reply1(endpoint_t driver_e, devminor_t minor, int status)
endpoint_t driver_e;
int minor;
int status;
{ {
/* Handle the initial reply to CDEV_SELECT request. This function MUST NOT /* Handle the initial reply to CDEV_SELECT request. This function MUST NOT
* block its calling thread. * block its calling thread.
*/ */
int major; devmajor_t major;
dev_t dev; dev_t dev;
struct filp *f; struct filp *f;
struct dmap *dp; struct dmap *dp;
@ -863,16 +861,14 @@ int status;
/*===========================================================================* /*===========================================================================*
* select_reply2 * * select_reply2 *
*===========================================================================*/ *===========================================================================*/
void select_reply2(driver_e, minor, status) void select_reply2(endpoint_t driver_e, devminor_t minor, int status)
endpoint_t driver_e;
int minor;
int status;
{ {
/* Handle secondary reply to DEV_SELECT request. A secondary reply occurs when /* Handle secondary reply to DEV_SELECT request. A secondary reply occurs when
* the select request is 'blocking' until an operation becomes ready. This * the select request is 'blocking' until an operation becomes ready. This
* function MUST NOT block its calling thread. * function MUST NOT block its calling thread.
*/ */
int major, slot, found, fd; int slot, found, fd;
devmajor_t major;
dev_t dev; dev_t dev;
struct filp *f; struct filp *f;
struct dmap *dp; struct dmap *dp;