bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] libmachdev: Install as translator when bootstrapping && fix


From: Samuel Thibault
Subject: Re: [PATCH] libmachdev: Install as translator when bootstrapping && fix rumpdisk injection
Date: Sat, 14 Nov 2020 12:08:04 +0100
User-agent: NeoMutt/20170609 (1.8.3)

Damien Zammit, le sam. 14 nov. 2020 14:37:37 +1100, a ecrit:
> @@ -53,7 +53,7 @@ struct block_data
>    char name[DISK_NAME_LEN];  /* eg /dev/wd0 */
>    off_t media_size;          /* total block device size */
>    uint32_t block_size;               /* size in bytes of 1 sector */
> -  bool taken;                        /* simple refcount */
> +  bool opening;                      /* simple lock */
>    struct block_data *next;
>  };



> +  bd = search_bd (dev_name);
>    if (!bd)
>      {
>        err = machdev_create_device_port (sizeof (*bd), &bd);
>  
> -      snprintf (bd->name, DISK_NAME_LEN, "%s", name);
> +      snprintf (bd->name, DISK_NAME_LEN, "%s", dev_name);
> +      bd->opening = true;
>        bd->mode = mode;
>        bd->device.emul_data = bd;
>        bd->device.emul_ops = &rump_block_emulation_ops;

> @@ -253,6 +284,9 @@ device_write (void *d, mach_port_t reply_port,
>    if ((bd->mode & D_WRITE) == 0)
>      return D_INVALID_OPERATION;
>  
> +  if (bd->opening)
> +    return D_WOULD_BLOCK;
> +

? That cannot happen: the only period during which opening would be true
is during the device_open call in case the disk is getting opened for
the first time. But during that period, no port has been returned yet
that could be used to call device_write/read on it...

Samuel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]