+static inline int smfs_get_dentry_name_index(struct dentry *dentry,
+ struct qstr *str,
+ int *index)
+{
+ char *name = (char *)dentry->d_name.name;
+ unsigned long hash;
+ unsigned char c;
+ char *str_name;
+ int len = 0, name_len = 0;
+
+ name_len = dentry->d_name.len;
+ if (!name_len)
+ return 0;
+ hash = init_name_hash();
+ while (name_len--) {
+ c = *(const unsigned char *)name++;
+ if (c == ':' || c == '\0')
+ break;
+ hash = partial_name_hash(c, hash);
+ len ++;
+ }
+ str->hash = end_name_hash(hash);
+ OBD_ALLOC(str_name, len + 1);
+ memcpy(str_name, dentry->d_name.name, len);
+ str->len = len;
+ str->name = str_name;
+ if (index && c == ':') {
+ *index = simple_strtoul(name, 0, 0);
+ }
+ return 0;
+}
+
+static inline void smfs_free_dentry_name(struct qstr *str)
+{
+ char *name = (char*)str->name;
+ OBD_FREE(name, str->len + 1);
+}
+