Skip to contentSkip to conversation

provide strsep for ancient kernels

PATCH New Christoph Hellwig 2 participants 2 messages Jun 22, 2004 OCFS2

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 provide strsep for ancient kernels

super.c +1 -7
Index: src/super.c
===================================================================
@@ -435,13 +435,7 @@
 
 	LOG_TRACE_ARGS("strlen(options) = %u, options = \"%s\"\n", (unsigned int)strlen(options), options);
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-	while ( (c = strsep(&options, ",")) != NULL)
-#else
-	for (c = strtok (options, ","); c != NULL; c = strtok (NULL, ","))
-#endif
-//	while ( (c = strsep(&options, ",")) != NULL) 
-	{
+	while ((c = strsep(&options, ",")) != NULL) {
 		if ((value = strchr (c, '=')) != NULL)
 			*value++ = 0;
 		if (!strcmp (c, "gid")) {
ocfs_compat.h +13 -0
Index: src/ocfs_compat.h
===================================================================
@@ -87,6 +87,19 @@
 	sb->s_blocksize_bits = bits;
 	return sb->s_blocksize;
 }
+
+static inline char *strsep(char **s, const char *ct)
+{
+	char *sbegin = *s, *end;
+
+	if (sbegin == NULL)
+		return NULL;
+	end = strpbrk(sbegin, ct);
+	if (end)
+		*end++ = '\0';
+	*s = end;
+	return sbegin;
+}
 #endif
 
 typedef long sector_t;
#1 lore raw

PATCH 1/1 provide strsep for ancient kernels

Quoted 12 lines · Christoph Hellwig

Index: src/ocfs_compat.h
===================================================================

ocfs_compat.h +4 -0
@@ -87,6 +87,19 @@
 	sb->s_blocksize_bits = bits;
 	return sb->s_blocksize;
 }
+
+static inline char *strsep(char **s, const char *ct)
+{
+	char *sbegin = *s, *end;

ocfs_compat.h line 103

Quoted 10 lines
ocfs_compat.h +9 -0
+
+	if (sbegin == NULL)
+		return NULL;
+	end = strpbrk(sbegin, ct);
+	if (end)
+		*end++ = '\0';
+	*s = end;
+	return sbegin;
+}
 #endif

strsep actually is in AS 2.1's 2.4.9, so I didn't stick it in the compat header. This was probably a holdover from years ago, when we were look at a pretty ancient kernel tree.

-Manish