Christoph Hellwig
2004-Jun-22 07:22 UTC
[Ocfs2-devel] [PATCH] provide strsep for ancient kernels
Index: src/super.c
==================================================================---
src/super.c (revision 1182)
+++ src/super.c (working copy)
@@ -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")) {
Index: src/ocfs_compat.h
==================================================================---
src/ocfs_compat.h (revision 1182)
+++ src/ocfs_compat.h (working copy)
@@ -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;
Manish Singh
2004-Jun-22 17:54 UTC
[Ocfs2-devel] [PATCH] provide strsep for ancient kernels
On Tue, Jun 22, 2004 at 02:22:54PM +0200, Christoph Hellwig wrote:> Index: src/ocfs_compat.h > ==================================================================> --- src/ocfs_compat.h (revision 1182) > +++ src/ocfs_compat.h (working copy) > @@ -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; > +} > #endifstrsep 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