From: Dmitry Monakhov <dmonakhov@openvz.org>
To: linux-ext4@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, tytso@mit.edu, adilger@sun.com,
hch@infradead.org, jack@suse.cz, david@fromorbit.com,
viro@ZenIV.linux.org.uk, xemul@openvz.org,
Dmitry Monakhov <dmonakhov@openvz.org>
Subject: [PATCH 1/5] vfs: Add additional owner identifier
Date: Thu, 18 Mar 2010 17:02:46 +0300 [thread overview]
Message-ID: <1268920970-9061-2-git-send-email-dmonakhov@openvz.org> (raw)
In-Reply-To: <1268920970-9061-1-git-send-email-dmonakhov@openvz.org>
This patch add project inode identifier. Project ID may be used as
auxiliary owner specifier in addition to standard uid/gid.
---
fs/Kconfig | 7 +++++++
fs/attr.c | 10 +++++++++-
include/linux/fs.h | 8 ++++++++
include/linux/xattr.h | 3 +++
4 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/fs/Kconfig b/fs/Kconfig
index 5f85b59..23957c0 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -54,6 +54,13 @@ config FILE_LOCKING
This option enables standard file locking support, required
for filesystems like NFS and for the flock() system
call. Disabling this option saves about 11k.
+config PROJECT_ID
+ bool "Enable project inode identifier"
+ default y
+ help
+ This option enables project inode identifier. Project ID
+ may be used as auxiliary owner specifier in addition to
+ standard uid/gid.
source "fs/notify/Kconfig"
diff --git a/fs/attr.c b/fs/attr.c
index 0815e93..2894cc7 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -32,6 +32,9 @@ int inode_change_ok(const struct inode *inode, struct iattr *attr)
attr->ia_uid != inode->i_uid) && !capable(CAP_CHOWN))
goto error;
+ if ((ia_valid & ATTR_PRJID) && !capable(CAP_SYS_RESOURCE))
+ goto error;
+
/* Make sure caller can chgrp. */
if ((ia_valid & ATTR_GID) &&
(current_fsuid() != inode->i_uid ||
@@ -119,6 +122,10 @@ int inode_setattr(struct inode * inode, struct iattr * attr)
inode->i_uid = attr->ia_uid;
if (ia_valid & ATTR_GID)
inode->i_gid = attr->ia_gid;
+#ifdef CONFIG_PROJECT_ID
+ if (ia_valid & ATTR_PRJID)
+ inode->i_prjid = attr->ia_prjid;
+#endif
if (ia_valid & ATTR_ATIME)
inode->i_atime = timespec_trunc(attr->ia_atime,
inode->i_sb->s_time_gran);
@@ -149,7 +156,8 @@ int notify_change(struct dentry * dentry, struct iattr * attr)
struct timespec now;
unsigned int ia_valid = attr->ia_valid;
- if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
+ if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_PRJID |
+ ATTR_TIMES_SET)) {
if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
return -EPERM;
}
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 48aee87..0c9dadb 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -438,6 +438,7 @@ typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
#define ATTR_KILL_PRIV (1 << 14)
#define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
#define ATTR_TIMES_SET (1 << 16)
+#define ATTR_PRJID (1 << 17)
/*
* This is the Inode Attributes structure, used for notify_change(). It
@@ -453,6 +454,9 @@ struct iattr {
umode_t ia_mode;
uid_t ia_uid;
gid_t ia_gid;
+#ifdef CONFIG_PROJECT_ID
+ unsigned int ia_prjid;
+#endif
loff_t ia_size;
struct timespec ia_atime;
struct timespec ia_mtime;
@@ -756,6 +760,10 @@ struct inode {
#ifdef CONFIG_QUOTA
struct dquot *i_dquot[MAXQUOTAS];
#endif
+#ifdef CONFIG_PROJECT_ID
+ /* Project id, protected by i_mutex similar to i_uid/i_gid */
+ __u32 i_prjid;
+#endif
struct list_head i_devices;
union {
struct pipe_inode_info *i_pipe;
diff --git a/include/linux/xattr.h b/include/linux/xattr.h
index fb9b7e6..9d85a4b 100644
--- a/include/linux/xattr.h
+++ b/include/linux/xattr.h
@@ -33,6 +33,9 @@
#define XATTR_USER_PREFIX "user."
#define XATTR_USER_PREFIX_LEN (sizeof (XATTR_USER_PREFIX) - 1)
+#define XATTR_PRJID "system.project_id"
+#define XATTR_PRJID_LEN (sizeof (XATTR_PRJID))
+
struct inode;
struct dentry;
--
1.6.6.1
next prev parent reply other threads:[~2010-03-18 14:02 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-18 14:02 [PATCH 0/5] RFC: introduce extended inode owner identifier v6 Dmitry Monakhov
2010-03-18 14:02 ` Dmitry Monakhov [this message]
2010-03-18 14:02 ` [PATCH 2/5] quota: Implement project id support for generic quota Dmitry Monakhov
2010-03-18 14:02 ` [PATCH 3/5] ext4: Implement project ID support for ext4 filesystem Dmitry Monakhov
2010-03-18 14:02 ` [PATCH 4/5] ext4: add project quota support Dmitry Monakhov
2010-03-18 14:02 ` [PATCH 5/5] ext4: add isolated project support Dmitry Monakhov
2010-03-18 21:25 ` [PATCH 3/5] ext4: Implement project ID support for ext4 filesystem Andreas Dilger
2010-03-19 8:16 ` Dmitry Monakhov
2010-04-06 9:00 ` Ping Dmitry Monakhov
2010-04-13 18:14 ` Ping Christoph Hellwig
2010-04-15 11:30 ` Ping Dmitry Monakhov
2010-05-15 9:34 ` Ping Al Viro
2010-04-30 12:14 ` Ping to Al Pavel Emelyanov
-- strict thread matches above, loose matches on Subject: below --
2010-03-04 18:34 [PATCH 0/5] RFC: introduce extended inode owner identifier v5 Dmitry Monakhov
2010-03-04 18:34 ` [PATCH 1/5] vfs: Add additional owner identifier Dmitry Monakhov
2010-03-11 12:01 ` Christoph Hellwig
2010-03-11 13:11 ` Dmitry Monakhov
2010-03-11 18:51 ` J. Bruce Fields
2010-03-11 19:40 ` Andreas Dilger
2010-03-12 8:47 ` Dmitry Monakhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1268920970-9061-2-git-send-email-dmonakhov@openvz.org \
--to=dmonakhov@openvz.org \
--cc=adilger@sun.com \
--cc=david@fromorbit.com \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=viro@ZenIV.linux.org.uk \
--cc=xemul@openvz.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).