ret = exfat_alloc_cluster(inode, new_num_clusters - num_clusters,
&clu, inode_needs_sync(inode)); if (ret) return ret;
/* Append new clusters to chain */ if (num_clusters) { if (clu.flags != ei->flags) if (exfat_chain_cont_cluster(sb, ei->start_clu, num_clusters)) goto free_clu;
if (clu.flags == ALLOC_FAT_CHAIN) if (exfat_ent_set(sb, last_clu, clu.dir)) goto free_clu;
} else
ei->start_clu = clu.dir;
ei->flags = clu.flags;
out:
inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); /* Expanded range not zeroed, do not update valid_size */
i_size_write(inode, size);
/* Of the r and x bits, all (subject to umask) must be present.*/ if ((perm & 0555) != (i_mode & 0555)) return -EPERM;
if (exfat_mode_can_hold_ro(inode)) { /* * Of the w bits, either all (subject to umask) or none must * be present.
*/ if ((perm & 0222) && ((perm & 0222) != (0222 & ~mask))) return -EPERM;
} else { /* * If exfat_mode_can_hold_ro(inode) is false, can't change * w bits.
*/ if ((perm & 0222) != (0222 & ~mask)) return -EPERM;
}
if (i_size_read(inode) < ei->valid_size)
ei->valid_size = i_size_read(inode);
if (ei->type == TYPE_FILE)
ei->attr |= EXFAT_ATTR_ARCHIVE;
/* * update the directory entry * * If the directory entry is updated by mark_inode_dirty(), the * directory entry will be written after a writeback cycle of * updating the bitmap/FAT, which may result in clusters being * freed but referenced by the directory entry in the event of a * sudden power failure. * __exfat_write_inode() is called for directory entry, bitmap * and FAT to be written in a same writeback.
*/ if (__exfat_write_inode(inode, inode_needs_sync(inode))) return -EIO;
/* cut off from the FAT chain */ if (ei->flags == ALLOC_FAT_CHAIN && last_clu != EXFAT_FREE_CLUSTER &&
last_clu != EXFAT_EOF_CLUSTER) { if (exfat_ent_set(sb, last_clu, EXFAT_EOF_CLUSTER)) return -EIO;
}
/* invalidate cache and free the clusters */ /* clear exfat cache */
exfat_cache_inval_inode(inode);
/* hint information */
ei->hint_bmap.off = EXFAT_EOF_CLUSTER;
ei->hint_bmap.clu = EXFAT_EOF_CLUSTER;
/* hint_stat will be used if this is directory. */
ei->hint_stat.eidx = 0;
ei->hint_stat.clu = ei->start_clu;
ei->hint_femp.eidx = EXFAT_HINT_NONE;
/* free the clusters */ if (exfat_free_cluster(inode, &clu)) return -EIO;
/* * We don't return -EPERM here. Yes, strange, but this is too * old behavior.
*/ if (attr->ia_valid & ATTR_MODE) { if (exfat_sanitize_mode(sbi, inode, &attr->ia_mode) < 0)
attr->ia_valid &= ~ATTR_MODE;
}
if (attr->ia_valid & ATTR_SIZE)
inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
/* * __exfat_write_inode() is called from exfat_truncate(), inode * is already written by it, so mark_inode_dirty() is unneeded.
*/
exfat_truncate(inode);
up_write(&EXFAT_I(inode)->truncate_lock);
} else
mark_inode_dirty(inode);
out: return error;
}
/* * modified ioctls from fat/file.c by Welmer Almesberger
*/ staticint exfat_ioctl_get_attributes(struct inode *inode, u32 __user *user_attr)
{
u32 attr;
/* * The security check is questionable... We single * out the RO attribute for checking by the security * module, just because it maps to a file mode.
*/
err = security_inode_setattr(file_mnt_idmap(file),
file->f_path.dentry, &ia); if (err) goto out_unlock_inode;
/* This MUST be done before doing anything irreversible... */
err = exfat_setattr(file_mnt_idmap(file), file->f_path.dentry, &ia); if (err) goto out_unlock_inode;
if (!IS_ALIGNED(align, i_blocksize(inode)) &&
!IS_ALIGNED(align, bdev_logical_block_size(inode->i_sb->s_bdev))) {
ret = -EINVAL; goto unlock;
}
}
if (pos > valid_size) {
ret = exfat_extend_valid_size(inode, pos); if (ret < 0 && ret != -ENOSPC) {
exfat_err(inode->i_sb, "write: fail to zero from %llu to %llu(%zd)",
valid_size, pos, ret);
} if (ret < 0) goto unlock;
}
ret = __generic_file_write_iter(iocb, iter); if (ret < 0) goto unlock;
inode_unlock(inode);
if (pos > valid_size)
pos = valid_size;
if (iocb->ki_pos > pos) {
ssize_t err = generic_write_sync(iocb, iocb->ki_pos - pos); if (err < 0) return err;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.