Overwriting of device block size from fat_init_volume_info

ali nasir supremenasir at yahoo.com
Tue Apr 22 06:45:19 UTC 2014


Hi,
 
Yes. I noticed that the length is an integral multiple of the media block size. 
So is this length field reliable enough to be used as a mesaure to determine how many blocks to read from the device. 
For e.g. if the media block size is 512 and the length field is 4096. Should i interpret in the device driver (ioctl) that the request is to read 8 blocks of data (4096/512)?
 
I was trying to read the block_size field of the struct rtems_disk_device. But the ioctl receives the pointer to the physical device and the block_size of the physical device is set to the media_block_size (512 in my case). There is no relation in the physical device pointer to the logical device (the partition on the disk).
 
Regards,
Ali

From: Sebastian Huber <sebastian.huber at embedded-brains.de>
To: ali nasir <supremenasir at yahoo.com> 
Cc: "rtems-users at rtems.org" <rtems-users at rtems.org> 
Sent: Tuesday, April 22, 2014 11:52 AM
Subject: Re: Overwriting of device block size from fat_init_volume_info


Hello Ali,

On 2014-04-20 04:18, ali nasir wrote:
> Hi,
>
> In the RTEMS4.11 i see that the block device's block size is overwritten in the
> rtems_disk_device depending on the cluster size or the alignment of the block
> device.
> We are migrating from 4.10.2 to 4.11. The block device we use is SD card. The
> ioctl just checks for the bufnum field and reads those number of blocks from
> the device. However, in the rtems4.11, with one particular SD card, the fat
> overwrites the block size to 4K from 512. But the ioctl is not aware of the
> same. Hence when the FAT tries to read a single block, it assumes that it will
> get 4K of data. But the ioctl just sends out 512 bytes to the FAT layer.
>
> How should i take care of the overwriting of the block size by FAT? The block
> device is created,at start up, with a block size of 512. Should the ioctl check
> the block size in the rtems_disk_device pointer which the ioctl receives?

the block device cache uses two block sizes.  One is the media block size which 
is the minimum transfer unit of a particular device/driver.  The other is the 
block size used by the cache.  It must be an integral multiple of the media 
block size.

I guess your driver doesn't evaluate the block device transfer request correctly.

/**
  * @brief Block device scatter or gather buffer structure.
  */
typedef struct rtems_blkdev_sg_buffer {
  /**
    * Block index.
    */
  rtems_blkdev_bnum block;

  /**
    * Buffer length.
    */
  uint32_t length;

  /**
    * Buffer pointer.
    */
  void *buffer;

  /**
    * User pointer.
    */
  void *user;
} rtems_blkdev_sg_buffer;

Please note that the length here may be an integral multiple of the media block 

size.

>
> This change in the fat_init_volume_info (to rewrite the block size) should be
> there in the release notes as there is a chance that the ioctl's, which were
> working with 4.10, may fail with 4.11.

We will add something to the release notes.

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone  : +49 89 189 47 41-16
Fax    : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP    : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20140421/4dac0867/attachment-0001.html>


More information about the users mailing list