From: Sascha Hauer <s.hauer@pengutronix.de>
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
Christoph Hellwig <hch@infradead.org>,
kernel@pengutronix.de, Jan Kara <jack@suse.com>,
Richard Weinberger <richard@nod.at>,
Sascha Hauer <s.hauer@pengutronix.de>
Subject: [PATCH 1/2] quota: Add mountpath based quota support
Date: Thu, 11 Feb 2021 16:30:22 +0100 [thread overview]
Message-ID: <20210211153024.32502-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20210211153024.32502-1-s.hauer@pengutronix.de>
Add syscall quotactl_path, a variant of quotactl which allows to specify
the mountpath instead of a path of to a block device.
The quotactl syscall expects a path to the mounted block device to
specify the filesystem to work on. This limits usage to filesystems
which actually have a block device. quotactl_path replaces the path
to the block device with a path where the filesystem is mounted at.
The global Q_SYNC command to sync all filesystems is not supported for
this new syscall, otherwise quotactl_path behaves like quotactl.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
fs/quota/quota.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/fs/quota/quota.c b/fs/quota/quota.c
index 6d16b2be5ac4..6f1df32abeea 100644
--- a/fs/quota/quota.c
+++ b/fs/quota/quota.c
@@ -17,6 +17,7 @@
#include <linux/capability.h>
#include <linux/quotaops.h>
#include <linux/types.h>
+#include <linux/mount.h>
#include <linux/writeback.h>
#include <linux/nospec.h>
#include "compat.h"
@@ -968,3 +969,51 @@ SYSCALL_DEFINE4(quotactl, unsigned int, cmd, const char __user *, special,
path_put(pathp);
return ret;
}
+
+SYSCALL_DEFINE4(quotactl_path, unsigned int, cmd, const char __user *,
+ mountpoint, qid_t, id, void __user *, addr)
+{
+ struct super_block *sb;
+ struct path mountpath;
+ unsigned int cmds = cmd >> SUBCMDSHIFT;
+ unsigned int type = cmd & SUBCMDMASK;
+ int ret;
+
+ if (type >= MAXQUOTAS)
+ return -EINVAL;
+
+ if (!mountpoint)
+ return -ENODEV;
+
+ ret = user_path_at(AT_FDCWD, mountpoint,
+ LOOKUP_FOLLOW | LOOKUP_AUTOMOUNT, &mountpath);
+ if (ret)
+ return ret;
+
+ sb = mountpath.dentry->d_inode->i_sb;
+
+ if (quotactl_cmd_write(cmds)) {
+ ret = mnt_want_write(mountpath.mnt);
+ if (ret)
+ goto out;
+ }
+
+ if (quotactl_cmd_onoff(cmds))
+ down_write(&sb->s_umount);
+ else
+ down_read(&sb->s_umount);
+
+ ret = do_quotactl(sb, type, cmds, id, addr, ERR_PTR(-EINVAL));
+
+ if (quotactl_cmd_onoff(cmds))
+ up_write(&sb->s_umount);
+ else
+ up_read(&sb->s_umount);
+
+ if (quotactl_cmd_write(cmds))
+ mnt_drop_write(mountpath.mnt);
+out:
+ path_put(&mountpath);
+
+ return ret;
+}
--
2.20.1
next prev parent reply other threads:[~2021-02-11 16:36 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-11 15:30 [PATCH v2 0/2] quota: Add mountpath based quota support Sascha Hauer
2021-02-11 15:30 ` Sascha Hauer [this message]
2021-02-11 15:38 ` [PATCH 1/2] " Christoph Hellwig
2021-02-12 8:38 ` Sascha Hauer
2021-02-12 10:05 ` Jan Kara
2021-02-12 10:29 ` Sascha Hauer
2021-02-12 10:41 ` Jan Kara
2021-02-12 5:45 ` kernel test robot
2021-02-14 13:48 ` Al Viro
2021-02-11 15:30 ` [PATCH 2/2] quota: wire up quotactl_path Sascha Hauer
2021-02-11 15:38 ` Christoph Hellwig
2021-02-11 19:56 ` kernel test robot
2021-02-12 0:10 ` kernel test robot
2021-02-11 15:30 ` [PATCH] quotactl.2: Add documentation for quotactl_path() Sascha Hauer
2021-02-12 10:16 ` [PATCH v2 0/2] quota: Add mountpath based quota support Jan Kara
-- strict thread matches above, loose matches on Subject: below --
2021-03-04 12:35 [PATCH v3 " Sascha Hauer
2021-03-04 12:35 ` [PATCH 1/2] " Sascha Hauer
2021-01-28 14:17 [PATCH 0/2] " Sascha Hauer
2021-01-28 14:17 ` [PATCH 1/2] " Sascha Hauer
2021-01-28 14:35 ` Christoph Hellwig
2021-02-02 18:02 ` Jan Kara
2021-02-04 7:34 ` Christoph Hellwig
2021-02-04 12:53 ` Jan Kara
2021-02-09 8:51 ` Christoph Hellwig
2021-02-09 9:57 ` Jan Kara
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=20210211153024.32502-2-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=hch@infradead.org \
--cc=jack@suse.com \
--cc=kernel@pengutronix.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=richard@nod.at \
/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).