mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 01/30] fs: remove useless AT_FDCWD references
Date: Mon, 22 Nov 2021 09:47:03 +0100	[thread overview]
Message-ID: <20211122084732.2597109-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20211122084732.2597109-1-a.fatoum@pengutronix.de>

All name lookups by barebox are AT_FDCWD and there are no dirfd support
that could be used in its place, so just remove that parameter altogether
from the FS functions.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 fs/fs.c               | 56 +++++++++++++++++++++----------------------
 include/linux/namei.h |  4 ----
 2 files changed, 27 insertions(+), 33 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index e6fd57b8ac97..7da3a050c1cb 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -92,7 +92,7 @@ postcore_initcall(init_fs);
 struct filename;
 
 static struct fs_device_d *get_fsdevice_by_path(const char *path);
-static int filename_lookup(int dfd, struct filename *name, unsigned flags,
+static int filename_lookup(struct filename *name, unsigned flags,
 			   struct path *path);;
 static struct filename *getname(const char *filename);
 static void path_put(const struct path *path);
@@ -710,7 +710,7 @@ static void fs_remove(struct device_d *dev)
 	if (fsdev->loop && fsdev->cdev) {
 		cdev_remove_loop(fsdev->cdev);
 
-		ret = filename_lookup(AT_FDCWD, getname(fsdev->backingstore),
+		ret = filename_lookup(getname(fsdev->backingstore),
 				      LOOKUP_FOLLOW, &path);
 		if (!ret) {
 			mntput(path.mnt);
@@ -793,7 +793,7 @@ int fsdev_open_cdev(struct fs_device_d *fsdev)
 	parseopt_b(fsdev->options, "loop", &fsdev->loop);
 	parseopt_llu_suffix(fsdev->options, "offset", &offset);
 	if (fsdev->loop) {
-		ret = filename_lookup(AT_FDCWD, getname(fsdev->backingstore),
+		ret = filename_lookup(getname(fsdev->backingstore),
 				      LOOKUP_FOLLOW, &path);
 		if (ret)
 			return ret;
@@ -1467,7 +1467,6 @@ struct nameidata {
 	struct nameidata *saved;
 	struct inode	*link_inode;
 	unsigned	root_seq;
-	int		dfd;
 };
 
 struct filename {
@@ -1475,10 +1474,9 @@ struct filename {
 	int refcnt;
 };
 
-static void set_nameidata(struct nameidata *p, int dfd, struct filename *name)
+static void set_nameidata(struct nameidata *p, struct filename *name)
 {
 	p->stack = p->internal;
-	p->dfd = dfd;
 	p->name = name;
 	p->total_link_count = 0;
 }
@@ -2041,7 +2039,7 @@ static const char *path_init(struct nameidata *nd, unsigned flags)
 	if (*s == '/') {
 		get_root(&nd->path);
 		return s;
-	} else if (nd->dfd == AT_FDCWD) {
+	} else {
 		get_pwd(&nd->path);
 		nd->inode = nd->path.dentry->d_inode;
 		return s;
@@ -2101,7 +2099,7 @@ static int path_parentat(struct nameidata *nd, unsigned flags,
 	return err;
 }
 
-static struct filename *filename_parentat(int dfd, struct filename *name,
+static struct filename *filename_parentat(struct filename *name,
 				unsigned int flags, struct path *parent,
 				struct qstr *last, int *type)
 {
@@ -2111,7 +2109,7 @@ static struct filename *filename_parentat(int dfd, struct filename *name,
 	if (IS_ERR(name))
 		return name;
 
-	set_nameidata(&nd, dfd, name);
+	set_nameidata(&nd, name);
 
 	retval = path_parentat(&nd, flags, parent);
 	if (likely(!retval)) {
@@ -2125,7 +2123,7 @@ static struct filename *filename_parentat(int dfd, struct filename *name,
 	return name;
 }
 
-static struct dentry *filename_create(int dfd, struct filename *name,
+static struct dentry *filename_create(struct filename *name,
 				struct path *path, unsigned int lookup_flags)
 {
 	struct dentry *dentry = ERR_PTR(-EEXIST);
@@ -2140,7 +2138,7 @@ static struct dentry *filename_create(int dfd, struct filename *name,
 	 */
 	lookup_flags &= LOOKUP_REVAL;
 
-	name = filename_parentat(dfd, name, 0, path, &last, &type);
+	name = filename_parentat(name, 0, path, &last, &type);
 	if (IS_ERR(name))
 		return ERR_CAST(name);
 
@@ -2185,7 +2183,7 @@ out:
 	return dentry;
 }
 
-static int filename_lookup(int dfd, struct filename *name, unsigned flags,
+static int filename_lookup(struct filename *name, unsigned flags,
 			   struct path *path)
 {
 	int err;
@@ -2195,7 +2193,7 @@ static int filename_lookup(int dfd, struct filename *name, unsigned flags,
 	if (IS_ERR(name))
 		return PTR_ERR(name);
 
-	set_nameidata(&nd, dfd, name);
+	set_nameidata(&nd, name);
 
 	s = path_init(&nd, flags);
 
@@ -2228,7 +2226,7 @@ static struct fs_device_d *get_fsdevice_by_path(const char *pathname)
 	struct path path;
 	int ret;
 
-	ret = filename_lookup(AT_FDCWD, getname(pathname), 0, &path);
+	ret = filename_lookup(getname(pathname), 0, &path);
 	if (ret)
 		return NULL;
 
@@ -2287,7 +2285,7 @@ int mkdir (const char *pathname, mode_t mode)
 	int error;
 	unsigned int lookup_flags = LOOKUP_DIRECTORY;
 
-	dentry = filename_create(AT_FDCWD, getname(pathname), &path, lookup_flags);
+	dentry = filename_create(getname(pathname), &path, lookup_flags);
 	if (IS_ERR(dentry)) {
 		error = PTR_ERR(dentry);
 		goto out;
@@ -2314,7 +2312,7 @@ int rmdir (const char *pathname)
 	struct qstr last;
 	int type;
 
-	name = filename_parentat(AT_FDCWD, getname(pathname), 0,
+	name = filename_parentat(getname(pathname), 0,
 				&path, &last, &type);
 	if (IS_ERR(name))
 		return PTR_ERR(name);
@@ -2377,7 +2375,7 @@ int open(const char *pathname, int flags, ...)
 	if (IS_ERR(filename))
 		return PTR_ERR(filename);
 
-	set_nameidata(&nd, AT_FDCWD, filename);
+	set_nameidata(&nd, filename);
 
 	s = path_init(&nd, LOOKUP_FOLLOW);
 
@@ -2495,7 +2493,7 @@ int unlink(const char *pathname)
 	struct inode *inode;
 	struct path path;
 
-	ret = filename_lookup(AT_FDCWD, getname(pathname), 0, &path);
+	ret = filename_lookup(getname(pathname), 0, &path);
 	if (ret)
 		goto out;
 
@@ -2543,7 +2541,7 @@ int symlink(const char *pathname, const char *newpath)
 	int error;
 	unsigned int lookup_flags = LOOKUP_DIRECTORY;
 
-	dentry = filename_create(AT_FDCWD, getname(newpath), &path, lookup_flags);
+	dentry = filename_create(getname(newpath), &path, lookup_flags);
 	if (IS_ERR(dentry)) {
 		error = PTR_ERR(dentry);
 		goto out;
@@ -2583,7 +2581,7 @@ DIR *opendir(const char *pathname)
 		},
 	};
 
-	ret = filename_lookup(AT_FDCWD, getname(pathname),
+	ret = filename_lookup(getname(pathname),
 			      LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &path);
 	if (ret)
 		goto out;
@@ -2651,7 +2649,7 @@ int readlink(const char *pathname, char *buf, size_t bufsiz)
 	const char *link;
 	struct path path = {};
 
-	ret = filename_lookup(AT_FDCWD, getname(pathname), 0, &path);
+	ret = filename_lookup(getname(pathname), 0, &path);
 	if (ret)
 		goto out;
 
@@ -2695,7 +2693,7 @@ static int stat_filename(const char *filename, struct stat *s, unsigned int flag
 	struct inode *inode;
 	struct path path = {};
 
-	ret = filename_lookup(AT_FDCWD, getname(filename), flags, &path);
+	ret = filename_lookup(getname(filename), flags, &path);
 	if (ret)
 		goto out;
 
@@ -2799,7 +2797,7 @@ char *canonicalize_path(const char *pathname)
 	struct path path;
 	int ret;
 
-	ret = filename_lookup(AT_FDCWD, getname(pathname), LOOKUP_FOLLOW, &path);
+	ret = filename_lookup(getname(pathname), LOOKUP_FOLLOW, &path);
 	if (ret)
 		goto out;
 
@@ -2823,7 +2821,7 @@ int chdir(const char *pathname)
 	struct path path;
 	int ret;
 
-	ret = filename_lookup(AT_FDCWD, getname(pathname), LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &path);
+	ret = filename_lookup(getname(pathname), LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &path);
 	if (ret)
 		goto out;
 
@@ -2888,7 +2886,7 @@ int mount(const char *device, const char *fsname, const char *pathname,
 	struct path path = {};
 
 	if (d_root) {
-		ret = filename_lookup(AT_FDCWD, getname(pathname), LOOKUP_FOLLOW, &path);
+		ret = filename_lookup(getname(pathname), LOOKUP_FOLLOW, &path);
 		if (ret)
 			goto out;
 
@@ -3001,7 +2999,7 @@ int umount(const char *pathname)
 	struct path path = {};
 	int ret;
 
-	ret = filename_lookup(AT_FDCWD, getname(pathname), LOOKUP_FOLLOW, &path);
+	ret = filename_lookup(getname(pathname), LOOKUP_FOLLOW, &path);
 	if (ret)
 		return ret;
 
@@ -3074,7 +3072,7 @@ void automount_remove(const char *pathname)
 	struct path path;
 	int ret;
 
-	ret = filename_lookup(AT_FDCWD, getname(pathname), LOOKUP_FOLLOW, &path);
+	ret = filename_lookup(getname(pathname), LOOKUP_FOLLOW, &path);
 	if (ret)
 		return;
 
@@ -3090,7 +3088,7 @@ int automount_add(const char *pathname, const char *cmd)
 	struct path path;
 	int ret;
 
-	ret = filename_lookup(AT_FDCWD, getname(pathname), LOOKUP_FOLLOW, &path);
+	ret = filename_lookup(getname(pathname), LOOKUP_FOLLOW, &path);
 	if (ret)
 		return ret;
 
@@ -3199,7 +3197,7 @@ static int do_lookup_dentry(int argc, char *argv[])
 	if (argc < 2)
 		return COMMAND_ERROR_USAGE;
 
-	ret = filename_lookup(AT_FDCWD, getname(argv[1]), 0, &path);
+	ret = filename_lookup(getname(argv[1]), 0, &path);
 	if (ret) {
 		printf("Cannot lookup path \"%s\": %s\n",
 		       argv[1], strerror(-ret));
diff --git a/include/linux/namei.h b/include/linux/namei.h
index 8ed7f8a1cdac..9f6e568591af 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -45,8 +45,4 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
 #define LOOKUP_EMPTY		0x4000
 #define LOOKUP_DOWN		0x8000
 
-#define AT_FDCWD                -100    /* Special value used to indicate
-                                           openat should use the current
-                                           working directory. */
-
 #endif /* _LINUX_NAMEI_H */
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  reply	other threads:[~2021-11-22  8:49 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-22  8:47 [PATCH 00/30] efi: refactor for upcoming loader support Ahmad Fatoum
2021-11-22  8:47 ` Ahmad Fatoum [this message]
2021-11-22  8:47 ` [PATCH 02/30] fs: remove unused struct node_d in struct dir Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 03/30] block : efi: rename driver variable from efi_fs_driver to efi_bio_driver Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 04/30] include: <linux/types.h>: wrap in #ifndef __ASSEMBLY__ Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 05/30] hw_random: stm32: propagate error codes from rng read Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 06/30] efi: align LOAD_FILE_PROTOCOL_GUID's name with other PROTOCOL_GUIDs Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 07/30] asm-generic: move sync_caches_for_execution declaration to <asm/cache.h> Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 08/30] common: move EFI code into new efi/ top level directory Ahmad Fatoum
2021-11-23  8:55   ` Jules Maselbas
2021-11-22  8:47 ` [PATCH 09/30] serial: efi-stdio: move efi-stdio.h header to central location Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 10/30] efi: use SPDX-License-Identifier where appropriate Ahmad Fatoum
2021-11-23  8:52   ` Jules Maselbas
2021-11-22  8:47 ` [PATCH 11/30] drivers: efi: move Kconfig options to new menu Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 12/30] efi: factor out errno translation Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 13/30] efi: rename <efi/efi.h> to <efi/efi-payload.h> Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 14/30] efi: centralize efivarfs_parse_filename Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 15/30] kbuild: force 16-bit wchar_t treewide Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 16/30] include: <linux/nls.h>: remove duplicate wchar_t typedef Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 17/30] lib: wchar: add wctomb and mbtowc Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 18/30] lib: implement wcsnlen Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 19/30] vsprintf: add optional support for %ls format modifier Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 20/30] libfile: null-terminate read_file of wchar_t buffer Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 21/30] commands: echo: add wide file output via wecho alias Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 22/30] efi: make efi_main __noreturn Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 23/30] efi: define and use new EFI_ERROR_MASK macro Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 24/30] common: move CONFIG_ELF into General Settings Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 25/30] efi: don't zero executable buffer before freeing Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 26/30] partitions: efi: move header to central location Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 27/30] efi: print early efi_main string on CONFIG_DEBUG_LL=y Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 28/30] ARM64: board-dt-2nd: remove no longer needed noinline function split Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 29/30] bus: acpi: register bus even if without ACPI EFI table Ahmad Fatoum
2021-11-22  8:47 ` [PATCH 30/30] efi: guid: fix typos Ahmad Fatoum
2021-11-25  7:44 ` [PATCH 00/30] efi: refactor for upcoming loader support Sascha Hauer

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=20211122084732.2597109-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --subject='Re: [PATCH 01/30] fs: remove useless AT_FDCWD references' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox