problem about lower symlink

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all:

I notice that if the lower dir have absolute path symlink to another lower file,
the lower origin file will be modified if we do something to this symlink in merge
layer, such as chown or chmod. It can be reproduced as these steps:

$ mkdir lower upper worker merger
$ touch lower/aa
$ ln -s $(pwd)/lower/aa $(pwd)/lower/bb
$ mount -t overlay -o lowerdir=lower,upperdir=upper,workdir=worker overlayfs merger
$ ls -l merger/aa
  -rw-r--r--. 1 root root  0 Aug 28 07:42 merger/aa
$ chmod 777 merger/bb
$ ls -l merger/aa
  -rwxrwxrwx. 1 root root  0 Aug 28 07:42 merger/aa


I have an idea to resolve this problem, we can do someting in ovl_get_link(). I.e. like that:

static const char *ovl_get_link(struct dentry *dentry,
				struct inode *inode,
				struct delayed_call *done)
{
	const struct cred *old_cred;
	const char *p;

	if (!dentry)
		return ERR_PTR(-ECHILD);

	old_cred = ovl_override_creds(dentry->d_sb);
	p = vfs_get_link(ovl_dentry_real(dentry), done);
	revert_creds(old_cred);

+	if (*p == '/')
+		return ovl_get_link_orig(ofs, p);

	return p;
}

In ovl_get_link_orig(), we can deal with three cases:
1) Link origin belongs to the lower layer:
   Find which lower layer it belongs to, then convert absolute path to relative
   path and return. We also can save the relative path in a string to ovl_inode,
   which can get directly next time;
2) Link origin belongs to the upper layer:
   No problem, do nothing;
3) Link origin not handled by overlayfs:
   Return ENOENT errno.

What do you think? Please let me know if you have some suggestiones.

Thanks,
ZhangYi.

--
To unsubscribe from this list: send the line "unsubscribe linux-unionfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux