From patchwork Mon Feb 2 16:52:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shirish Pargaonkar X-Patchwork-Id: 5080 Received: from lists.samba.org (mail.samba.org [66.70.73.150]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n12HQIPr004100 for ; Mon, 2 Feb 2009 17:26:19 GMT Received: from dp.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id 91EF0163BAF for ; Mon, 2 Feb 2009 17:26:06 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on dp.samba.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.8 tests=AWL,BAYES_00, DNS_FROM_RFC_POST,SPF_PASS autolearn=no version=3.1.7 X-Original-To: linux-cifs-client@lists.samba.org Delivered-To: linux-cifs-client@lists.samba.org X-Greylist: delayed 1991 seconds by postgrey-1.24 at dp.samba.org; Mon, 02 Feb 2009 17:25:48 GMT Received: from yw-out-1718.google.com (yw-out-1718.google.com [74.125.46.154]) by lists.samba.org (Postfix) with ESMTP id 5992E163AE1 for ; Mon, 2 Feb 2009 17:25:48 +0000 (GMT) Received: by yw-out-1718.google.com with SMTP id 6so545205ywa.80 for ; Mon, 02 Feb 2009 09:25:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=7QTgsitWCtuTU8kAMa6DVbk7hADCfEd6Go3+DN3mREE=; b=Qovd07zSUFBvzCUKGTfi/89ee4e7kUCcvUPUl45X13ZoQX13AE6aCx+yLIbdmrlpKl qeLtlpLRyTwgiIc8nXfWDzmCMXZTlfVCHgotTIZm627PXjfEwO3tkBEFc0jFJOpLSwLA O04nyhDoQ2U8MhUvw8jrjlE3W5/6O2hTAOu2k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=ajlQct74COrkyvIDiPB7sjKW4HoK+ODFZW+Fv0L71KCLqhfdGp8o+3tujiLpLXeuIa sqQMutg77uvjGpwZTBkpRofVikU/VJ6a9jyM4JuibnEMv955MuvJIdO8W+UvCH12ARS3 liIcL2b+9MAeZwJTmx2DPBS7/h2A+aTIt34O4= MIME-Version: 1.0 Received: by 10.231.30.137 with SMTP id u9mr534067ibc.30.1233593568918; Mon, 02 Feb 2009 08:52:48 -0800 (PST) Date: Mon, 2 Feb 2009 10:52:48 -0600 Message-ID: <4a4634330902020852s729a613fp1890ecd045bc82b8@mail.gmail.com> Subject: [patch][linux-cifs-client] clean-up entries in /etc/mtab after unmounting a cifs filesystem From: Shirish Pargaonkar To: "linux-cifs-client@lists.samba.org" X-BeenThere: linux-cifs-client@lists.samba.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: The Linux CIFS VFS client List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-cifs-client-bounces+patchwork-cifs-client=patchwork.kernel.org@lists.samba.org Errors-To: linux-cifs-client-bounces+patchwork-cifs-client=patchwork.kernel.org@lists.samba.org Two different patches for the same functionality, to remove the remaining entry in /etc/mtab after a filesystem is unmounted by canonicalizing the supplied mountpoint on the command line. Please refer to bug 4370 in samba bugzilla. Regards, Shirish --- client.orig/umount.cifs.c 2009-02-02 04:35:20.000000000 -0600 +++ client/umount.cifs.c 2009-02-02 05:29:11.000000000 -0600 @@ -33,6 +33,7 @@ #include #include #include +#include #include "mount.h" #define UNMOUNT_CIFS_VERSION_MAJOR "0" @@ -231,6 +232,37 @@ static int remove_from_mtab(char * mount return rc; } +/* Make a canonical pathname from PATH. Returns a freshly malloced string. + It is up the *caller* to ensure that the PATH is sensible. i.e. + canonicalize ("/dev/fd0/.") returns "/dev/fd0" even though ``/dev/fd0/.'' + is not a legal pathname for ``/dev/fd0'' Anything we cannot parse + we return unmodified. */ +static char * +canonicalize (char *path) +{ + char *canonical = malloc (PATH_MAX + 1); + + if (!canonical) { + fprintf(stderr, "Error! Not enough memory!\n"); + return NULL; + } + + if (strlen(path) > PATH_MAX) { + fprintf(stderr, "Mount point string too long\n"); + return NULL; + } + + if (path == NULL) + return NULL; + + if (realpath (path, canonical)) + return canonical; + + strncpy (canonical, path, PATH_MAX); + canonical[PATH_MAX] = '\0'; + return canonical; +} + int main(int argc, char ** argv) { int c; @@ -304,7 +336,7 @@ int main(int argc, char ** argv) argv += optind; argc -= optind; - mountpoint = argv[0]; + mountpoint = canonicalize(argv[0]); if((argc < 1) || (argv[0] == NULL)) { printf("\nMissing name of unmount directory\n"); --- client.orig/umount.cifs.c 2009-02-02 04:35:20.000000000 -0600 +++ client/umount.cifs.c 2009-02-02 04:49:20.000000000 -0600 @@ -304,7 +304,7 @@ int main(int argc, char ** argv) argv += optind; argc -= optind; - mountpoint = argv[0]; + mountpoint = canonicalize(argv[0]); if((argc < 1) || (argv[0] == NULL)) { printf("\nMissing name of unmount directory\n");