Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: Luk Claes <luk-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
To: linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org,
	Luk Claes <luk-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
Subject: [PATCH] mount.cifs: Use original device string all the way
Date: Wed,  6 Apr 2011 10:46:55 +0200	[thread overview]
Message-ID: <1302079615-14411-1-git-send-email-luk@debian.org> (raw)
In-Reply-To: <20110405160636.1e956ecf-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>

Don't construct a device name, but use the original device string
to mount so the device name in /proc/mounts matches the one in
/etc/fstab.

Signed-off-by: Luk Claes <luk-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
---
 mount.cifs.c |   27 +++------------------------
 1 files changed, 3 insertions(+), 24 deletions(-)

diff --git a/mount.cifs.c b/mount.cifs.c
index 8e1e32b..29b0d4c 100644
--- a/mount.cifs.c
+++ b/mount.cifs.c
@@ -1673,12 +1673,11 @@ int main(int argc, char **argv)
 	char *orgoptions = NULL;
 	char *mountpoint = NULL;
 	char *options = NULL;
-	char *dev_name = NULL, *orig_dev = NULL;
+	char *orig_dev = NULL;
 	char *currentaddress, *nextaddress;
 	int rc = 0;
 	int already_uppercased = 0;
 	size_t options_size = MAX_OPTIONS_LEN;
-	size_t dev_len;
 	struct parsed_mount_info *parsed_info = NULL;
 	pid_t pid;
 	const char *fstype;
@@ -1823,25 +1822,6 @@ int main(int argc, char **argv)
 		goto mount_exit;
 	}
 
-	/* lengths of different strings + slashes + trailing \0 */
-	dev_len = strnlen(parsed_info->host, sizeof(parsed_info->host)) +
-	    strnlen(parsed_info->share, sizeof(parsed_info->share)) +
-	    strnlen(parsed_info->prefix, sizeof(parsed_info->prefix)) +
-	    2 + 1 + 1 + 1;
-	dev_name = calloc(dev_len, 1);
-	if (!dev_name) {
-		rc = EX_SYSERR;
-		goto mount_exit;
-	}
-
-	/* rebuild device name with forward slashes */
-	strlcpy(dev_name, "//", dev_len);
-	strlcat(dev_name, parsed_info->host, dev_len);
-	strlcat(dev_name, "/", dev_len);
-	strlcat(dev_name, parsed_info->share, dev_len);
-	strlcat(dev_name, "/", dev_len);
-	strlcat(dev_name, parsed_info->prefix, dev_len);
-
 	currentaddress = parsed_info->addrlist;
 	nextaddress = strchr(currentaddress, ',');
 	if (nextaddress)
@@ -1889,7 +1869,7 @@ mount_retry:
 	if (parsed_info->verboseflag)
 		fprintf(stderr, "\n");
 
-	rc = check_mtab(thisprogram, dev_name, mountpoint);
+	rc = check_mtab(thisprogram, orig_dev, mountpoint);
 	if (rc)
 		goto mount_exit;
 
@@ -1900,7 +1880,7 @@ mount_retry:
 
 	if (!parsed_info->fakemnt) {
 		toggle_dac_capability(0, 1);
-		rc = mount(dev_name, ".", fstype, parsed_info->flags, options);
+		rc = mount(orig_dev, ".", fstype, parsed_info->flags, options);
 		toggle_dac_capability(0, 0);
 		if (rc == 0)
 			goto do_mtab;
@@ -1948,7 +1928,6 @@ mount_exit:
 		memset(parsed_info->password, 0, sizeof(parsed_info->password));
 		munmap(parsed_info, sizeof(*parsed_info));
 	}
-	SAFE_FREE(dev_name);
 	SAFE_FREE(options);
 	SAFE_FREE(orgoptions);
 	return rc;
-- 
1.7.4.1

  parent reply	other threads:[~2011-04-06  8:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-04 14:33 slash appended to filesystem when mtab symlinked to proc Luk Claes
     [not found] ` <4D99D6A1.7080101-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
2011-04-05 15:51   ` Jeff Layton
     [not found]     ` <20110405085147.22dc6829-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2011-04-05 22:26       ` [PATCH] mount.cifs: only convert '\' to '/' for dev_name Luk Claes
     [not found]         ` <1302042408-10579-1-git-send-email-luk-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
2011-04-05 23:06           ` Jeff Layton
     [not found]             ` <20110405160636.1e956ecf-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2011-04-06  8:46               ` Luk Claes [this message]
     [not found]                 ` <1302079615-14411-1-git-send-email-luk-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
2011-04-08 18:14                   ` [PATCH] mount.cifs: Use original device string all the way Jeff Layton

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=1302079615-14411-1-git-send-email-luk@debian.org \
    --to=luk-8fiuurrzop0dnm+yrofe0a@public.gmane.org \
    --cc=jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.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