fs/driver/fs_registerblockdriver.c
int register_blockdriver(const char *path,
                         const struct block_operations *bops,
                         mode_t mode, void *priv)
{
  struct Vnode *vp = NULL;
  int ret;

  if (path == NULL || strlen(path) >= PATH_MAX || strncmp("/dev/", path, DEV_PATH_LEN) != 0)
    {
      return -EINVAL;
    }

  /* Insert an vnode for the device driver -- we need to hold the vnode
   * semaphore to prevent access to the tree while we this.  This is because
   * we will have a momentarily bad true until we populate the vnode with
   * valid data.
   */

  struct drv_data *data = (struct drv_data *)zalloc(sizeof(struct drv_data));

  data->ops = (void *)bops;
  data->mode = mode;
  data->priv = priv;

  VnodeHold();
  ret = VnodeLookup(path, &vp, V_CREATE | V_DUMMY);
  if (ret == OK)
    {
      /* We have it, now populate it with block driver specific information. */

      vp->type = VNODE_TYPE_BLK;
      vp->data = data;
      vp->mode = mode;
    }

  VnodeDrop();
  return ret;
}
/****************************************************************************
 * Name: register_blockdriver
 *
 * Description:
 *   Register a block driver vnode the pseudo file system.
 *
 * Input parameters:
 *   path - The path to the vnode to create
 *   bops - The block driver operations structure
 *   mode - inmode priviledges (not used)
 *   priv - Private, user data that will be associated with the vnode.
 *
 * Returned Value:
 *   Zero on success (with the vnode point in 'vnode'); A negated errno
 *   value is returned on a failure (all error values returned by
 *   vnode_reserve):
 *
 *   EINVAL - 'path' is invalid for this operation
 *   EEXIST - An vnode already exists at 'path'
 *   ENOMEM - Failed to allocate in-memory resources for the operation
 *
 ****************************************************************************/
register_blockdriver
Description:
Register a block driver vnode the pseudo file system.

Input parameters:
path - The path to the vnode to create
bops - The block driver operations structure
mode - inmode priviledges (not used)
priv - Private, user data that will be associated with the vnode.

Returned Value:
Zero on success (with the vnode point in 'vnode'); A negated errno
value is returned on a failure (all error values returned by
vnode_reserve).

'path' is invalid for this operation
EEXIST - An vnode already exists at 'path'
ENOMEM - Failed to allocate in-memory resources for the operation
register_blockdriver Description : Register a block driver vnode the pseudo file system . Input parameters : path - The path to the vnode to create bops - The block driver operations structure mode - inmode priviledges ( not used ) priv - Private user data that will be associated with the vnode . Returned Value : Zero on success ( with the vnode point in ' vnode ' ) ; A negated errno value is returned on a failure ( all error values returned by vnode_reserve ) . ' path ' is invalid for this operation EEXIST - An vnode already exists at ' path ' ENOMEM - Failed to allocate in - memory resources for the operation
int register_blockdriver(const char *path,
                         const struct block_operations *bops,
                         mode_t mode, void *priv)
{
  struct Vnode *vp = NULL;
  int ret;
  if (path == NULL || strlen(path) >= PATH_MAX || strncmp("/dev/", path, DEV_PATH_LEN) != 0)
    {
      return -EINVAL;
    }
  struct drv_data *data = (struct drv_data *)zalloc(sizeof(struct drv_data));
  data->ops = (void *)bops;
  data->mode = mode;
  data->priv = priv;
  VnodeHold();
  ret = VnodeLookup(path, &vp, V_CREATE | V_DUMMY);
  if (ret == OK)
    {
      vp->type = VNODE_TYPE_BLK;
      vp->data = data;
      vp->mode = mode;
    }
  VnodeDrop();
  return ret;
}
int register_blockdriver ( const char * path , const struct block_operations * bops , mode_t mode , void * priv ) { struct Vnode * vp = NULL ; int ret ; if ( path == NULL || strlen ( path ) >= PATH_MAX || strncmp ( " " , path , DEV_PATH_LEN ) != 0 ) { return - EINVAL ; } struct drv_data * data = ( struct drv_data * ) zalloc ( sizeof ( struct drv_data ) ) ; data -> ops = ( void * ) bops ; data -> mode = mode ; data -> priv = priv ; VnodeHold ( ) ; ret = VnodeLookup ( path , & vp , V_CREATE | V_DUMMY ) ; if ( ret == OK ) { vp -> type = VNODE_TYPE_BLK ; vp -> data = data ; vp -> mode = mode ; } VnodeDrop ( ) ; return ret ; }
Name: register_blockdriver
 Description:
   Register a block driver vnode the pseudo file system.
Name : register_blockdriver Description : Register a block driver vnode the pseudo file system .
/* Insert an vnode for the device driver -- we need to hold the vnode
   * semaphore to prevent access to the tree while we this.  This is because
   * we will have a momentarily bad true until we populate the vnode with
   * valid data.
   */ /* We have it, now populate it with block driver specific information. */