本文整理汇总了C++中EXT2_I函数的典型用法代码示例。如果您正苦于以下问题:C++ EXT2_I函数的具体用法?C++ EXT2_I怎么用?C++ EXT2_I使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EXT2_I函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ext2_clear_inode
static void ext2_clear_inode(struct inode *inode)
{
struct ext2_block_alloc_info *rsv = EXT2_I(inode)->i_block_alloc_info;
ext2_discard_reservation(inode);
EXT2_I(inode)->i_block_alloc_info = NULL;
if (unlikely(rsv))
kfree(rsv);
}
示例2: ext2_release_file
/*
* Called when filp is released. This happens when all file descriptors
* for a single struct file are closed. Note that different open() calls
* for the same file yield different struct file structures.
*/
static int ext2_release_file (struct inode * inode, struct file * filp)
{
if (filp->f_mode & FMODE_WRITE) {
mutex_lock(&EXT2_I(inode)->truncate_mutex);
ext2_discard_reservation(inode);
mutex_unlock(&EXT2_I(inode)->truncate_mutex);
}
return 0;
}
示例3: do_immediate_write
/*
* COMP3301 Addition
* Write immediate files data to the inode. Covert back to
* Regular files when the data exceeds the limit.
*/
ssize_t do_immediate_write (struct file* flip, const char __user* buf,
size_t len, loff_t *ppos, int need_to_encrypt) {
struct ext2_inode_info *inode_info = EXT2_I(flip->f_dentry->d_inode);
struct inode *inode = flip->f_dentry->d_inode;
char *data = (char *)inode_info->i_data;
char *copy;
char *ext_inode_data = (char *) (EXT2_I(inode)->i_data);
int err;
ssize_t result;
if (*ppos + len >= IMMEDIATE_FILE_SIZE) {
// Convert to regular file
copy = (char *) kmalloc(sizeof(char) * strlen(ext_inode_data)
+ 1, GFP_KERNEL);
memset(copy, 0, strlen(ext_inode_data) + 1);
memcpy(copy, ext_inode_data, strlen(ext_inode_data));
copy[strlen(ext_inode_data)] = 0;
inode->i_mode &= ~(S_IF_IMMEDIATE & S_IFMT);
inode->i_mode |= S_IFREG & S_IFMT;
inode_info->i_data[0] = ext2_new_block(inode, 0, &err);
mark_inode_dirty(inode);
flip->f_pos = 0;
result = write_encrypt(flip, copy, strlen(copy), &flip->f_pos);
result = write_encrypt(flip, buf, len, ppos);
kfree(copy);
return result;
}
if (need_to_encrypt) {
encrypt(buf, len);
}
if (copy_from_user(data + *ppos, buf, len)) {
return -1;
}
*ppos += len;
flip->f_pos = *ppos;
inode->i_size += len;
mark_inode_dirty(inode);
return len;
}
示例4: ext2_get_acl
/*
* inode->i_sem: don't care
*/
static struct posix_acl *
ext2_get_acl(struct inode *inode, int type)
{
struct ext2_inode_info *ei = EXT2_I(inode);
int name_index;
char *value = NULL;
struct posix_acl *acl;
int retval;
if (!test_opt(inode->i_sb, POSIX_ACL))
return 0;
switch(type) {
case ACL_TYPE_ACCESS:
acl = ext2_iget_acl(inode, &ei->i_acl);
if (acl != EXT2_ACL_NOT_CACHED)
return acl;
name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS;
break;
case ACL_TYPE_DEFAULT:
acl = ext2_iget_acl(inode, &ei->i_default_acl);
if (acl != EXT2_ACL_NOT_CACHED)
return acl;
name_index = EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT;
break;
default:
return ERR_PTR(-EINVAL);
}
retval = ext2_xattr_get(inode, name_index, "", NULL, 0);
if (retval > 0) {
value = kmalloc(retval, GFP_KERNEL);
if (!value)
return ERR_PTR(-ENOMEM);
retval = ext2_xattr_get(inode, name_index, "", value, retval);
}
if (retval > 0)
acl = ext2_acl_from_disk(value, retval);
else if (retval == -ENODATA || retval == -ENOSYS)
acl = NULL;
else
acl = ERR_PTR(retval);
if (value)
kfree(value);
if (!IS_ERR(acl)) {
switch(type) {
case ACL_TYPE_ACCESS:
ext2_iset_acl(inode, &ei->i_acl, acl);
break;
case ACL_TYPE_DEFAULT:
ext2_iset_acl(inode, &ei->i_default_acl, acl);
break;
}
}
return acl;
}
示例5: ext2_symlink
static int ext2_symlink (struct inode * dir, struct dentry * dentry,
const char * symname)
{
struct super_block * sb = dir->i_sb;
int err = -ENAMETOOLONG;
unsigned l = strlen(symname)+1;
struct inode * inode;
if (l > sb->s_blocksize)
goto out;
dquot_initialize(dir);
inode = ext2_new_inode (dir, S_IFLNK | S_IRWXUGO, &dentry->d_name);
err = PTR_ERR(inode);
if (IS_ERR(inode))
goto out;
if (l > sizeof (EXT2_I(inode)->i_data)) {
/* slow symlink */
inode->i_op = &ext2_symlink_inode_operations;
if (test_opt(inode->i_sb, NOBH))
inode->i_mapping->a_ops = &ext2_nobh_aops;
else
inode->i_mapping->a_ops = &ext2_aops;
err = page_symlink(inode, symname, l);
if (err)
goto out_fail;
} else {
/* fast symlink */
inode->i_op = &ext2_fast_symlink_inode_operations;
memcpy((char*)(EXT2_I(inode)->i_data),symname,l);
inode->i_size = l-1;
}
mark_inode_dirty(inode);
err = ext2_add_nondir(dentry, inode);
out:
return err;
out_fail:
inode_dec_link_count(inode);
unlock_new_inode(inode);
iput (inode);
goto out;
}
示例6: ext2_clear_inode
static void ext2_clear_inode(struct inode *inode)
{
struct ext2_block_alloc_info *rsv = EXT2_I(inode)->i_block_alloc_info;
#ifdef CONFIG_EXT2_FS_POSIX_ACL
struct ext2_inode_info *ei = EXT2_I(inode);
if (ei->i_acl && ei->i_acl != EXT2_ACL_NOT_CACHED) {
posix_acl_release(ei->i_acl);
ei->i_acl = EXT2_ACL_NOT_CACHED;
}
if (ei->i_default_acl && ei->i_default_acl != EXT2_ACL_NOT_CACHED) {
posix_acl_release(ei->i_default_acl);
ei->i_default_acl = EXT2_ACL_NOT_CACHED;
}
#endif
ext2_discard_reservation(inode);
EXT2_I(inode)->i_block_alloc_info = NULL;
if (unlikely(rsv))
kfree(rsv);
}
示例7: ext2_evict_inode
/*
* Called at the last iput() if i_nlink is zero.
*/
void ext2_evict_inode(struct inode * inode)
{
struct ext2_block_alloc_info *rsv;
int want_delete = 0;
if (!inode->i_nlink && !is_bad_inode(inode)) {
want_delete = 1;
dquot_initialize(inode);
} else {
dquot_drop(inode);
}
truncate_inode_pages_final(&inode->i_data);
if (want_delete) {
sb_start_intwrite(inode->i_sb);
/* set dtime */
EXT2_I(inode)->i_dtime = get_seconds();
mark_inode_dirty(inode);
__ext2_write_inode(inode, inode_needs_sync(inode));
/* truncate to 0 */
inode->i_size = 0;
if (inode->i_blocks)
ext2_truncate_blocks(inode, 0);
ext2_xattr_delete_inode(inode);
}
invalidate_inode_buffers(inode);
clear_inode(inode);
ext2_discard_reservation(inode);
rsv = EXT2_I(inode)->i_block_alloc_info;
EXT2_I(inode)->i_block_alloc_info = NULL;
if (unlikely(rsv))
kfree(rsv);
if (want_delete) {
ext2_free_inode(inode);
sb_end_intwrite(inode->i_sb);
}
}
示例8: ext2bp_debug
// Vijay: Modified lookup for ext2bp. This includes a validation check inside it.
static struct dentry *ext2bp_lookup(struct inode * dir, struct dentry *dentry, struct nameidata *nd)
{
ext2bp_debug("Inside ext2bp_lookup for dir with inode num: %lu\n", dir->i_ino);
struct inode * inode;
ino_t ino;
if (dentry->d_name.len > EXT2_NAME_LEN)
return ERR_PTR(-ENAMETOOLONG);
ino = ext2_inode_by_name(dir, dentry);
inode = NULL;
if (ino) {
inode = ext2_iget(dir->i_sb, ino);
if (IS_ERR(inode))
return ERR_CAST(inode);
// Check the inode state
if (inode->i_state & I_DIRTY)
ext2bp_debug("Inode's state: dirty\n");
if (inode->i_state & I_NEW)
ext2bp_debug("Inode's state: new\n");
if (inode->i_state & I_LOCK)
ext2bp_debug("Inode's state: locked\n");
if (inode->i_state & I_CLEAR)
ext2bp_debug("Inode's state: clear\n");
if (inode->i_state & I_SYNC)
ext2bp_debug("Inode's state: sync\n");
ext2bp_debug("Inode's state: something I didnt check for\n");
// Now that we have the child inode, we can
// carry out the check.
struct ext2_inode_info *ei = EXT2_I(inode);
int n;
int backlink_present = 0;
for (n=0; n < EXT2_N_LINKS; n++)
if (ei->i_backlinks[n] == dir->i_ino) {
backlink_present = 1;
ext2bp_debug("Found backlink from %lu to %lu\n", inode->i_ino, dir->i_ino);
break;
}
if (!backlink_present) {
printk("Vijay:Error:Did not find backlink from %lu to %lu\n", inode->i_ino, dir->i_ino);
iput(inode);
return ERR_PTR(-EIO);
}
}
return d_splice_alias(inode, dentry);
}
示例9: ext2_clear_inode
static void ext2_clear_inode(struct inode *inode)
{
#ifdef CONFIG_EXT2_FS_POSIX_ACL
struct ext2_inode_info *ei = EXT2_I(inode);
if (ei->i_acl && ei->i_acl != EXT2_ACL_NOT_CACHED) {
posix_acl_release(ei->i_acl);
ei->i_acl = EXT2_ACL_NOT_CACHED;
}
if (ei->i_default_acl && ei->i_default_acl != EXT2_ACL_NOT_CACHED) {
posix_acl_release(ei->i_default_acl);
ei->i_default_acl = EXT2_ACL_NOT_CACHED;
}
#endif
}
示例10: ext2_discard_prealloc
void ext2_discard_prealloc (struct inode * inode)
{
#ifdef EXT2_PREALLOCATE
struct ext2_inode_info *ei = EXT2_I(inode);
write_lock(&ei->i_meta_lock);
if (ei->i_prealloc_count) {
unsigned short total = ei->i_prealloc_count;
unsigned long block = ei->i_prealloc_block;
ei->i_prealloc_count = 0;
ei->i_prealloc_block = 0;
write_unlock(&ei->i_meta_lock);
ext2_free_blocks (inode, block, total);
return;
} else
write_unlock(&ei->i_meta_lock);
#endif
}
示例11: ext2_delete_inode
/*
* Called at the last iput() if i_nlink is zero.
*/
void ext2_delete_inode (struct inode * inode)
{
if (is_bad_inode(inode))
goto no_delete;
EXT2_I(inode)->i_dtime = get_seconds();
mark_inode_dirty(inode);
ext2_update_inode(inode, inode_needs_sync(inode));
inode->i_size = 0;
if (inode->i_blocks)
ext2_truncate (inode);
ext2_free_inode (inode);
return;
no_delete:
clear_inode(inode); /* We must guarantee clearing of inode... */
}
示例12: ext2_unlink
static int ext2_unlink(struct inode * dir, struct dentry *dentry)
{
struct inode * inode = dentry->d_inode;
struct ext2_dir_entry_2 * de;
struct page * page;
int err = -ENOENT;
de = ext2_find_entry (dir, dentry, &page);
if (!de)
goto out;
err = ext2_delete_entry (de, page);
if (err)
goto out;
inode->i_ctime = dir->i_ctime;
// Removing the backlink from the inode
ext2bp_debug("Removing backlink from the inode\n");
int i, link_pos = -1;
struct ext2_inode_info *ei = EXT2_I(inode);
for(i=0; i < inode->i_nlink; i++) {
if (ei->i_backlinks[i] == dir->i_ino) {
link_pos = i;
ext2bp_debug("Found backlink to inode %d at position %d\n", dir->i_ino, i);
break;
}
}
// If we find the backlink, remove it and move the other
// backlinks up a bit.
if (link_pos != -1) {
for(i=link_pos; i < (EXT2_N_LINKS - 1); i++) {
ei->i_backlinks[i] = ei->i_backlinks[i+1];
}
}
mark_inode_dirty(inode);
inode_dec_link_count(inode);
err = 0;
out:
return err;
}
示例13: ext2_dax_fault
/*
* The lock ordering for ext2 DAX fault paths is:
*
* mmap_sem (MM)
* sb_start_pagefault (vfs, freeze)
* ext2_inode_info->dax_sem
* address_space->i_mmap_rwsem or page_lock (mutually exclusive in DAX)
* ext2_inode_info->truncate_mutex
*
* The default page_lock and i_size verification done by non-DAX fault paths
* is sufficient because ext2 doesn't support hole punching.
*/
static vm_fault_t ext2_dax_fault(struct vm_fault *vmf)
{
struct inode *inode = file_inode(vmf->vma->vm_file);
struct ext2_inode_info *ei = EXT2_I(inode);
vm_fault_t ret;
if (vmf->flags & FAULT_FLAG_WRITE) {
sb_start_pagefault(inode->i_sb);
file_update_time(vmf->vma->vm_file);
}
down_read(&ei->dax_sem);
ret = dax_iomap_fault(vmf, PE_SIZE_PTE, NULL, NULL, &ext2_iomap_ops);
up_read(&ei->dax_sem);
if (vmf->flags & FAULT_FLAG_WRITE)
sb_end_pagefault(inode->i_sb);
return ret;
}
示例14: ext2_dax_fault
/*
* The lock ordering for ext2 DAX fault paths is:
*
* mmap_sem (MM)
* sb_start_pagefault (vfs, freeze)
* ext2_inode_info->dax_sem
* address_space->i_mmap_rwsem or page_lock (mutually exclusive in DAX)
* ext2_inode_info->truncate_mutex
*
* The default page_lock and i_size verification done by non-DAX fault paths
* is sufficient because ext2 doesn't support hole punching.
*/
static int ext2_dax_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
{
struct inode *inode = file_inode(vma->vm_file);
struct ext2_inode_info *ei = EXT2_I(inode);
int ret;
if (vmf->flags & FAULT_FLAG_WRITE) {
sb_start_pagefault(inode->i_sb);
file_update_time(vma->vm_file);
}
down_read(&ei->dax_sem);
ret = __dax_fault(vma, vmf, ext2_get_block, NULL);
up_read(&ei->dax_sem);
if (vmf->flags & FAULT_FLAG_WRITE)
sb_end_pagefault(inode->i_sb);
return ret;
}
示例15: ext2_dax_pmd_fault
static int ext2_dax_pmd_fault(struct vm_area_struct *vma, unsigned long addr,
pmd_t *pmd, unsigned int flags)
{
struct inode *inode = file_inode(vma->vm_file);
struct ext2_inode_info *ei = EXT2_I(inode);
int ret;
if (flags & FAULT_FLAG_WRITE) {
sb_start_pagefault(inode->i_sb);
file_update_time(vma->vm_file);
}
down_read(&ei->dax_sem);
ret = __dax_pmd_fault(vma, addr, pmd, flags, ext2_get_block, NULL);
up_read(&ei->dax_sem);
if (flags & FAULT_FLAG_WRITE)
sb_end_pagefault(inode->i_sb);
return ret;
}