コード例 #1
0
int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
{
	struct dnotify_struct *dn = NULL;
	struct dnotify_struct *odn;
	struct dnotify_struct **prev;
	struct inode *inode;
	int turning_off = (arg & ~DN_MULTISHOT) == 0;
	int error = 0;

	if (!turning_off && !dir_notify_enable)
		return -EINVAL;
	inode = filp->f_dentry->d_inode;
	if (!S_ISDIR(inode->i_mode))
		return -ENOTDIR;
	if (!turning_off) {
		dn = kmem_cache_alloc(dn_cache, SLAB_KERNEL);
		if (dn == NULL)
			return -ENOMEM;
	}
	write_lock(&dn_lock);
	prev = &inode->i_dnotify;
	for (odn = *prev; odn != NULL; prev = &odn->dn_next, odn = *prev)
		if (odn->dn_filp == filp)
			break;
	if (odn != NULL) {
		if (turning_off) {
			*prev = odn->dn_next;
			redo_inode_mask(inode);
			dn = odn;
			goto out_free;
		}
		odn->dn_fd = fd;
		odn->dn_mask |= arg;
		inode->i_dnotify_mask |= arg & ~DN_MULTISHOT;
		goto out_free;
	}
	if (turning_off)
		goto out;
	if ((error = security_file_set_fowner(filp)))
		goto out_free;
	filp->f_owner.pid = current->pid;
	filp->f_owner.uid = current->uid;
	filp->f_owner.euid = current->euid;
	dn->dn_magic = DNOTIFY_MAGIC;
	dn->dn_mask = arg;
	dn->dn_fd = fd;
	dn->dn_filp = filp;
	inode->i_dnotify_mask |= arg & ~DN_MULTISHOT;
	dn->dn_next = inode->i_dnotify;
	inode->i_dnotify = dn;
out:
	write_unlock(&dn_lock);
	return error;
out_free:
	kmem_cache_free(dn_cache, dn);
	goto out;
}
コード例 #2
0
ファイル: fcntl.c プロジェクト: nemumu/linux
int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
               int force)
{
    int err;

    err = security_file_set_fowner(filp);
    if (err)
        return err;

    f_modown(filp, pid, type, force);
    return 0;
}
コード例 #3
0
ファイル: fcntl.c プロジェクト: ReneNyffenegger/linux
void __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
		int force)
{
	security_file_set_fowner(filp);
	f_modown(filp, pid, type, force);
}