* [PATCH 1/4] Overlayfs: Convert S_ISDIR(dentry->d_inode) to d_is_dir()/d_can_lookup()
@ 2015-04-16 14:42 David Howells
2015-04-16 14:45 ` David Howells
0 siblings, 1 reply; 3+ messages in thread
From: David Howells @ 2015-04-16 14:42 UTC (permalink / raw)
To: viro, miklos; +Cc: dhowells, linux-fsdevel, linux-unionfs
Convert S_ISDIR(dentry->d_inode) to d_is_dir(dentry) or d_can_lookup(dentry)
as appropriate. This is slightly complicated as there are two options for
directories. The difference is whether the directory in question is a real
dir with a ->lookup op or whether it's a fake dir with a ->d_automount op.
Note that if there is a directory at this position, in both overlayfs and
unionmount it must be represented as a directory inode in the union layer and
will not be represented as a dentry with NULL ->d_inode with a fallthrough.
This means that the d_is_dir() and d_can_lookup() tests are safe no matter
whether we're looking at overlayfs's own inodes or its subordinate inodes.
Signed-off-by: David Howells <dhowells@redhat.com>
---
fs/overlayfs/inode.c | 2 +-
fs/overlayfs/super.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 04f124884687..8c8f024edcc0 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -239,7 +239,7 @@ static bool ovl_need_xattr_filter(struct dentry *dentry,
enum ovl_path_type type)
{
if ((type & (__OVL_PATH_PURE | __OVL_PATH_UPPER)) == __OVL_PATH_UPPER)
- return S_ISDIR(dentry->d_inode->i_mode);
+ return d_is_dir(dentry);
else
return false;
}
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 5f0d1993e6e3..d5f7117caf5e 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -76,7 +76,7 @@ enum ovl_path_type ovl_path_type(struct dentry *dentry)
type = __OVL_PATH_UPPER;
if (oe->numlower) {
- if (S_ISDIR(dentry->d_inode->i_mode))
+ if (d_is_dir(dentry))
type |= __OVL_PATH_MERGE;
} else if (!oe->opaque) {
type |= __OVL_PATH_PURE;
@@ -395,8 +395,8 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
if (i < poe->numlower - 1 && ovl_is_opaquedir(this))
opaque = true;
- if (prev && (!S_ISDIR(prev->d_inode->i_mode) ||
- !S_ISDIR(this->d_inode->i_mode))) {
+ if (prev && (!d_is_dir(prev) ||
+ !d_is_dir(this))) {
/*
* FIXME: check for upper-opaqueness maybe better done
* in remove code.
@@ -731,7 +731,7 @@ static int ovl_mount_dir_noesc(const char *name, struct path *path)
pr_err("overlayfs: filesystem on '%s' not supported\n", name);
goto out_put;
}
- if (!S_ISDIR(path->dentry->d_inode->i_mode)) {
+ if (!d_can_lookup(path->dentry)) {
pr_err("overlayfs: '%s' not a directory\n", name);
goto out_put;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 1/4] Overlayfs: Convert S_ISDIR(dentry->d_inode) to d_is_dir()/d_can_lookup()
2015-04-16 14:42 [PATCH 0/4] Overlayfs: Wrap ->d_inode David Howells
@ 2015-04-16 14:42 ` David Howells
0 siblings, 0 replies; 3+ messages in thread
From: David Howells @ 2015-04-16 14:42 UTC (permalink / raw)
To: viro, miklos; +Cc: dhowells, linux-fsdevel, linux-unionfs
Convert S_ISDIR(dentry->d_inode) to d_is_dir(dentry) or d_can_lookup(dentry)
as appropriate. This is slightly complicated as there are two options for
directories. The difference is whether the directory in question is a real
dir with a ->lookup op or whether it's a fake dir with a ->d_automount op.
Note that if there is a directory at this position, in both overlayfs and
unionmount it must be represented as a directory inode in the union layer and
will not be represented as a dentry with NULL ->d_inode with a fallthrough.
This means that the d_is_dir() and d_can_lookup() tests are safe no matter
whether we're looking at overlayfs's own inodes or its subordinate inodes.
Signed-off-by: David Howells <dhowells@redhat.com>
---
fs/overlayfs/inode.c | 2 +-
fs/overlayfs/super.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 04f124884687..8c8f024edcc0 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -239,7 +239,7 @@ static bool ovl_need_xattr_filter(struct dentry *dentry,
enum ovl_path_type type)
{
if ((type & (__OVL_PATH_PURE | __OVL_PATH_UPPER)) == __OVL_PATH_UPPER)
- return S_ISDIR(dentry->d_inode->i_mode);
+ return d_is_dir(dentry);
else
return false;
}
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 5f0d1993e6e3..d5f7117caf5e 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -76,7 +76,7 @@ enum ovl_path_type ovl_path_type(struct dentry *dentry)
type = __OVL_PATH_UPPER;
if (oe->numlower) {
- if (S_ISDIR(dentry->d_inode->i_mode))
+ if (d_is_dir(dentry))
type |= __OVL_PATH_MERGE;
} else if (!oe->opaque) {
type |= __OVL_PATH_PURE;
@@ -395,8 +395,8 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
if (i < poe->numlower - 1 && ovl_is_opaquedir(this))
opaque = true;
- if (prev && (!S_ISDIR(prev->d_inode->i_mode) ||
- !S_ISDIR(this->d_inode->i_mode))) {
+ if (prev && (!d_is_dir(prev) ||
+ !d_is_dir(this))) {
/*
* FIXME: check for upper-opaqueness maybe better done
* in remove code.
@@ -731,7 +731,7 @@ static int ovl_mount_dir_noesc(const char *name, struct path *path)
pr_err("overlayfs: filesystem on '%s' not supported\n", name);
goto out_put;
}
- if (!S_ISDIR(path->dentry->d_inode->i_mode)) {
+ if (!d_can_lookup(path->dentry)) {
pr_err("overlayfs: '%s' not a directory\n", name);
goto out_put;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/4] Overlayfs: Convert S_ISDIR(dentry->d_inode) to d_is_dir()/d_can_lookup()
2015-04-16 14:42 [PATCH 1/4] Overlayfs: Convert S_ISDIR(dentry->d_inode) to d_is_dir()/d_can_lookup() David Howells
@ 2015-04-16 14:45 ` David Howells
0 siblings, 0 replies; 3+ messages in thread
From: David Howells @ 2015-04-16 14:45 UTC (permalink / raw)
Cc: dhowells, viro, miklos, linux-fsdevel, linux-unionfs
Ignore this - I forgot to attach the cover note.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-04-16 14:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-16 14:42 [PATCH 1/4] Overlayfs: Convert S_ISDIR(dentry->d_inode) to d_is_dir()/d_can_lookup() David Howells
2015-04-16 14:45 ` David Howells
-- strict thread matches above, loose matches on Subject: below --
2015-04-16 14:42 [PATCH 0/4] Overlayfs: Wrap ->d_inode David Howells
2015-04-16 14:42 ` [PATCH 1/4] Overlayfs: Convert S_ISDIR(dentry->d_inode) to d_is_dir()/d_can_lookup() David Howells
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).