Whamcloud - gitweb
LU-1770 ptlrpc: introducing OBD_CONNECT_FLOCK_OWNER flag
[fs/lustre-release.git] / lustre / obdclass / lprocfs_status.c
index dc595f5..516d798 100644 (file)
@@ -1010,11 +1010,12 @@ static const char *obd_connect_names[] = {
         "umask",
         "einprogress",
         "grant_param",
-       "nanoseconds_times",
+       "flock_owner",
        "lvb_type",
-       "unknown",
+       "nanoseconds_times",
        "lightweight_conn",
        "short_io",
+       "unknown",
         NULL
 };
 
@@ -2332,6 +2333,52 @@ int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count,
 }
 EXPORT_SYMBOL(lprocfs_write_frac_u64_helper);
 
+static char *lprocfs_strnstr(const char *s1, const char *s2, size_t len)
+{
+       size_t l2;
+
+       l2 = strlen(s2);
+       if (!l2)
+               return (char *)s1;
+       while (len >= l2) {
+               len--;
+               if (!memcmp(s1, s2, l2))
+                       return (char *)s1;
+               s1++;
+       }
+       return NULL;
+}
+
+/**
+ * Find the string \a name in the input \a buffer, and return a pointer to the
+ * value immediately following \a name, reducing \a count appropriately.
+ * If \a name is not found the original \a buffer is returned.
+ */
+char *lprocfs_find_named_value(const char *buffer, const char *name,
+                               unsigned long *count)
+{
+       char *val;
+       size_t buflen = *count;
+
+       /* there is no strnstr() in rhel5 and ubuntu kernels */
+       val = lprocfs_strnstr(buffer, name, buflen);
+       if (val == NULL)
+               return (char *)buffer;
+
+       val += strlen(name);                             /* skip prefix */
+       while (val < buffer + buflen && isspace(*val)) /* skip separator */
+               val++;
+
+       *count = 0;
+       while (val < buffer + buflen && isalnum(*val)) {
+               ++*count;
+               ++val;
+       }
+
+       return val - *count;
+}
+EXPORT_SYMBOL(lprocfs_find_named_value);
+
 int lprocfs_seq_create(cfs_proc_dir_entry_t *parent, char *name, mode_t mode,
                        struct file_operations *seq_fops, void *data)
 {