All of lore.kernel.org
 help / color / mirror / Atom feed
* backfstype patch.
@ 2004-07-16 18:45 Hans Deragon
  2004-07-16 19:01 ` Jeff Moyer
  2004-07-17  4:16 ` raven
  0 siblings, 2 replies; 15+ messages in thread
From: Hans Deragon @ 2004-07-16 18:45 UTC (permalink / raw)
  To: autofs

Greetings.


   Remember me with my backfstype patch?  Some people commented on it, I replied 
and then never got any answers since.  Altough functional, my patch was 
questionned; the fix was not at the right place within the code (from a 
design/elegance point of view; technically it works great).  As I explained, I 
have no knowledge of the overall architecture of Autofs and unfortunatly, I do 
not have the time to get deep into it.

   Can my patch still be applied in the main branch until it is moved into a 
more appropriate area of the code?  Its still adds the new backsftype support, 
does not cause any problems, is very localized, and very usefull.  I have been 
running it since the last 2 weeks without any problems.  I am rolling it out in 
the production environment.


Best regards,
Hans Deragon
--
Consultant en informatique/Software Consultant
Deragon Informatique inc.     Open source:
http://www.deragon.biz        http://facil.qc.ca (Promotion du libre)
mailto://hans@deragon.biz     http://autopoweroff.sourceforge.net (Logiciel)

^ permalink raw reply	[flat|nested] 15+ messages in thread
* backfstype patch.
@ 2004-06-29 20:10 Hans Deragon
  2004-06-30 13:26 ` Jeff Moyer
  2004-06-30 13:31 ` Mike Waychison
  0 siblings, 2 replies; 15+ messages in thread
From: Hans Deragon @ 2004-06-29 20:10 UTC (permalink / raw)
  To: autofs

[-- Attachment #1: Type: text/plain, Size: 865 bytes --]

Greetings.


   Attached, my patch for supporting backfstype.  If the OS is Linux and cachefs 
is detected, this fs is ignored and no attempt is made to mount a cachefs kernel 
module (none exist).  This way we avoid useless error messages in syslog.

   If mounting the fstype fails or is cachefs, backfstype is then tried.

   It works fine under RHL 9.  Only one file was changed:  parse_sun.c.  The 
changes were made from the 4.1.3 branch.  Changes are very localized and I 
believe they are safe (though code inspection is always desired).

   Please confirm if my patch has been accepted.


Best regards,
Hans Deragon
--
Consultant en informatique/Software Consultant
Deragon Informatique inc.     Open source:
http://www.deragon.biz        http://facil.qc.ca (Promotion du libre)
mailto://hans@deragon.biz     http://autopoweroff.sourceforge.net (Logiciel)

[-- Attachment #2: autofs-4.1.3-backfstype.patch --]
[-- Type: text/plain, Size: 3956 bytes --]

diff -Nur autofs-4.1.3.org/modules/parse_sun.c autofs-4.1.3/modules/parse_sun.c
--- autofs-4.1.3.org/modules/parse_sun.c	2004-05-18 08:22:40.000000000 -0400
+++ autofs-4.1.3/modules/parse_sun.c	2004-06-29 14:54:49.000000000 -0400
@@ -22,7 +22,6 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <stdlib.h>
-#include <syslog.h>
 #include <string.h>
 #include <syslog.h>
 #include <ctype.h>
@@ -516,17 +515,20 @@
 static int sun_mount(const char *root, const char *name, int namelen,
 		     const char *loc, int loclen, const char *options)
 {
-	char *fstype = "nfs";	/* Default filesystem type */
+	char *fstype     = "nfs"; /* Default filesystem type */
+	char *backfstype = "nfs";	/* Default filesystem type */
+	char *curfstype = NULL;
 	int nonstrict = 1;
-	int rv;
+	int rv = -1;
 	char *mountpoint;
 	char *what;
+	char *noptions = NULL;
 
-	if (*options == '\0')
+	if (*options == '\0') {
 		options = NULL;
+  }
 
 	if (options) {
-		char *noptions;
 		const char *comma;
 		char *np;
 		int len = strlen(options) + 1;
@@ -551,6 +553,15 @@
 				fstype = alloca(typelen + 1);
 				memcpy(fstype, cp + 7, typelen);
 				fstype[typelen] = '\0';
+			} else if (strncmp("backfstype=", cp, 11) == 0) {
+				int typelen = comma - (cp + 11);
+				backfstype = alloca(typelen + 1);
+				memcpy(backfstype, cp + 11, typelen);
+				backfstype[typelen] = '\0';
+#if 0
+			} else if (strncmp("cachedir=", cp, 9) == 0) {
+        /* Ignoring cachedir, since cachefs is not supported. */
+#endif
 			} else if (strncmp("strict", cp, 6) == 0) {
 				nonstrict = 0;
 			} else if (strncmp("nonstrict", cp, 9) == 0) {
@@ -589,17 +600,64 @@
 		what[loclen] = '\0';
 	}
 
-	debug(MODPREFIX
-	    "mounting root %s, mountpoint %s, what %s, fstype %s, options %s\n",
-	    root, mountpoint, what, fstype, options);
-
-	if (!strcmp(fstype, "nfs")) {
-		rv = mount_nfs->mount_mount(root, mountpoint, strlen(mountpoint),
-					    what, fstype, options, mount_nfs->context);
-	} else {
-		/* Generic mount routine */
-		rv = do_mount(root, mountpoint, strlen(mountpoint), what, fstype,
-			      options);
+	int index;
+	char *curoptions = NULL;
+	char *start, *end;
+	for (index=0; index<2; index++) {
+		if (index==0)
+			curfstype=fstype;
+		else
+			curfstype=backfstype;
+
+#ifdef __linux__
+		if (!strcmp(curfstype, "cachefs")) {
+			/* cachefs not supported for Linux.  We do not even try because when
+			   we try, mount will complain about the module being absent.  This is
+			   not desired because if backfstype parameter is provided and works,
+			   we sure do not want any error messages reported to syslog. */
+			debug("cachefs not implemented under Linux and thus ignored.");
+			continue;
+		}
+#endif
+
+		if (!strcmp(curfstype, "nfs")) {
+			/* Removing cachedir parameter which is not understood by nfs. */
+			start=strstr(noptions, ",cachedir=");
+			if (start != NULL) {
+				/* cachedir parameter found.  Now removing it. */
+				int noptions_len=strlen(noptions);
+				end=strstr(start+1, ",");
+				curoptions = alloca(noptions_len-(end-start)+1);
+				strncpy(curoptions, noptions, start-noptions);
+				strncpy(curoptions+(start-noptions), end, noptions_len-(end-noptions));
+			} else {
+				/* No cachedir parameter found.  Using noptions as is. */
+				curoptions=noptions;
+			}
+		}
+		else
+			curoptions=noptions;
+
+		/* Updating options for calling function. */
+		options=curoptions;
+
+		debug(MODPREFIX
+				"mounting root %s, mountpoint %s, what %s, fstype %s, options %s\n",
+				root, mountpoint, what, curfstype, curoptions);
+
+		if (!strcmp(curfstype, "nfs")) {
+			rv = mount_nfs->mount_mount(root, mountpoint, strlen(mountpoint),
+			                what, curfstype, curoptions, mount_nfs->context);
+		} else {
+			/* Generic mount routine */
+			rv = do_mount(root, mountpoint, strlen(mountpoint), what, curfstype,
+			              curoptions);
+		}
+
+		if(!rv)
+		{
+			break;
+		}
 	}
 
 	if (nonstrict && rv) {

[-- Attachment #3: Type: text/plain, Size: 140 bytes --]

_______________________________________________
autofs mailing list
autofs@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/autofs

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2005-03-03  2:15 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-16 18:45 backfstype patch Hans Deragon
2004-07-16 19:01 ` Jeff Moyer
2005-03-02 21:03   ` Greg Bradner
2005-03-03  2:15     ` Ian Kent
2004-07-17  4:16 ` raven
  -- strict thread matches above, loose matches on Subject: below --
2004-06-29 20:10 Hans Deragon
2004-06-30 13:26 ` Jeff Moyer
2004-06-30 14:00   ` raven
2004-06-30 15:01   ` Hans Deragon
2004-06-30 13:31 ` Mike Waychison
2004-06-30 13:51   ` Jeff Moyer
2004-06-30 14:20     ` Mike Waychison
2004-06-30 14:22       ` Jeff Moyer
2004-06-30 15:11       ` Hans Deragon
2004-06-30 14:28     ` Mike Waychison

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.