public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: xfs <linux-xfs@vger.kernel.org>
Subject: [PATCH 2/2] libxfs: remove getcwd/chdir dance from initialization
Date: Sun, 3 Sep 2017 18:18:06 -0700	[thread overview]
Message-ID: <20170904011806.GA4660@magnolia> (raw)

Back in the old days of Irix, the library saved and restored chdir so
that (I guess?) check_open can change directory without screwing up our
ability to use relative paths.  However, there's nothing in Linux that
actually does this, so just rip out the getcwd/chdir stuff since we
absolute device paths work just fine without it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 libxfs/init.c |   16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/libxfs/init.c b/libxfs/init.c
index d77a9e6..15e8bbb 100644
--- a/libxfs/init.c
+++ b/libxfs/init.c
@@ -240,13 +240,11 @@ int
 libxfs_init(libxfs_init_t *a)
 {
 	char		*blockfile;
-	char		curdir[MAXPATHLEN];
 	char		*dname;
 	char		dpath[25];
 	int		fd;
 	char		*logname;
 	char		logpath[25];
-	int		needcd;
 	char		*rawfile;
 	char		*rtname;
 	char		rtpath[25];
@@ -262,8 +260,6 @@ libxfs_init(libxfs_init_t *a)
 	a->dsize = a->lbsize = a->rtbsize = 0;
 	a->dbsize = a->logBBsize = a->logBBstart = a->rtsize = 0;
 
-	(void)getcwd(curdir,MAXPATHLEN);
-	needcd = 0;
 	fd = -1;
 	flags = (a->isreadonly | a->isdirect);
 
@@ -277,14 +273,11 @@ libxfs_init(libxfs_init_t *a)
 	if (a->volname) {
 		if(!check_open(a->volname,flags,&rawfile,&blockfile))
 			goto done;
-		needcd = 1;
 		fd = open(rawfile, O_RDONLY);
 		dname = a->dname = a->volname;
 		a->volname = NULL;
 	}
 	if (dname) {
-		if (dname[0] != '/' && needcd)
-			chdir(curdir);
 		if (a->disfile) {
 			a->ddev= libxfs_device_open(dname, a->dcreat, flags,
 						    a->setblksize);
@@ -300,12 +293,9 @@ libxfs_init(libxfs_init_t *a)
 			platform_findsizes(rawfile, a->dfd,
 					   &a->dsize, &a->dbsize);
 		}
-		needcd = 1;
 	} else
 		a->dsize = 0;
 	if (logname) {
-		if (logname[0] != '/' && needcd)
-			chdir(curdir);
 		if (a->lisfile) {
 			a->logdev = libxfs_device_open(logname,
 					a->lcreat, flags, a->setblksize);
@@ -321,12 +311,9 @@ libxfs_init(libxfs_init_t *a)
 			platform_findsizes(rawfile, a->logfd,
 					   &a->logBBsize, &a->lbsize);
 		}
-		needcd = 1;
 	} else
 		a->logBBsize = 0;
 	if (rtname) {
-		if (rtname[0] != '/' && needcd)
-			chdir(curdir);
 		if (a->risfile) {
 			a->rtdev = libxfs_device_open(rtname,
 					a->rcreat, flags, a->setblksize);
@@ -342,7 +329,6 @@ libxfs_init(libxfs_init_t *a)
 			platform_findsizes(rawfile, a->rtfd,
 					   &a->rtsize, &a->rtbsize);
 		}
-		needcd = 1;
 	} else
 		a->rtsize = 0;
 	if (a->dsize < 0) {
@@ -360,8 +346,6 @@ libxfs_init(libxfs_init_t *a)
 			progname);
 		goto done;
 	}
-	if (needcd)
-		chdir(curdir);
 	if (!libxfs_bhash_size)
 		libxfs_bhash_size = LIBXFS_BHASHSIZE(sbp);
 	libxfs_bcache = cache_init(a->bcache_flags, libxfs_bhash_size,

             reply	other threads:[~2017-09-04  1:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-04  1:18 Darrick J. Wong [this message]
2017-09-08 16:41 ` [PATCH 2/2] libxfs: remove getcwd/chdir dance from initialization Eric Sandeen

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=20170904011806.GA4660@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@redhat.com \
    /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