Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cf28b486 authored by Jan Blunck's avatar Jan Blunck Committed by Linus Torvalds
Browse files

d_path: Make d_path() use a struct path



d_path() is used on a <dentry,vfsmount> pair.  Lets use a struct path to
reflect this.

[akpm@linux-foundation.org: fix build in mm/memory.c]
Signed-off-by: default avatarJan Blunck <jblunck@suse.de>
Acked-by: default avatarBryan Wu <bryan.wu@analog.com>
Acked-by: default avatarChristoph Hellwig <hch@infradead.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Neil Brown <neilb@suse.de>
Cc: Michael Halcrow <mhalcrow@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c32c2f63
Loading
Loading
Loading
Loading
+5 −7
Original line number Original line Diff line number Diff line
@@ -126,15 +126,13 @@ static void decode_address(char *buf, unsigned long address)
			struct vm_area_struct *vma = vml->vma;
			struct vm_area_struct *vma = vml->vma;


			if (address >= vma->vm_start && address < vma->vm_end) {
			if (address >= vma->vm_start && address < vma->vm_end) {
				char _tmpbuf[256];
				char *name = p->comm;
				char *name = p->comm;
				struct file *file = vma->vm_file;
				struct file *file = vma->vm_file;
				if (file) {

					char _tmpbuf[256];
				if (file)
					name = d_path(file->f_dentry,
					name = d_path(&file->f_path, _tmpbuf,
					              file->f_vfsmnt,
					              _tmpbuf,
						      sizeof(_tmpbuf));
						      sizeof(_tmpbuf));
				}


				/* FLAT does not have its text aligned to the start of
				/* FLAT does not have its text aligned to the start of
				 * the map while FDPIC ELF does ...
				 * the map while FDPIC ELF does ...
+1 −7
Original line number Original line Diff line number Diff line
@@ -206,16 +206,10 @@ static void bitmap_checkfree(struct bitmap *bitmap, unsigned long page)
/* copy the pathname of a file to a buffer */
/* copy the pathname of a file to a buffer */
char *file_path(struct file *file, char *buf, int count)
char *file_path(struct file *file, char *buf, int count)
{
{
	struct dentry *d;
	struct vfsmount *v;

	if (!buf)
	if (!buf)
		return NULL;
		return NULL;


	d = file->f_path.dentry;
	buf = d_path(&file->f_path, buf, count);
	v = file->f_path.mnt;

	buf = d_path(d, v, buf, count);


	return IS_ERR(buf) ? NULL : buf;
	return IS_ERR(buf) ? NULL : buf;
}
}
+3 −5
Original line number Original line Diff line number Diff line
@@ -3563,8 +3563,7 @@ static ssize_t show_file(struct device *dev, struct device_attribute *attr,


	down_read(&fsg->filesem);
	down_read(&fsg->filesem);
	if (backing_file_is_open(curlun)) {	// Get the complete pathname
	if (backing_file_is_open(curlun)) {	// Get the complete pathname
		p = d_path(curlun->filp->f_path.dentry,
		p = d_path(&curlun->filp->f_path, buf, PAGE_SIZE - 1);
				curlun->filp->f_path.mnt, buf, PAGE_SIZE - 1);
		if (IS_ERR(p))
		if (IS_ERR(p))
			rc = PTR_ERR(p);
			rc = PTR_ERR(p);
		else {
		else {
@@ -3981,8 +3980,7 @@ static int __init fsg_bind(struct usb_gadget *gadget)
		if (backing_file_is_open(curlun)) {
		if (backing_file_is_open(curlun)) {
			p = NULL;
			p = NULL;
			if (pathbuf) {
			if (pathbuf) {
				p = d_path(curlun->filp->f_path.dentry,
				p = d_path(&curlun->filp->f_path,
					curlun->filp->f_path.mnt,
					   pathbuf, PATH_MAX);
					   pathbuf, PATH_MAX);
				if (IS_ERR(p))
				if (IS_ERR(p))
					p = NULL;
					p = NULL;
+1 −1
Original line number Original line Diff line number Diff line
@@ -2853,7 +2853,7 @@ static void compat_ioctl_error(struct file *filp, unsigned int fd,
	/* find the name of the device. */
	/* find the name of the device. */
	path = (char *)__get_free_page(GFP_KERNEL);
	path = (char *)__get_free_page(GFP_KERNEL);
	if (path) {
	if (path) {
		fn = d_path(filp->f_path.dentry, filp->f_path.mnt, path, PAGE_SIZE);
		fn = d_path(&filp->f_path, path, PAGE_SIZE);
		if (IS_ERR(fn))
		if (IS_ERR(fn))
			fn = "?";
			fn = "?";
	}
	}
+5 −7
Original line number Original line Diff line number Diff line
@@ -1845,8 +1845,7 @@ static char *__d_path(struct dentry *dentry, struct vfsmount *vfsmnt,


/**
/**
 * d_path - return the path of a dentry
 * d_path - return the path of a dentry
 * @dentry: dentry to report
 * @path: path to report
 * @vfsmnt: vfsmnt to which the dentry belongs
 * @buf: buffer to return value in
 * @buf: buffer to return value in
 * @buflen: buffer length
 * @buflen: buffer length
 *
 *
@@ -1857,8 +1856,7 @@ static char *__d_path(struct dentry *dentry, struct vfsmount *vfsmnt,
 *
 *
 * "buflen" should be positive. Caller holds the dcache_lock.
 * "buflen" should be positive. Caller holds the dcache_lock.
 */
 */
char *d_path(struct dentry *dentry, struct vfsmount *vfsmnt,
char *d_path(struct path *path, char *buf, int buflen)
	     char *buf, int buflen)
{
{
	char *res;
	char *res;
	struct path root;
	struct path root;
@@ -1870,15 +1868,15 @@ char *d_path(struct dentry *dentry, struct vfsmount *vfsmnt,
	 * user wants to identify the object in /proc/pid/fd/.  The little hack
	 * user wants to identify the object in /proc/pid/fd/.  The little hack
	 * below allows us to generate a name for these objects on demand:
	 * below allows us to generate a name for these objects on demand:
	 */
	 */
	if (dentry->d_op && dentry->d_op->d_dname)
	if (path->dentry->d_op && path->dentry->d_op->d_dname)
		return dentry->d_op->d_dname(dentry, buf, buflen);
		return path->dentry->d_op->d_dname(path->dentry, buf, buflen);


	read_lock(&current->fs->lock);
	read_lock(&current->fs->lock);
	root = current->fs->root;
	root = current->fs->root;
	path_get(&current->fs->root);
	path_get(&current->fs->root);
	read_unlock(&current->fs->lock);
	read_unlock(&current->fs->lock);
	spin_lock(&dcache_lock);
	spin_lock(&dcache_lock);
	res = __d_path(dentry, vfsmnt, &root, buf, buflen);
	res = __d_path(path->dentry, path->mnt, &root, buf, buflen);
	spin_unlock(&dcache_lock);
	spin_unlock(&dcache_lock);
	path_put(&root);
	path_put(&root);
	return res;
	return res;
Loading