mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-25 16:11:45 +00:00
userns: Simplify insert_extent
Consolidate the code to write to the new mapping at the end of the function to remove the duplication. Move the increase in the number of mappings into insert_extent, keeping the logic together. Just a small increase in readability and maintainability. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
This commit is contained in:
parent
ece6613397
commit
3fda0e737e
1 changed files with 8 additions and 11 deletions
|
@ -758,12 +758,7 @@ static bool mappings_overlap(struct uid_gid_map *new_map,
|
||||||
*/
|
*/
|
||||||
static int insert_extent(struct uid_gid_map *map, struct uid_gid_extent *extent)
|
static int insert_extent(struct uid_gid_map *map, struct uid_gid_extent *extent)
|
||||||
{
|
{
|
||||||
if (map->nr_extents < UID_GID_MAP_MAX_BASE_EXTENTS) {
|
struct uid_gid_extent *dest;
|
||||||
map->extent[map->nr_extents].first = extent->first;
|
|
||||||
map->extent[map->nr_extents].lower_first = extent->lower_first;
|
|
||||||
map->extent[map->nr_extents].count = extent->count;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (map->nr_extents == UID_GID_MAP_MAX_BASE_EXTENTS) {
|
if (map->nr_extents == UID_GID_MAP_MAX_BASE_EXTENTS) {
|
||||||
struct uid_gid_extent *forward;
|
struct uid_gid_extent *forward;
|
||||||
|
@ -784,9 +779,13 @@ static int insert_extent(struct uid_gid_map *map, struct uid_gid_extent *extent)
|
||||||
map->reverse = NULL;
|
map->reverse = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
map->forward[map->nr_extents].first = extent->first;
|
if (map->nr_extents < UID_GID_MAP_MAX_BASE_EXTENTS)
|
||||||
map->forward[map->nr_extents].lower_first = extent->lower_first;
|
dest = &map->extent[map->nr_extents];
|
||||||
map->forward[map->nr_extents].count = extent->count;
|
else
|
||||||
|
dest = &map->forward[map->nr_extents];
|
||||||
|
|
||||||
|
*dest = *extent;
|
||||||
|
map->nr_extents++;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -968,8 +967,6 @@ static ssize_t map_write(struct file *file, const char __user *buf,
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out;
|
goto out;
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
|
||||||
new_map.nr_extents++;
|
|
||||||
}
|
}
|
||||||
/* Be very certaint the new map actually exists */
|
/* Be very certaint the new map actually exists */
|
||||||
if (new_map.nr_extents == 0)
|
if (new_map.nr_extents == 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue