file->inode->atime = clock_unixtime();
if ((file->inode->itype & VFS_IFSEQDEV) || (fd_s->flags & FO_DIRECT)) {
- errno = file->ops->read(file->inode, buf, count, file->f_pos);
+ errno = file->ops->read(file->inode, buf, count, file->f_pos);
} else {
errno = pcache_read(file->inode, buf, count, file->f_pos);
}
int
vfs_get_dtype(int itype)
{
- if ((itype & VFS_IFSYMLINK)) {
+ if ((itype & VFS_IFSYMLINK) == VFS_IFSYMLINK) {
return DT_SYMLINK;
} else if (!(itype & VFS_IFFILE)) {
return DT_DIR;
goto done;
}
+ if (!(errno = vfs_walk(parent, name_value, &dir, NULL, 0))) {
+ errno = EEXIST;
+ goto done;
+ }
+
if ((errno = vfs_check_writable(parent))) {
goto done;
}
vfs_ref_dnode(struct v_dnode* dnode)
{
atomic_fetch_add(&dnode->ref_count, 1);
- mnt_mkbusy(dnode->mnt);
+
+ if (dnode->mnt) {
+ mnt_mkbusy(dnode->mnt);
+ }
}
void
vfs_unref_dnode(struct v_dnode* dnode)
{
atomic_fetch_sub(&dnode->ref_count, 1);
- mnt_chillax(dnode->mnt);
+ if (dnode->mnt) {
+ mnt_chillax(dnode->mnt);
+ }
}
int
.st_blksize = vino->sb->blksize};
if (VFS_DEVFILE(vino->itype)) {
- struct device* rdev = (struct device*)vino->data;
+ struct device* rdev = resolve_device(vino->data);
if (!rdev || rdev->magic != DEV_STRUCT_MAGIC) {
errno = EINVAL;
goto done;