本文整理汇总了C++中HFS_I函数的典型用法代码示例。如果您正苦于以下问题:C++ HFS_I函数的具体用法?C++ HFS_I怎么用?C++ HFS_I使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HFS_I函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: build_key
/*
* build_key()
*
* Build a key for a file by the given name in the given directory.
* If the name matches one of the reserved names returns 1 otherwise 0.
*/
static int build_key(struct hfs_cat_key *key, struct inode *dir,
const char *name, int len)
{
struct hfs_name cname;
const struct hfs_name *reserved;
/* mangle the name */
hfs_nameout(dir, &cname, name, len);
/* check against reserved names */
reserved = HFS_SB(dir->i_sb)->s_reserved1;
while (reserved->Len) {
if (hfs_streq(reserved, &cname)) {
return 1;
}
++reserved;
}
/* check against the names reserved only in the root directory */
if (HFS_I(dir)->entry->cnid == htonl(HFS_ROOT_CNID)) {
reserved = HFS_SB(dir->i_sb)->s_reserved2;
while (reserved->Len) {
if (hfs_streq(reserved, &cname)) {
return 1;
}
++reserved;
}
}
/* build the key */
hfs_cat_build_key(HFS_I(dir)->entry->cnid, &cname, key);
return 0;
}
示例2: init_file_inode
/*
* init_file_inode()
*
* Given an HFS catalog entry initialize an inode for a file.
*/
static void init_file_inode(struct inode *inode, hfs_u8 fork)
{
struct hfs_fork *fk;
struct hfs_cat_entry *entry = HFS_I(inode)->entry;
if (fork == HFS_FK_DATA) {
inode->i_mode = S_IRWXUGO | S_IFREG;
} else {
inode->i_mode = S_IRUGO | S_IWUGO | S_IFREG;
}
if (fork == HFS_FK_DATA) {
#if 0 /* XXX: disable crlf translations for now */
hfs_u32 type = hfs_get_nl(entry->info.file.finfo.fdType);
HFS_I(inode)->convert =
((HFS_SB(inode->i_sb)->s_conv == 't') ||
((HFS_SB(inode->i_sb)->s_conv == 'a') &&
((type == htonl(0x54455854)) || /* "TEXT" */
(type == htonl(0x7474726f))))); /* "ttro" */
#else
HFS_I(inode)->convert = 0;
#endif
fk = &entry->u.file.data_fork;
} else {
fk = &entry->u.file.rsrc_fork;
HFS_I(inode)->convert = 0;
}
HFS_I(inode)->fork = fk;
inode->i_size = fk->lsize;
inode->i_blocks = fk->psize;
inode->i_nlink = 1;
}
示例3: hfs_create
/*
* hfs_create()
*
* This is the create() entry in the inode_operations structure for
* regular HFS directories. The purpose is to create a new file in
* a directory and return a corresponding inode, given the inode for
* the directory and the name (and its length) of the new file.
*/
int hfs_create(struct inode * dir, const char * name, int len, int mode,
struct inode ** result)
{
struct hfs_cat_entry *entry = HFS_I(dir)->entry;
struct hfs_cat_entry *new;
struct hfs_cat_key key;
int error;
*result = NULL;
/* build the key, checking against reserved names */
if (build_key(&key, dir, name, len)) {
error = -EEXIST;
} else {
/* try to create the file */
error = hfs_cat_create(entry, &key,
(mode & S_IWUSR) ? 0 : HFS_FIL_LOCK,
HFS_SB(dir->i_sb)->s_type,
HFS_SB(dir->i_sb)->s_creator, &new);
}
if (!error) {
update_dirs_plus(entry, 0);
/* create an inode for the new file */
*result = __hfs_iget(new, HFS_I(dir)->file_type, 0);
if (!(*result)) {
/* XXX correct error? */
error = -EIO;
}
}
示例4: HFS_I
/*
* cap_lookup()
*
* This is the lookup() entry in the inode_operations structure for
* HFS directories in the CAP scheme. The purpose is to generate the
* inode corresponding to an entry in a directory, given the inode for
* the directory and the name (and its length) of the entry.
*/
static struct dentry *cap_lookup(struct inode * dir, struct dentry *dentry)
{
ino_t dtype;
struct hfs_name cname;
struct hfs_cat_entry *entry;
struct hfs_cat_key key;
struct inode *inode = NULL;
dentry->d_op = &hfs_dentry_operations;
entry = HFS_I(dir)->entry;
dtype = HFS_ITYPE(dir->i_ino);
/* Perform name-mangling */
hfs_nameout(dir, &cname, dentry->d_name.name,
dentry->d_name.len);
/* no need to check for "." or ".." */
/* Check for special directories if in a normal directory.
Note that cap_dupdir() does an iput(dir). */
if (dtype==HFS_CAP_NDIR) {
/* Check for ".resource", ".finderinfo" and ".rootinfo" */
if (hfs_streq(cname.Name, cname.Len,
DOT_RESOURCE->Name, DOT_RESOURCE_LEN)) {
++entry->count; /* __hfs_iget() eats one */
inode = hfs_iget(entry, HFS_CAP_RDIR, dentry);
goto done;
} else if (hfs_streq(cname.Name, cname.Len,
DOT_FINDERINFO->Name,
DOT_FINDERINFO_LEN)) {
++entry->count; /* __hfs_iget() eats one */
inode = hfs_iget(entry, HFS_CAP_FDIR, dentry);
goto done;
} else if ((entry->cnid == htonl(HFS_ROOT_CNID)) &&
hfs_streq(cname.Name, cname.Len,
DOT_ROOTINFO->Name, DOT_ROOTINFO_LEN)) {
++entry->count; /* __hfs_iget() eats one */
inode = hfs_iget(entry, HFS_CAP_FNDR, dentry);
goto done;
}
}
/* Do an hfs_iget() on the mangled name. */
hfs_cat_build_key(entry->cnid, &cname, &key);
inode = hfs_iget(hfs_cat_get(entry->mdb, &key),
HFS_I(dir)->file_type, dentry);
/* Don't return a resource fork for a directory */
if (inode && (dtype == HFS_CAP_RDIR) &&
(HFS_I(inode)->entry->type == HFS_CDR_DIR)) {
iput(inode); /* this does an hfs_cat_put */
inode = NULL;
}
done:
d_add(dentry, inode);
return NULL;
}
示例5: hfs_dir_release
static int hfs_dir_release(struct inode *inode, struct file *file)
{
struct hfs_readdir_data *rd = file->private_data;
if (rd) {
spin_lock(&HFS_I(inode)->open_dir_lock);
list_del(&rd->list);
spin_unlock(&HFS_I(inode)->open_dir_lock);
kfree(rd);
}
return 0;
}
示例6: hfs_put_inode
/*
* hfs_put_inode()
*
* This is the put_inode() entry in the super_operations for HFS
* filesystems. The purpose is to perform any filesystem-dependent
* cleanup necessary when the use-count of an inode falls to zero.
*/
void hfs_put_inode(struct inode * inode)
{
struct hfs_cat_entry *entry = HFS_I(inode)->entry;
hfs_cat_put(entry);
if (inode->i_count == 1) {
struct hfs_hdr_layout *tmp = HFS_I(inode)->layout;
if (tmp) {
HFS_I(inode)->layout = NULL;
HFS_DELETE(tmp);
}
}
}
示例7: hfs_put_inode
/*
* hfs_put_inode()
*
* This is the put_inode() entry in the super_operations for HFS
* filesystems. The purpose is to perform any filesystem-dependent
* cleanup necessary when the use-count of an inode falls to zero.
*/
void hfs_put_inode(struct inode * inode)
{
struct hfs_cat_entry *entry = HFS_I(inode)->entry;
lock_kernel();
hfs_cat_put(entry);
if (atomic_read(&inode->i_count) == 1) {
struct hfs_hdr_layout *tmp = HFS_I(inode)->layout;
if (tmp) {
HFS_I(inode)->layout = NULL;
HFS_DELETE(tmp);
}
}
unlock_kernel();
}
示例8: hfs_rename
/*
* hfs_rename()
*
* This is the rename() entry in the inode_operations structure for
* regular HFS directories. The purpose is to rename an existing
* file or directory, given the inode for the current directory and
* the name (and its length) of the existing file/directory and the
* inode for the new directory and the name (and its length) of the
* new file/directory.
* XXX: how do you handle must_be dir?
*/
static int hfs_rename(struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags)
{
int res;
if (flags & ~RENAME_NOREPLACE)
return -EINVAL;
/* Unlink destination if it already exists */
if (d_really_is_positive(new_dentry)) {
res = hfs_remove(new_dir, new_dentry);
if (res)
return res;
}
res = hfs_cat_move(d_inode(old_dentry)->i_ino,
old_dir, &old_dentry->d_name,
new_dir, &new_dentry->d_name);
if (!res)
hfs_cat_build_key(old_dir->i_sb,
(btree_key *)&HFS_I(d_inode(old_dentry))->cat_key,
new_dir->i_ino, &new_dentry->d_name);
return res;
}
示例9: nat_hdr_unlink
/*
* nat_hdr_unlink()
*
* This is the unlink() entry in the inode_operations structure for
* Netatalk .AppleDouble directories. The purpose is to delete an
* existing file, given the inode for the parent directory and the name
* (and its length) of the existing file.
*
* WE DON'T ACTUALLY DELETE HEADER THE FILE.
* In non-afpd-compatible mode:
* We return -EPERM.
* In afpd-compatible mode:
* We return success if the file exists or is .Parent.
* Otherwise we return -ENOENT.
*/
static int nat_hdr_unlink(struct inode *dir, const char *name, int len)
{
struct hfs_cat_entry *entry = HFS_I(dir)->entry;
int error = 0;
if (!HFS_SB(dir->i_sb)->s_afpd) {
/* Not in AFPD compatibility mode */
error = -EPERM;
} else {
struct hfs_name cname;
hfs_nameout(dir, &cname, name, len);
if (!hfs_streq(&cname, DOT_PARENT)) {
struct hfs_cat_entry *victim;
struct hfs_cat_key key;
hfs_cat_build_key(entry->cnid, &cname, &key);
victim = hfs_cat_get(entry->mdb, &key);
if (victim) {
/* pretend to succeed */
hfs_cat_put(victim);
} else {
error = -ENOENT;
}
}
}
iput(dir);
return error;
}
示例10: cap_info_read
/*
* cap_info_read()
*
* This is the read() entry in the file_operations structure for CAP
* metadata files. The purpose is to transfer up to 'count' bytes
* from the file corresponding to 'inode' beginning at offset
* 'file->f_pos' to user-space at the address 'buf'. The return value
* is the number of bytes actually transferred.
*/
static hfs_rwret_t cap_info_read(struct file *filp, char *buf,
hfs_rwarg_t count, loff_t *ppos)
{
struct inode *inode = filp->f_dentry->d_inode;
struct hfs_cat_entry *entry = HFS_I(inode)->entry;
hfs_s32 left, size, read = 0;
hfs_u32 pos;
if (!S_ISREG(inode->i_mode)) {
hfs_warn("hfs_cap_info_read: mode = %07o\n", inode->i_mode);
return -EINVAL;
}
pos = *ppos;
if (pos > HFS_FORK_MAX) {
return 0;
}
size = inode->i_size;
if (pos > size) {
left = 0;
} else {
left = size - pos;
}
if (left > count) {
left = count;
}
if (left <= 0) {
return 0;
}
if (pos < sizeof(struct hfs_cap_info)) {
int memcount = sizeof(struct hfs_cap_info) - pos;
struct hfs_cap_info meta;
if (memcount > left) {
memcount = left;
}
cap_build_meta(&meta, entry);
memcount -= copy_to_user(buf, ((char *)&meta) + pos, memcount);
left -= memcount;
read += memcount;
pos += memcount;
buf += memcount;
}
if (left > 0) {
clear_user(buf, left);
pos += left;
}
if (read) {
inode->i_atime = CURRENT_TIME;
*ppos = pos;
mark_inode_dirty(inode);
}
return read;
}
示例11: hfs_revalidate_dentry
static int hfs_revalidate_dentry(struct dentry *dentry, struct nameidata *nd)
{
struct inode *inode = dentry->d_inode;
int diff;
if(!inode)
return 1;
/* fix up inode on a timezone change */
diff = sys_tz.tz_minuteswest * 60 - HFS_I(inode)->tz_secondswest;
if (diff) {
inode->i_ctime.tv_sec += diff;
inode->i_atime.tv_sec += diff;
inode->i_mtime.tv_sec += diff;
HFS_I(inode)->tz_secondswest += diff;
}
return 1;
}
示例12: hfs_write_begin
static int hfs_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
{
*pagep = NULL;
return cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
hfs_get_block,
&HFS_I(mapping->host)->phys_size);
}
示例13: hfs_dbl_ifill
/*
* hfs_dbl_ifill()
*
* This function serves the same purpose as a read_inode() function does
* in other filesystems. It is called by __hfs_iget() to fill in
* the missing fields of an uninitialized inode under the AppleDouble
* scheme.
*/
void hfs_dbl_ifill(struct inode * inode, ino_t type, const int version)
{
struct hfs_cat_entry *entry = HFS_I(inode)->entry;
HFS_I(inode)->d_drop_op = hfs_dbl_drop_dentry;
if (type == HFS_DBL_HDR) {
if (entry->type == HFS_CDR_FIL) {
init_file_inode(inode, HFS_FK_RSRC);
inode->i_size += HFS_DBL_HDR_LEN;
HFS_I(inode)->default_layout = &hfs_dbl_fil_hdr_layout;
} else {
inode->i_size = HFS_DBL_HDR_LEN;
inode->i_mode = S_IRUGO | S_IWUGO | S_IFREG;
inode->i_nlink = 1;
HFS_I(inode)->default_layout = &hfs_dbl_dir_hdr_layout;
}
inode->i_op = &hfs_hdr_inode_operations;
} else if (entry->type == HFS_CDR_FIL) {
init_file_inode(inode, HFS_FK_DATA);
inode->i_op = &hfs_file_inode_operations;
} else { /* Directory */
struct hfs_dir *hdir = &entry->u.dir;
inode->i_blocks = 0;
inode->i_nlink = hdir->dirs + 2;
inode->i_size = 3 + 2 * (hdir->dirs + hdir->files);
inode->i_mode = S_IRWXUGO | S_IFDIR;
inode->i_op = &hfs_dbl_dir_inode_operations;
HFS_I(inode)->file_type = HFS_DBL_NORM;
HFS_I(inode)->dir_size = 2;
}
}
示例14: cap_info_write
/*
* cap_info_write()
*
* This is the write() entry in the file_operations structure for CAP
* metadata files. The purpose is to transfer up to 'count' bytes
* to the file corresponding to 'inode' beginning at offset
* '*ppos' from user-space at the address 'buf'.
* The return value is the number of bytes actually transferred.
*/
static hfs_rwret_t cap_info_write(struct file *filp, const char *buf,
hfs_rwarg_t count, loff_t *ppos)
{
struct inode *inode = filp->f_dentry->d_inode;
hfs_u32 pos;
if (!S_ISREG(inode->i_mode)) {
hfs_warn("hfs_file_write: mode = %07o\n", inode->i_mode);
return -EINVAL;
}
if (count <= 0) {
return 0;
}
pos = (filp->f_flags & O_APPEND) ? inode->i_size : *ppos;
if (pos > HFS_FORK_MAX) {
return 0;
}
*ppos += count;
if (*ppos > HFS_FORK_MAX) {
*ppos = HFS_FORK_MAX;
count = HFS_FORK_MAX - pos;
}
if (*ppos > inode->i_size)
inode->i_size = *ppos;
/* Only deal with the part we store in memory */
if (pos < sizeof(struct hfs_cap_info)) {
int end, mem_count;
struct hfs_cat_entry *entry = HFS_I(inode)->entry;
struct hfs_cap_info meta;
mem_count = sizeof(struct hfs_cap_info) - pos;
if (mem_count > count) {
mem_count = count;
}
end = pos + mem_count;
cap_build_meta(&meta, entry);
mem_count -= copy_from_user(((char *)&meta) + pos, buf, mem_count);
/* Update finder attributes if changed */
if (OVERLAPS(pos, end, struct hfs_cap_info, fi_fndr)) {
memcpy(&entry->info, meta.fi_fndr, 32);
hfs_cat_mark_dirty(entry);
}
示例15: __hfs_getxattr
static ssize_t __hfs_getxattr(struct inode *inode, enum hfs_xattr_type type,
void *value, size_t size)
{
struct hfs_find_data fd;
hfs_cat_rec rec;
struct hfs_cat_file *file;
ssize_t res = 0;
if (!S_ISREG(inode->i_mode) || HFS_IS_RSRC(inode))
return -EOPNOTSUPP;
if (size) {
res = hfs_find_init(HFS_SB(inode->i_sb)->cat_tree, &fd);
if (res)
return res;
fd.search_key->cat = HFS_I(inode)->cat_key;
res = hfs_brec_find(&fd);
if (res)
goto out;
hfs_bnode_read(fd.bnode, &rec, fd.entryoffset,
sizeof(struct hfs_cat_file));
}
file = &rec.file;
switch (type) {
case HFS_TYPE:
if (size >= 4) {
memcpy(value, &file->UsrWds.fdType, 4);
res = 4;
} else
res = size ? -ERANGE : 4;
break;
case HFS_CREATOR:
if (size >= 4) {
memcpy(value, &file->UsrWds.fdCreator, 4);
res = 4;
} else
res = size ? -ERANGE : 4;
break;
}
out:
if (size)
hfs_find_exit(&fd);
return res;
}