diff options
author | Joel Becker <joel.becker@oracle.com> | 2008-07-17 18:21:29 -0400 |
---|---|---|
committer | Joel Becker <joel.becker@oracle.com> | 2008-07-17 18:21:29 -0400 |
commit | a6795e9ebb420d87af43789174689af0d66d1d35 (patch) | |
tree | fb2a86ad010015fdd311f3b7f6ef30f60c14b8f7 /fs/configfs/dir.c | |
parent | f89ab8619e5320cc9c2576f5f8dcbaf6c0ba3950 (diff) |
configfs: Allow ->make_item() and ->make_group() to return detailed errors.
The configfs operations ->make_item() and ->make_group() currently
return a new item/group. A return of NULL signifies an error. Because
of this, -ENOMEM is the only return code bubbled up the stack.
Multiple folks have requested the ability to return specific error codes
when these operations fail. This patch adds that ability by changing the
->make_item/group() ops to return ERR_PTR() values. These errors are
bubbled up appropriately. NULL returns are changed to -ENOMEM for
compatibility.
Also updated are the in-kernel users of configfs.
This is a rework of reverted commit 11c3b79218390a139f2d474ee1e983a672d5839a.
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs/configfs/dir.c')
-rw-r--r-- | fs/configfs/dir.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index 614e382a6049..179589be063a 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c | |||
@@ -1027,9 +1027,10 @@ EXPORT_SYMBOL(configfs_undepend_item); | |||
1027 | 1027 | ||
1028 | static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | 1028 | static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) |
1029 | { | 1029 | { |
1030 | int ret, module_got = 0; | 1030 | int ret = 0; |
1031 | struct config_group *group; | 1031 | int module_got = 0; |
1032 | struct config_item *item; | 1032 | struct config_group *group = NULL; |
1033 | struct config_item *item = NULL; | ||
1033 | struct config_item *parent_item; | 1034 | struct config_item *parent_item; |
1034 | struct configfs_subsystem *subsys; | 1035 | struct configfs_subsystem *subsys; |
1035 | struct configfs_dirent *sd; | 1036 | struct configfs_dirent *sd; |
@@ -1070,28 +1071,32 @@ static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
1070 | snprintf(name, dentry->d_name.len + 1, "%s", dentry->d_name.name); | 1071 | snprintf(name, dentry->d_name.len + 1, "%s", dentry->d_name.name); |
1071 | 1072 | ||
1072 | mutex_lock(&subsys->su_mutex); | 1073 | mutex_lock(&subsys->su_mutex); |
1073 | group = NULL; | ||
1074 | item = NULL; | ||
1075 | if (type->ct_group_ops->make_group) { | 1074 | if (type->ct_group_ops->make_group) { |
1076 | group = type->ct_group_ops->make_group(to_config_group(parent_item), name); | 1075 | group = type->ct_group_ops->make_group(to_config_group(parent_item), name); |
1077 | if (group) { | 1076 | if (!group) |
1077 | group = ERR_PTR(-ENOMEM); | ||
1078 | if (!IS_ERR(group)) { | ||
1078 | link_group(to_config_group(parent_item), group); | 1079 | link_group(to_config_group(parent_item), group); |
1079 | item = &group->cg_item; | 1080 | item = &group->cg_item; |
1080 | } | 1081 | } else |
1082 | ret = PTR_ERR(group); | ||
1081 | } else { | 1083 | } else { |
1082 | item = type->ct_group_ops->make_item(to_config_group(parent_item), name); | 1084 | item = type->ct_group_ops->make_item(to_config_group(parent_item), name); |
1083 | if (item) | 1085 | if (!item) |
1086 | item = ERR_PTR(-ENOMEM); | ||
1087 | if (!IS_ERR(item)) | ||
1084 | link_obj(parent_item, item); | 1088 | link_obj(parent_item, item); |
1089 | else | ||
1090 | ret = PTR_ERR(item); | ||
1085 | } | 1091 | } |
1086 | mutex_unlock(&subsys->su_mutex); | 1092 | mutex_unlock(&subsys->su_mutex); |
1087 | 1093 | ||
1088 | kfree(name); | 1094 | kfree(name); |
1089 | if (!item) { | 1095 | if (ret) { |
1090 | /* | 1096 | /* |
1091 | * If item == NULL, then link_obj() was never called. | 1097 | * If item == NULL, then link_obj() was never called. |
1092 | * There are no extra references to clean up. | 1098 | * There are no extra references to clean up. |
1093 | */ | 1099 | */ |
1094 | ret = -ENOMEM; | ||
1095 | goto out_put; | 1100 | goto out_put; |
1096 | } | 1101 | } |
1097 | 1102 | ||