本文整理汇总了C++中IS_APPEND函数的典型用法代码示例。如果您正苦于以下问题:C++ IS_APPEND函数的具体用法?C++ IS_APPEND怎么用?C++ IS_APPEND使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IS_APPEND函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sys_fcntl
int sys_fcntl(unsigned int fd, unsigned int cmd, unsigned int arg)
{
register struct file *filp;
register struct file_struct *fils = ¤t->files;
int result;
if (fd >= NR_OPEN || !(filp = fils->fd[fd])) return -EBADF;
switch (cmd) {
case F_DUPFD:
result = dupfd(fd, arg);
break;
case F_GETFD:
result = test_bit(fd, &fils->close_on_exec);
break;
case F_SETFD:
if (arg & 1)
set_bit(fd, &fils->close_on_exec);
else
clear_bit(fd, &fils->close_on_exec);
result = 0;
break;
case F_GETFL:
result = (int) filp->f_flags;
break;
case F_SETFL:
/*
* In the case of an append-only file, O_APPEND
* cannot be cleared
*/
result = -EPERM;
if (!IS_APPEND(filp->f_inode) || (arg & O_APPEND)) {
filp->f_flags &= ~(O_APPEND | O_NONBLOCK);
filp->f_flags |= arg & (O_APPEND | O_NONBLOCK);
result = 0;
}
break;
default:
result = -EINVAL;
break;
}
return result;
}
示例2: do_sys_ftruncate
static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
{
struct inode * inode;
struct dentry *dentry;
struct file * file;
int error;
error = -EINVAL;
if (length < 0)
goto out;
error = -EBADF;
file = fget(fd);
if (!file)
goto out;
/* explicitly opened as large or we are on 64-bit box */
if (file->f_flags & O_LARGEFILE)
small = 0;
dentry = file->f_path.dentry;
inode = dentry->d_inode;
error = -EINVAL;
if (!S_ISREG(inode->i_mode) || !(file->f_mode & FMODE_WRITE))
goto out_putf;
error = -EINVAL;
/* Cannot ftruncate over 2^31 bytes without large file support */
if (small && length > MAX_NON_LFS)
goto out_putf;
error = -EPERM;
if (IS_APPEND(inode))
goto out_putf;
error = locks_verify_truncate(inode, file, length);
if (!error)
error = security_path_truncate(&file->f_path);
if (!error)
error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
out_putf:
fput(file);
out:
return error;
}
示例3: call_notify_change
static void call_notify_change(void *args)
{
struct notify_change_args *a = args;
struct inode *h_inode;
h_inode = d_inode(a->path->dentry);
IMustLock(h_inode);
*a->errp = -EPERM;
if (!IS_IMMUTABLE(h_inode) && !IS_APPEND(h_inode)) {
lockdep_off();
*a->errp = notify_change(a->path->dentry, a->ia,
a->delegated_inode);
lockdep_on();
if (!*a->errp)
vfsub_update_h_iattr(a->path, /*did*/NULL); /*ignore*/
}
AuTraceErr(*a->errp);
}
示例4: xfs_fssetdm_by_handle
STATIC int
xfs_fssetdm_by_handle(
struct file *parfilp,
void __user *arg)
{
int error;
struct fsdmidata fsd;
xfs_fsop_setdm_handlereq_t dmhreq;
struct dentry *dentry;
if (!capable(CAP_MKNOD))
return -EPERM;
if (copy_from_user(&dmhreq, arg, sizeof(xfs_fsop_setdm_handlereq_t)))
return -EFAULT;
error = mnt_want_write_file(parfilp);
if (error)
return error;
dentry = xfs_handlereq_to_dentry(parfilp, &dmhreq.hreq);
if (IS_ERR(dentry)) {
mnt_drop_write_file(parfilp);
return PTR_ERR(dentry);
}
if (IS_IMMUTABLE(d_inode(dentry)) || IS_APPEND(d_inode(dentry))) {
error = -EPERM;
goto out;
}
if (copy_from_user(&fsd, dmhreq.data, sizeof(fsd))) {
error = -EFAULT;
goto out;
}
error = xfs_set_dmattrs(XFS_I(d_inode(dentry)), fsd.fsd_dmevmask,
fsd.fsd_dmstate);
out:
mnt_drop_write_file(parfilp);
dput(dentry);
return error;
}
示例5: xattr_permission
/*
* Check permissions for extended attribute access. This is a bit complicated
* because different namespaces have very different rules.
*/
static int
xattr_permission(struct inode *inode, const char *name, int mask)
{
/*
* We can never set or remove an extended attribute on a read-only
* filesystem or on an immutable / append-only inode.
*/
if (mask & MAY_WRITE) {
if (IS_RDONLY(inode))
return -EROFS;
if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
return -EPERM;
}
/*
* No restriction for security.* and system.* from the VFS. Decision
* on these is left to the underlying filesystem / security module.
*/
if (!strncmp(name, XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN) ||
!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN))
return 0;
/*
* The trusted.* namespace can only be accessed by a privileged user.
*/
if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM);
/* In user.* namespace, only regular files and directories can have
* extended attributes. For sticky directories, only the owner and
* privileged user can write attributes.
*/
if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode))
return -EPERM;
if (S_ISDIR(inode->i_mode) && (inode->i_mode & S_ISVTX) &&
(mask & MAY_WRITE) && (current->fsuid != inode->i_uid) &&
!capable(CAP_FOWNER))
return -EPERM;
}
return permission(inode, mask, NULL);
}
示例6: sys_truncate
asmlinkage int sys_truncate(const char * path, unsigned long length)
{
struct inode * inode;
int error;
error = namei(path,&inode);
if (error)
return error;
error = -EACCES;
if (S_ISDIR(inode->i_mode))
goto out;
error = permission(inode,MAY_WRITE);
if (error)
goto out;
error = -EROFS;
if (IS_RDONLY(inode))
goto out;
error = -EPERM;
if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
goto out;
error = get_write_access(inode);
if (error)
goto out;
error = locks_verify_area(FLOCK_VERIFY_WRITE, inode, NULL,
length < inode->i_size ? length : inode->i_size,
abs(inode->i_size - length));
if (!error) {
if (inode->i_sb && inode->i_sb->dq_op)
inode->i_sb->dq_op->initialize(inode, -1);
error = do_truncate(inode, length);
}
put_write_access(inode);
out:
iput(inode);
return error;
}
示例7: xfs_fssetdm_by_handle
STATIC int
xfs_fssetdm_by_handle(
xfs_mount_t *mp,
void __user *arg,
struct file *parfilp,
struct inode *parinode)
{
int error;
struct fsdmidata fsd;
xfs_fsop_setdm_handlereq_t dmhreq;
struct inode *inode;
bhv_desc_t *bdp;
vnode_t *vp;
if (!capable(CAP_MKNOD))
return -XFS_ERROR(EPERM);
if (copy_from_user(&dmhreq, arg, sizeof(xfs_fsop_setdm_handlereq_t)))
return -XFS_ERROR(EFAULT);
error = xfs_vget_fsop_handlereq(mp, parinode, &dmhreq.hreq, &vp, &inode);
if (error)
return -error;
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) {
VN_RELE(vp);
return -XFS_ERROR(EPERM);
}
if (copy_from_user(&fsd, dmhreq.data, sizeof(fsd))) {
VN_RELE(vp);
return -XFS_ERROR(EFAULT);
}
bdp = bhv_base_unlocked(VN_BHV_HEAD(vp));
error = xfs_set_dmattrs(bdp, fsd.fsd_dmevmask, fsd.fsd_dmstate, NULL);
VN_RELE(vp);
if (error)
return -error;
return 0;
}
示例8: cr_filp_chmod
/* Based on sys_fchmod() from linux 2.6.21 (mostly unchanged since 2.4.0). */
int cr_filp_chmod(struct file *filp, mode_t mode) {
struct iattr newattrs;
struct dentry *dentry = filp->f_dentry;
struct inode *inode = dentry->d_inode;
int retval;
retval = -EROFS;
if (IS_RDONLY(inode)) goto out;
retval = -EPERM;
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) goto out;
cr_inode_lock(inode);
newattrs.ia_mode = (mode == (mode_t)-1) ? inode->i_mode
: ((mode & S_IALLUGO)|(inode->i_mode & ~S_IALLUGO));
newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
retval = cr_notify_change(dentry, filp->f_vfsmnt, &newattrs);
cr_inode_unlock(inode);
out:
return retval;
}
示例9: pvfs2_truncate
/** Change size of an object referenced by inode
*/
void pvfs2_truncate(struct inode *inode)
{
loff_t orig_size = pvfs2_i_size_read(inode);
if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
return;
gossip_debug(GOSSIP_INODE_DEBUG, "pvfs2: pvfs2_truncate called on inode %llu "
"with size %ld\n", llu(get_handle_from_ino(inode)), (long) orig_size);
/* successful truncate when size changes also requires mtime updates
* although the mtime updates are propagated lazily!
*/
if (pvfs2_truncate_inode(inode, inode->i_size) == 0
&& (orig_size != pvfs2_i_size_read(inode)))
{
pvfs2_inode_t *pvfs2_inode = PVFS2_I(inode);
SetMtimeFlag(pvfs2_inode);
inode->i_mtime = CURRENT_TIME;
mark_inode_dirty_sync(inode);
}
}
示例10: mext_check_arguments
int mext_check_arguments(struct inode *orig_inode,
struct inode *donor_inode, __u64 orig_start,
__u64 donor_start, __u64 *len)
{
unsigned int blkbits = orig_inode->i_blkbits;
unsigned int blocksize = 1 << blkbits;
#ifdef __PATCH__
if (IS_IMMUTABLE(donor_inode) || IS_APPEND(donor_inode))
return -EPERM;
#endif
if ((!orig_inode->i_size) || (!donor_inode->i_size))
return -EINVAL;
if (!*len)
return -EINVAL;
return 0;
}
示例11: sys_fchmod
asmlinkage int sys_fchmod(unsigned int fd, mode_t mode)
{
struct inode * inode;
struct file * file;
struct iattr newattrs;
if (fd >= NR_OPEN || !(file = current->files->fd[fd]))
return -EBADF;
if (!(inode = file->f_inode))
return -ENOENT;
if (IS_RDONLY(inode))
return -EROFS;
if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
return -EPERM;
if (mode == (mode_t) -1)
mode = inode->i_mode;
newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
inode->i_dirt = 1;
return notify_change(inode, &newattrs);
}
示例12: sys_ftruncate
asmlinkage int sys_ftruncate(unsigned int fd, unsigned long length)
{
struct inode * inode;
struct file * file;
int error;
if (fd >= NR_OPEN || !(file = current->files->fd[fd]))
return -EBADF;
if (!(inode = file->f_inode))
return -ENOENT;
if (S_ISDIR(inode->i_mode) || !(file->f_mode & FMODE_WRITE))
return -EACCES;
if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
return -EPERM;
error = locks_verify_area(FLOCK_VERIFY_WRITE, inode, file,
length < inode->i_size ? length : inode->i_size,
abs(inode->i_size - length));
if (!error)
error = do_truncate(inode, length);
return error;
}
示例13: xfs_attrmulti_attr_set
int
xfs_attrmulti_attr_set(
struct inode *inode,
unsigned char *name,
const unsigned char __user *ubuf,
__uint32_t len,
__uint32_t flags)
{
unsigned char *kbuf;
if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
return -EPERM;
if (len > XATTR_SIZE_MAX)
return -EINVAL;
kbuf = memdup_user(ubuf, len);
if (IS_ERR(kbuf))
return PTR_ERR(kbuf);
return xfs_attr_set(XFS_I(inode), name, kbuf, len, flags);
}
示例14: sys_fchmod
asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
{
struct inode * inode;
struct dentry * dentry;
struct file * file;
int err = -EBADF;
struct iattr newattrs;
file = fget(fd);
if (!file)
goto out;
dentry = file->f_path.dentry;
inode = dentry->d_inode;
audit_inode(NULL, dentry);
err = mnt_want_write(file->f_path.mnt);
if (err)
goto out_putf;
err = -EPERM;
if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
goto out_drop_write;
mutex_lock(&inode->i_mutex);
if (mode == (mode_t) -1)
mode = inode->i_mode;
newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
err = notify_change(dentry, &newattrs);
mutex_unlock(&inode->i_mutex);
out_drop_write:
mnt_drop_write(file->f_path.mnt);
out_putf:
fput(file);
out:
return err;
}
示例15: xfs_fssetdm_by_handle
STATIC int
xfs_fssetdm_by_handle(
xfs_mount_t *mp,
void __user *arg,
struct inode *parinode)
{
int error;
struct fsdmidata fsd;
xfs_fsop_setdm_handlereq_t dmhreq;
struct inode *inode;
if (!capable(CAP_MKNOD))
return -XFS_ERROR(EPERM);
if (copy_from_user(&dmhreq, arg, sizeof(xfs_fsop_setdm_handlereq_t)))
return -XFS_ERROR(EFAULT);
error = xfs_vget_fsop_handlereq(mp, parinode, &dmhreq.hreq, &inode);
if (error)
return -error;
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) {
error = -XFS_ERROR(EPERM);
goto out;
}
if (copy_from_user(&fsd, dmhreq.data, sizeof(fsd))) {
error = -XFS_ERROR(EFAULT);
goto out;
}
error = -xfs_set_dmattrs(XFS_I(inode), fsd.fsd_dmevmask,
fsd.fsd_dmstate);
out:
iput(inode);
return error;
}