Lines Matching +full:verify +full:- +full:formatting

4  * SPDX-License-Identifier: Apache-2.0
29 struct ext2_data *fs = filp->mp->fs_data; in ext2_open()
31 if (fs->open_files >= CONFIG_MAX_FILES) { in ext2_open()
33 return -EMFILE; in ext2_open()
42 const char *path = fs_impl_strip_prefix(fs_path, filp->mp); in ext2_open()
88 if ((found_inode->i_mode & EXT2_S_IFMT) != EXT2_S_IFREG) { in ext2_open()
89 ret = -EINVAL; in ext2_open()
95 ret = -ENOMEM; in ext2_open()
99 file->f_inode = found_inode; in ext2_open()
100 file->f_off = 0; in ext2_open()
101 file->f_flags = flags & (FS_O_RDWR | FS_O_APPEND); in ext2_open()
103 filp->filep = file; in ext2_open()
117 struct ext2_file *f = filp->filep; in ext2_close()
119 rc = ext2_inode_sync(f->f_inode); in ext2_close()
124 rc = ext2_inode_drop(f->f_inode); in ext2_close()
130 filp->filep = NULL; in ext2_close()
137 struct ext2_file *f = filp->filep; in ext2_read()
139 if ((f->f_flags & FS_O_READ) == 0) { in ext2_read()
140 return -EACCES; in ext2_read()
143 ssize_t r = ext2_inode_read(f->f_inode, dest, f->f_off, nbytes); in ext2_read()
148 f->f_off += r; in ext2_read()
154 struct ext2_file *f = filp->filep; in ext2_write()
156 if ((f->f_flags & FS_O_WRITE) == 0) { in ext2_write()
157 return -EACCES; in ext2_write()
160 if (f->f_flags & FS_O_APPEND) { in ext2_write()
161 f->f_off = f->f_inode->i_size; in ext2_write()
164 ssize_t r = ext2_inode_write(f->f_inode, src, f->f_off, nbytes); in ext2_write()
170 f->f_off += r; in ext2_write()
176 struct ext2_file *f = filp->filep; in ext2_lseek()
185 new_off = f->f_off + off; in ext2_lseek()
189 new_off = f->f_inode->i_size + off; in ext2_lseek()
193 return -EINVAL; in ext2_lseek()
197 if (new_off < 0 || new_off > f->f_inode->i_size) { in ext2_lseek()
198 return -EINVAL; in ext2_lseek()
200 f->f_off = new_off; in ext2_lseek()
206 struct ext2_file *f = filp->filep; in ext2_tell()
208 return f->f_off; in ext2_tell()
213 struct ext2_file *f = filp->filep; in ext2_truncate()
215 if ((f->f_flags & FS_O_WRITE) == 0) { in ext2_truncate()
216 return -EACCES; in ext2_truncate()
219 int rc = ext2_inode_trunc(f->f_inode, length); in ext2_truncate()
229 struct ext2_file *f = filp->filep; in ext2_sync()
231 int rc = ext2_inode_sync(f->f_inode); in ext2_sync()
244 struct ext2_data *fs = mountp->fs_data; in ext2_mkdir()
267 ret = -EEXIST; in ext2_mkdir()
292 const char *path = fs_impl_strip_prefix(fs_path, dirp->mp); in ext2_opendir()
293 struct ext2_data *fs = dirp->mp->fs_data; in ext2_opendir()
307 if (!(found_inode->i_mode & EXT2_S_IFDIR)) { in ext2_opendir()
308 ret = -ENOTDIR; in ext2_opendir()
314 ret = -ENOMEM; in ext2_opendir()
320 ret = -ENOMEM; in ext2_opendir()
324 dir->f_inode = found_inode; in ext2_opendir()
325 dir->f_off = 0; in ext2_opendir()
327 dirp->dirp = dir; in ext2_opendir()
337 struct ext2_file *dir = dirp->dirp; in ext2_readdir()
349 struct ext2_file *dir = dirp->dirp; in ext2_closedir()
351 ext2_inode_drop(dir->f_inode); in ext2_closedir()
374 bool possible_format = (mountp->flags & FS_MOUNT_FLAG_NO_FORMAT) == 0 && in ext2_mount()
375 (mountp->flags & FS_MOUNT_FLAG_READ_ONLY) == 0; in ext2_mount()
378 ret = ext2_init_storage(&fs, mountp->storage_dev, mountp->flags); in ext2_mount()
383 fs->flags = 0; in ext2_mount()
384 if (mountp->flags & FS_MOUNT_FLAG_READ_ONLY) { in ext2_mount()
385 fs->flags |= EXT2_DATA_FLAGS_RO; in ext2_mount()
388 ret = fs->backend_ops->read_superblock(fs, &superblock); in ext2_mount()
395 fs->block_size = 1024 << superblock.s_log_block_size; in ext2_mount()
397 } else if (ret == -EROFS) { in ext2_mount()
398 fs->block_size = 1024 << superblock.s_log_block_size; in ext2_mount()
399 fs->flags |= EXT2_DATA_FLAGS_RO; in ext2_mount()
402 } else if (ret == -EINVAL && possible_format) { in ext2_mount()
404 fs->block_size = ext2_default_cfg.block_size; in ext2_mount()
411 if (fs->block_size % fs->write_size != 0) { in ext2_mount()
413 fs->block_size, fs->write_size); in ext2_mount()
414 ret = -ENOTSUP; in ext2_mount()
422 LOG_INF("Formatting the storage device"); in ext2_mount()
428 /* We don't need to verify superblock here again. Format has succeeded hence in ext2_mount()
439 mountp->fs_data = fs; in ext2_mount()
465 fs->block_size = cfg->block_size; in ext2_mkfs()
469 LOG_INF("Formatting the storage device"); in ext2_mkfs()
485 struct ext2_data *fs = mountp->fs_data; in ext2_unmount()
496 mountp->fs_data = NULL; in ext2_unmount()
503 struct ext2_data *fs = mountp->fs_data; in ext2_unlink()
535 struct ext2_data *fs = mountp->fs_data; in ext2_rename()
537 LOG_DBG("Rename: %s -> %s", from, to); in ext2_rename()
584 struct ext2_data *fs = mountp->fs_data; in ext2_stat()
613 struct ext2_data *fs = mountp->fs_data; in ext2_statvfs()
615 stat->f_bsize = fs->block_size; in ext2_statvfs()
616 stat->f_frsize = fs->block_size; in ext2_statvfs()
617 stat->f_blocks = fs->sblock.s_blocks_count; in ext2_statvfs()
618 stat->f_bfree = fs->sblock.s_free_blocks_count; in ext2_statvfs()