Browse Source

hostfs: Add a BUG_ON to detect behavior changes of dentry_path_raw()

hostfs' __dentry_name() relies on the fact that dentry_path_raw() will place
the path name at the end of the provided buffer.
While this is okay, add a BUG_ON() to detect behavior changes as soon
as possible.

Signed-off-by: Richard Weinberger <richard@nod.at>
Richard Weinberger 10 years ago
parent
commit
aad50b1e06
1 changed files with 7 additions and 0 deletions
  1. 7 0
      fs/hostfs/hostfs_kern.c

+ 7 - 0
fs/hostfs/hostfs_kern.c

@@ -93,6 +93,13 @@ static char *__dentry_name(struct dentry *dentry, char *name)
 		__putname(name);
 		__putname(name);
 		return NULL;
 		return NULL;
 	}
 	}
+
+	/*
+	 * This function relies on the fact that dentry_path_raw() will place
+	 * the path name at the end of the provided buffer.
+	 */
+	BUG_ON(p + strlen(p) + 1 != name + PATH_MAX);
+
 	strlcpy(name, root, PATH_MAX);
 	strlcpy(name, root, PATH_MAX);
 	if (len > p - name) {
 	if (len > p - name) {
 		__putname(name);
 		__putname(name);