Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit d2739d29 authored by derfelot's avatar derfelot
Browse files

fuse: Add support to allow certain calls to utime() from Sony kernel

Taken from Sony 47.2.A.10.107 stock kernel
parent 5dfab3c0
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -5,6 +5,11 @@
  This program can be distributed under the terms of the GNU GPL.
  See the file COPYING.
*/
/*
 * NOTE: This file has been modified by Sony Mobile Communications Inc.
 * Modifications are Copyright (c) 2013 Sony Mobile Communications Inc,
 * and licensed under the license of the file.
 */

#include "fuse_i.h"

@@ -1627,6 +1632,12 @@ int fuse_flush_times(struct inode *inode, struct fuse_file *ff)
	return fuse_simple_request(fc, &args);
}

static bool fuse_allow_set_time(struct fuse_conn *fc, struct inode *inode)
{
	return (fc->flags & FUSE_ALLOW_UTIME_GRP && inode->i_mode & S_IWGRP &&
	    !uid_eq(current_uid(), inode->i_uid) && in_group_p(inode->i_gid));
}

/*
 * Set attributes, and at the same time refresh them.
 *
@@ -1646,13 +1657,22 @@ int fuse_do_setattr(struct inode *inode, struct iattr *attr,
	bool is_truncate = false;
	bool is_wb = fc->writeback_cache;
	loff_t oldsize;
	unsigned int ia_valid;
	int err;
	bool trust_local_cmtime = is_wb && S_ISREG(inode->i_mode);

	if (!(fc->flags & FUSE_DEFAULT_PERMISSIONS))
		attr->ia_valid |= ATTR_FORCE;

	ia_valid = attr->ia_valid;
	if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET) &&
	    fuse_allow_set_time(fc, inode)) {
		attr->ia_valid &= ~(ATTR_MTIME_SET | ATTR_ATIME_SET |
				    ATTR_TIMES_SET);
	}

	err = inode_change_ok(inode, attr);
	attr->ia_valid = ia_valid;
	if (err)
		return err;

+10 −0
Original line number Diff line number Diff line
@@ -5,6 +5,11 @@
  This program can be distributed under the terms of the GNU GPL.
  See the file COPYING.
*/
/*
 * NOTE: This file has been modified by Sony Mobile Communications Inc.
 * Modifications are Copyright (c) 2013 Sony Mobile Communications Inc,
 * and licensed under the license of the file.
 */

#ifndef _FS_FUSE_I_H
#define _FS_FUSE_I_H
@@ -45,6 +50,11 @@
    doing the mount will be allowed to access the filesystem */
#define FUSE_ALLOW_OTHER         (1 << 1)

/** If the FUSE_ALLOW_UTIME_GRP flag is given, then call to utime() is
    allowed for the current process if it's in the same group as the
    file and if the file's group is writeable */
#define FUSE_ALLOW_UTIME_GRP     (1 << 2)

/** Number of page pointers embedded in fuse_req */
#define FUSE_REQ_INLINE_PAGES 1

+13 −0
Original line number Diff line number Diff line
@@ -5,6 +5,11 @@
  This program can be distributed under the terms of the GNU GPL.
  See the file COPYING.
*/
/*
 * NOTE: This file has been modified by Sony Mobile Communications Inc.
 * Modifications are Copyright (c) 2013 Sony Mobile Communications Inc,
 * and licensed under the license of the file.
 */

#include "fuse_i.h"

@@ -435,6 +440,7 @@ enum {
	OPT_GROUP_ID,
	OPT_DEFAULT_PERMISSIONS,
	OPT_ALLOW_OTHER,
	OPT_ALLOW_UTIME_GRP,
	OPT_MAX_READ,
	OPT_BLKSIZE,
	OPT_ERR
@@ -447,6 +453,7 @@ static const match_table_t tokens = {
	{OPT_GROUP_ID,			"group_id=%u"},
	{OPT_DEFAULT_PERMISSIONS,	"default_permissions"},
	{OPT_ALLOW_OTHER,		"allow_other"},
	{OPT_ALLOW_UTIME_GRP,		"allow_utime_grp"},
	{OPT_MAX_READ,			"max_read=%u"},
	{OPT_BLKSIZE,			"blksize=%u"},
	{OPT_ERR,			NULL}
@@ -522,6 +529,10 @@ static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev)
			d->flags |= FUSE_ALLOW_OTHER;
			break;

		case OPT_ALLOW_UTIME_GRP:
			d->flags |= FUSE_ALLOW_UTIME_GRP;
			break;

		case OPT_MAX_READ:
			if (match_int(&args[0], &value))
				return 0;
@@ -557,6 +568,8 @@ static int fuse_show_options(struct seq_file *m, struct dentry *root)
		seq_puts(m, ",default_permissions");
	if (fc->flags & FUSE_ALLOW_OTHER)
		seq_puts(m, ",allow_other");
	if (fc->flags & FUSE_ALLOW_UTIME_GRP)
		seq_puts(m, ",allow_utime_grp");
	if (fc->max_read != ~0)
		seq_printf(m, ",max_read=%u", fc->max_read);
	if (sb->s_bdev && sb->s_blocksize != FUSE_DEFAULT_BLKSIZE)