Lines Matching +full:disk +full:- +full:name

4  * SPDX-License-Identifier: Apache-2.0
17 const char *name; member
24 struct disk_data *disk = fs->backend; in disk_access_device_size() local
26 return disk->sector_count * disk->sector_size; in disk_access_device_size()
31 struct disk_data *disk = fs->backend; in disk_access_write_size() local
33 return disk->sector_size; in disk_access_write_size()
36 static int disk_read(const char *disk, uint8_t *buf, uint32_t start, uint32_t num) in disk_read() argument
41 rc = disk_access_ioctl(disk, DISK_IOCTL_CTRL_SYNC, NULL); in disk_read()
43 rc = disk_access_read(disk, buf, start, num); in disk_read()
44 LOG_DBG("disk read: (start:%d, num:%d) (ret: %d)", start, num, rc); in disk_read()
46 } while ((rc == -EBUSY) && (loop++ < 16)); in disk_read()
50 static int disk_write(const char *disk, const uint8_t *buf, uint32_t start, uint32_t num) in disk_write() argument
55 rc = disk_access_ioctl(disk, DISK_IOCTL_CTRL_SYNC, NULL); in disk_write()
57 rc = disk_access_write(disk, buf, start, num); in disk_write()
58 LOG_DBG("disk write: (start:%d, num:%d) (ret: %d)", start, num, rc); in disk_write()
60 } while ((rc == -EBUSY) && (loop++ < 16)); in disk_write()
64 static int disk_prepare_range(struct disk_data *disk, uint32_t addr, uint32_t size, in disk_prepare_range() argument
67 *s_start = CONFIG_EXT2_DISK_STARTING_SECTOR + addr / disk->sector_size; in disk_prepare_range()
68 *s_count = size / disk->sector_size; in disk_prepare_range()
70 LOG_DBG("addr:0x%x size:0x%x -> sector_start:%d sector_count:%d", in disk_prepare_range()
74 if (*s_count > UINT32_MAX - *s_start) { in disk_prepare_range()
77 return -ENOSPC; in disk_prepare_range()
80 /* Cannot read or write outside the disk. */ in disk_prepare_range()
81 if (*s_start + *s_count > disk->sector_count) { in disk_prepare_range()
82 LOG_ERR("Requested sectors: %d-%d are outside of disk (num_sectors: %d)", in disk_prepare_range()
83 *s_start, *s_start + *s_count, disk->sector_count); in disk_prepare_range()
84 return -ENOSPC; in disk_prepare_range()
92 struct disk_data *disk = fs->backend; in disk_access_read_block() local
95 rc = disk_prepare_range(disk, block * fs->block_size, fs->block_size, in disk_access_read_block()
100 return disk_read(disk->name, buf, sector_start, sector_count); in disk_access_read_block()
106 struct disk_data *disk = fs->backend; in disk_access_write_block() local
109 rc = disk_prepare_range(disk, block * fs->block_size, fs->block_size, in disk_access_write_block()
114 return disk_write(disk->name, buf, sector_start, sector_count); in disk_access_write_block()
120 struct disk_data *disk = fs->backend; in disk_access_read_superblock() local
123 rc = disk_prepare_range(disk, EXT2_SUPERBLOCK_OFFSET, sizeof(struct ext2_disk_superblock), in disk_access_read_superblock()
128 return disk_read(disk->name, (uint8_t *)sb, sector_start, sector_count); in disk_access_read_superblock()
133 struct disk_data *disk = fs->backend; in disk_access_sync() local
135 LOG_DBG("Sync disk %s", disk->name); in disk_access_sync()
136 return disk_access_ioctl(disk->name, DISK_IOCTL_CTRL_SYNC, NULL); in disk_access_sync()
152 const char *name = (const char *)storage_dev; in ext2_init_disk_access_backend() local
154 rc = disk_access_init(name); in ext2_init_disk_access_backend()
156 LOG_ERR("FAIL: unable to find disk %s: %d\n", name, rc); in ext2_init_disk_access_backend()
160 rc = disk_access_ioctl(name, DISK_IOCTL_GET_SECTOR_COUNT, &sector_count); in ext2_init_disk_access_backend()
162 LOG_ERR("Disk access (sector count) error: %d", rc); in ext2_init_disk_access_backend()
166 rc = disk_access_ioctl(name, DISK_IOCTL_GET_SECTOR_SIZE, &sector_size); in ext2_init_disk_access_backend()
168 LOG_ERR("Disk access (sector size) error: %d", rc); in ext2_init_disk_access_backend()
173 .name = storage_dev, in ext2_init_disk_access_backend()
178 fs->backend = &disk_data; in ext2_init_disk_access_backend()
179 fs->backend_ops = &disk_access_ops; in ext2_init_disk_access_backend()