本文整理汇总了C++中CODA_FTOC函数的典型用法代码示例。如果您正苦于以下问题:C++ CODA_FTOC函数的具体用法?C++ CODA_FTOC怎么用?C++ CODA_FTOC使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CODA_FTOC函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: coda_file_mmap
static int
coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma)
{
struct coda_file_info *cfi;
struct coda_inode_info *cii;
struct file *host_file;
struct inode *coda_inode, *host_inode;
cfi = CODA_FTOC(coda_file);
BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
host_file = cfi->cfi_container;
if (!host_file->f_op || !host_file->f_op->mmap)
return -ENODEV;
coda_inode = coda_file->f_path.dentry->d_inode;
host_inode = host_file->f_path.dentry->d_inode;
coda_file->f_mapping = host_file->f_mapping;
if (coda_inode->i_mapping == &coda_inode->i_data)
coda_inode->i_mapping = host_inode->i_mapping;
/* only allow additional mmaps as long as userspace isn't changing
* the container file on us! */
else if (coda_inode->i_mapping != host_inode->i_mapping)
return -EBUSY;
/* keep track of how often the coda_inode/host_file has been mmapped */
cii = ITOC(coda_inode);
cii->c_mapcount++;
cfi->cfi_mapcount++;
return host_file->f_op->mmap(host_file, vma);
}
示例2: coda_readdir
/* file operations for directories */
int coda_readdir(struct file *coda_file, void *dirent, filldir_t filldir)
{
struct dentry *coda_dentry = coda_file->f_dentry;
struct coda_file_info *cfi;
struct file *host_file;
int ret;
cfi = CODA_FTOC(coda_file);
if (!cfi || cfi->cfi_magic != CODA_MAGIC) BUG();
host_file = cfi->cfi_container;
coda_vfs_stat.readdir++;
down(&host_file->f_dentry->d_inode->i_sem);
host_file->f_pos = coda_file->f_pos;
if ( !host_file->f_op->readdir ) {
/* Venus: we must read Venus dirents from the file */
ret = coda_venus_readdir(host_file, filldir, dirent, coda_dentry);
} else {
/* potemkin case: we were handed a directory inode */
ret = vfs_readdir(host_file, filldir, dirent);
}
coda_file->f_pos = host_file->f_pos;
up(&host_file->f_dentry->d_inode->i_sem);
return ret;
}
示例3: coda_release
int coda_release(struct inode *coda_inode, struct file *coda_file)
{
unsigned short flags = (coda_file->f_flags) & (~O_EXCL);
unsigned short coda_flags = coda_flags_to_cflags(flags);
struct coda_file_info *cfi;
struct coda_inode_info *cii;
struct inode *host_inode;
int err;
cfi = CODA_FTOC(coda_file);
BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
err = venus_close(coda_inode->i_sb, coda_i2f(coda_inode),
coda_flags, coda_file->f_cred->fsuid);
host_inode = cfi->cfi_container->f_path.dentry->d_inode;
cii = ITOC(coda_inode);
/* did we mmap this file? */
spin_lock(&cii->c_lock);
if (coda_inode->i_mapping == &host_inode->i_data) {
cii->c_mapcount -= cfi->cfi_mapcount;
if (!cii->c_mapcount)
coda_inode->i_mapping = &coda_inode->i_data;
}
spin_unlock(&cii->c_lock);
fput(cfi->cfi_container);
kfree(coda_file->private_data);
coda_file->private_data = NULL;
/* VFS fput ignores the return value from file_operations->release, so
* there is no use returning an error here */
return 0;
}
示例4: coda_fsync
int coda_fsync(struct file *coda_file, struct dentry *coda_dentry, int datasync)
{
struct file *host_file;
struct dentry *host_dentry;
struct inode *host_inode, *coda_inode = coda_dentry->d_inode;
struct coda_file_info *cfi;
int err = 0;
if (!(S_ISREG(coda_inode->i_mode) || S_ISDIR(coda_inode->i_mode) ||
S_ISLNK(coda_inode->i_mode)))
return -EINVAL;
cfi = CODA_FTOC(coda_file);
if (!cfi || cfi->cfi_magic != CODA_MAGIC) BUG();
host_file = cfi->cfi_container;
coda_vfs_stat.fsync++;
if (host_file->f_op && host_file->f_op->fsync) {
host_dentry = host_file->f_dentry;
host_inode = host_dentry->d_inode;
down(&host_inode->i_sem);
err = host_file->f_op->fsync(host_file, host_dentry, datasync);
up(&host_inode->i_sem);
}
if ( !err && !datasync ) {
lock_kernel();
err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode));
unlock_kernel();
}
return err;
}
示例5: coda_file_write
static ssize_t
coda_file_write(struct file *coda_file, const char *buf, size_t count, loff_t *ppos)
{
struct inode *coda_inode = coda_file->f_dentry->d_inode;
struct coda_file_info *cfi;
struct file *host_file;
ssize_t ret;
cfi = CODA_FTOC(coda_file);
if (!cfi || cfi->cfi_magic != CODA_MAGIC) BUG();
host_file = cfi->cfi_container;
if (!host_file->f_op || !host_file->f_op->write)
return -EINVAL;
down(&coda_inode->i_sem);
ret = host_file->f_op->write(host_file, buf, count, ppos);
coda_inode->i_size = host_file->f_dentry->d_inode->i_size;
coda_inode->i_blocks = (coda_inode->i_size + 511) >> 9;
coda_inode->i_mtime = coda_inode->i_ctime = CURRENT_TIME;
up(&coda_inode->i_sem);
return ret;
}
示例6: coda_fsync
int coda_fsync(struct file *coda_file, loff_t start, loff_t end, int datasync)
{
struct file *host_file;
struct inode *coda_inode = coda_file->f_path.dentry->d_inode;
struct coda_file_info *cfi;
int err;
if (!(S_ISREG(coda_inode->i_mode) || S_ISDIR(coda_inode->i_mode) ||
S_ISLNK(coda_inode->i_mode)))
return -EINVAL;
err = filemap_write_and_wait_range(coda_inode->i_mapping, start, end);
if (err)
return err;
mutex_lock(&coda_inode->i_mutex);
cfi = CODA_FTOC(coda_file);
BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
host_file = cfi->cfi_container;
err = vfs_fsync(host_file, datasync);
if (!err && !datasync)
err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode));
mutex_unlock(&coda_inode->i_mutex);
return err;
}
示例7: coda_file_write
static ssize_t
coda_file_write(struct file *coda_file, const char __user *buf, size_t count, loff_t *ppos)
{
struct inode *host_inode, *coda_inode = coda_file->f_path.dentry->d_inode;
struct coda_file_info *cfi;
struct file *host_file;
ssize_t ret;
cfi = CODA_FTOC(coda_file);
BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
host_file = cfi->cfi_container;
if (!host_file->f_op || !host_file->f_op->write)
return -EINVAL;
host_inode = host_file->f_path.dentry->d_inode;
mutex_lock(&coda_inode->i_mutex);
ret = host_file->f_op->write(host_file, buf, count, ppos);
coda_inode->i_size = host_inode->i_size;
coda_inode->i_blocks = (coda_inode->i_size + 511) >> 9;
coda_inode->i_mtime = coda_inode->i_ctime = CURRENT_TIME_SEC;
mutex_unlock(&coda_inode->i_mutex);
return ret;
}
示例8: coda_readdir
static int coda_readdir(struct file *coda_file, void *buf, filldir_t filldir)
{
struct coda_file_info *cfi;
struct file *host_file;
int ret;
cfi = CODA_FTOC(coda_file);
BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
host_file = cfi->cfi_container;
if (!host_file->f_op)
return -ENOTDIR;
if (host_file->f_op->readdir)
{
struct inode *host_inode = host_file->f_path.dentry->d_inode;
mutex_lock(&host_inode->i_mutex);
host_file->f_pos = coda_file->f_pos;
ret = -ENOENT;
if (!IS_DEADDIR(host_inode)) {
ret = host_file->f_op->readdir(host_file, buf, filldir);
file_accessed(host_file);
}
coda_file->f_pos = host_file->f_pos;
mutex_unlock(&host_inode->i_mutex);
}
else
ret = coda_venus_readdir(coda_file, buf, filldir);
return ret;
}
示例9: coda_file_read_iter
static ssize_t
coda_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
{
struct file *coda_file = iocb->ki_filp;
struct coda_file_info *cfi = CODA_FTOC(coda_file);
BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
return vfs_iter_read(cfi->cfi_container, to, &iocb->ki_pos);
}
示例10: coda_file_read
static ssize_t
coda_file_read(struct file *coda_file, char __user *buf, size_t count, loff_t *ppos)
{
struct coda_file_info *cfi;
struct file *host_file;
cfi = CODA_FTOC(coda_file);
BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
host_file = cfi->cfi_container;
if (!host_file->f_op || !host_file->f_op->read)
return -EINVAL;
return host_file->f_op->read(host_file, buf, count, ppos);
}
示例11: coda_file_sendfile
static ssize_t
coda_file_sendfile(struct file *coda_file, loff_t *ppos, size_t count,
read_actor_t actor, void *target)
{
struct coda_file_info *cfi;
struct file *host_file;
cfi = CODA_FTOC(coda_file);
BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
host_file = cfi->cfi_container;
if (!host_file->f_op || !host_file->f_op->sendfile)
return -EINVAL;
return host_file->f_op->sendfile(host_file, ppos, count, actor, target);
}
示例12: coda_file_splice_read
static ssize_t
coda_file_splice_read(struct file *coda_file, loff_t *ppos,
struct pipe_inode_info *pipe, size_t count,
unsigned int flags)
{
struct coda_file_info *cfi;
struct file *host_file;
cfi = CODA_FTOC(coda_file);
BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
host_file = cfi->cfi_container;
if (!host_file->f_op || !host_file->f_op->splice_read)
return -EINVAL;
return host_file->f_op->splice_read(host_file, ppos, pipe, count,flags);
}
示例13: coda_release
int coda_release(struct inode *coda_inode, struct file *coda_file)
{
unsigned short flags = (coda_file->f_flags) & (~O_EXCL);
unsigned short coda_flags = coda_flags_to_cflags(flags);
struct coda_file_info *cfi;
struct coda_inode_info *cii;
struct inode *host_inode;
int err = 0;
lock_kernel();
coda_vfs_stat.release++;
if (!use_coda_close) {
err = venus_release(coda_inode->i_sb, coda_i2f(coda_inode),
coda_flags);
if (err == -EOPNOTSUPP) {
use_coda_close = 1;
err = 0;
}
}
cfi = CODA_FTOC(coda_file);
if (!cfi || cfi->cfi_magic != CODA_MAGIC) BUG();
if (use_coda_close)
err = venus_close(coda_inode->i_sb, coda_i2f(coda_inode),
coda_flags, &cfi->cfi_cred);
host_inode = cfi->cfi_container->f_dentry->d_inode;
cii = ITOC(coda_inode);
/* did we mmap this file? */
if (coda_inode->i_mapping == &host_inode->i_data) {
cii->c_mapcount -= cfi->cfi_mapcount;
if (!cii->c_mapcount)
coda_inode->i_mapping = &coda_inode->i_data;
}
fput(cfi->cfi_container);
kfree(coda_file->private_data);
coda_file->private_data = NULL;
unlock_kernel();
return err;
}
示例14: coda_flush
int coda_flush(struct file *coda_file, fl_owner_t id)
{
unsigned short flags = coda_file->f_flags & ~O_EXCL;
unsigned short coda_flags = coda_flags_to_cflags(flags);
struct coda_file_info *cfi;
struct inode *coda_inode;
int err = 0, fcnt;
lock_kernel();
coda_vfs_stat.flush++;
/* last close semantics */
fcnt = file_count(coda_file);
if (fcnt > 1)
goto out;
/* No need to make an upcall when we have not made any modifications
* to the file */
if ((coda_file->f_flags & O_ACCMODE) == O_RDONLY)
goto out;
if (use_coda_close)
goto out;
cfi = CODA_FTOC(coda_file);
BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
coda_inode = coda_file->f_dentry->d_inode;
err = venus_store(coda_inode->i_sb, coda_i2f(coda_inode), coda_flags,
coda_file->f_uid);
if (err == -EOPNOTSUPP) {
use_coda_close = 1;
err = 0;
}
out:
unlock_kernel();
return err;
}
示例15: coda_file_splice_read
static ssize_t
coda_file_splice_read(struct file *coda_file, loff_t *ppos,
struct pipe_inode_info *pipe, size_t count,
unsigned int flags)
{
ssize_t (*splice_read)(struct file *, loff_t *,
struct pipe_inode_info *, size_t, unsigned int);
struct coda_file_info *cfi;
struct file *host_file;
cfi = CODA_FTOC(coda_file);
BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
host_file = cfi->cfi_container;
splice_read = host_file->f_op->splice_read;
if (!splice_read)
splice_read = default_file_splice_read;
return splice_read(host_file, ppos, pipe, count, flags);
}