資源簡介
包含完整的ext4文件系統的源代碼,提供給大家學習和參考。

代碼片段和文件信息
/*
?*?linux/fs/ext4/acl.c
?*
?*?Copyright?(C)?2001-2003?Andreas?Gruenbacher?
?*/
#include?
#include?
#include?
#include?
#include?
#include?“ext4_jbd2.h“
#include?“ext4.h“
#include?“xattr.h“
#include?“acl.h“
/*
?*?Convert?from?filesystem?to?in-memory?representation.
?*/
static?struct?posix_acl?*
ext4_acl_from_disk(const?void?*value?size_t?size)
{
const?char?*end?=?(char?*)value?+?size;
int?n?count;
struct?posix_acl?*acl;
if?(!value)
return?NULL;
if?(size? ?return?ERR_PTR(-EINVAL);
if?(((ext4_acl_header?*)value)->a_version?!=
????cpu_to_le32(EXT4_ACL_VERSION))
return?ERR_PTR(-EINVAL);
value?=?(char?*)value?+?sizeof(ext4_acl_header);
count?=?ext4_acl_count(size);
if?(count?0)
return?ERR_PTR(-EINVAL);
if?(count?==?0)
return?NULL;
acl?=?posix_acl_alloc(count?GFP_NOFS);
if?(!acl)
return?ERR_PTR(-ENOMEM);
for?(n?=?0;?n? ext4_acl_entry?*entry?=
(ext4_acl_entry?*)value;
if?((char?*)value?+?sizeof(ext4_acl_entry_short)?>?end)
goto?fail;
acl->a_entries[n].e_tag??=?le16_to_cpu(entry->e_tag);
acl->a_entries[n].e_perm?=?le16_to_cpu(entry->e_perm);
switch?(acl->a_entries[n].e_tag)?{
case?ACL_USER_OBJ:
case?ACL_GROUP_OBJ:
case?ACL_MASK:
case?ACL_OTHER:
value?=?(char?*)value?+
sizeof(ext4_acl_entry_short);
acl->a_entries[n].e_id?=?ACL_UNDEFINED_ID;
break;
case?ACL_USER:
case?ACL_GROUP:
value?=?(char?*)value?+?sizeof(ext4_acl_entry);
if?((char?*)value?>?end)
goto?fail;
acl->a_entries[n].e_id?=
le32_to_cpu(entry->e_id);
break;
default:
goto?fail;
}
}
if?(value?!=?end)
goto?fail;
return?acl;
fail:
posix_acl_release(acl);
return?ERR_PTR(-EINVAL);
}
/*
?*?Convert?from?in-memory?to?filesystem?representation.
?*/
static?void?*
ext4_acl_to_disk(const?struct?posix_acl?*acl?size_t?*size)
{
ext4_acl_header?*ext_acl;
char?*e;
size_t?n;
*size?=?ext4_acl_size(acl->a_count);
ext_acl?=?kmalloc(sizeof(ext4_acl_header)?+?acl->a_count?*
sizeof(ext4_acl_entry)?GFP_NOFS);
if?(!ext_acl)
return?ERR_PTR(-ENOMEM);
ext_acl->a_version?=?cpu_to_le32(EXT4_ACL_VERSION);
e?=?(char?*)ext_acl?+?sizeof(ext4_acl_header);
for?(n?=?0;?n?a_count;?n++)?{
ext4_acl_entry?*entry?=?(ext4_acl_entry?*)e;
entry->e_tag??=?cpu_to_le16(acl->a_entries[n].e_tag);
entry->e_perm?=?cpu_to_le16(acl->a_entries[n].e_perm);
switch?(acl->a_entries[n].e_tag)?{
case?ACL_USER:
case?ACL_GROUP:
entry->e_id?=?cpu_to_le32(acl->a_entries[n].e_id);
e?+=?sizeof(ext4_acl_entry);
break;
case?ACL_USER_OBJ:
case?ACL_GROUP_OBJ:
case?ACL_MASK:
case?ACL_OTHER:
e?+=?sizeof(ext4_acl_entry_short);
break;
default:
goto?fail;
}
}
return?(char?*)ext_acl;
fail:
kfree(ext_acl);
return?ERR_PTR(-EINVAL);
}
/*
?*?Inode?operation?get_posix_acl().
?*
?*?inode->i_mutex:?don‘t?care
?*/
static?struct?posix_acl?*
ext4_get_acl(struct?inode
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????11293??2012-10-08?05:41??ext4\acl.c
?????文件???????1543??2012-10-08?05:41??ext4\acl.h
?????文件??????22744??2012-10-08?05:41??ext4\balloc.c
?????文件????????672??2012-10-08?05:41??ext4\bitmap.c
?????文件???????6193??2012-10-08?05:41??ext4\block_validity.c
?????文件??????14032??2012-10-08?05:41??ext4\dir.c
?????文件??????67403??2012-10-08?05:41??ext4\ext4.h
?????文件???????8794??2012-10-08?05:41??ext4\ext4_extents.h
?????文件???????2355??2012-10-08?05:41??ext4\ext4_jbd2.c
?????文件??????10124??2012-10-08?05:41??ext4\ext4_jbd2.h
?????文件?????103877??2012-10-08?05:41??ext4\extents.c
?????文件???????4492??2012-10-08?05:41??ext4\file.c
?????文件???????4332??2012-10-08?05:41??ext4\fsync.c
?????文件???????4448??2012-10-08?05:41??ext4\hash.c
?????文件??????34683??2012-10-08?05:41??ext4\ialloc.c
?????文件?????175966??2012-10-08?05:41??ext4\inode.c
?????文件???????9723??2012-10-08?05:41??ext4\ioctl.c
?????文件???????2544??2012-10-08?05:41??ext4\Kconfig
?????文件????????452??2012-10-08?05:41??ext4\Makefile
?????文件?????129308??2012-10-08?05:41??ext4\mballoc.c
?????文件???????5873??2012-10-08?05:41??ext4\mballoc.h
?????文件??????15559??2012-10-08?05:41??ext4\migrate.c
?????文件??????41727??2012-10-08?05:41??ext4\move_extent.c
?????文件??????71324??2012-10-08?05:41??ext4\namei.c
?????文件??????34936??2012-10-08?05:41??ext4\resize.c
?????文件?????116013??2012-10-08?05:41??ext4\super.c
?????文件???????1338??2012-10-08?05:41??ext4\symli
?????文件??????43076??2012-10-08?05:41??ext4\xattr.c
?????文件???????4387??2012-10-08?05:41??ext4\xattr.h
?????文件???????1837??2012-10-08?05:41??ext4\xattr_security.c
............此處省略6個文件信息
- 上一篇:12864液晶的Stm32f103驅動
- 下一篇:pid算法-arduino
評論
共有 條評論