Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 295473
b: refs/heads/master
c: 60f126d
h: refs/heads/master
i:
  295471: 8c8cca9
v: v3
  • Loading branch information
Eric W. Biederman committed Feb 2, 2012
1 parent f880e89 commit 64df37a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0eb97f38d2bfaea289b44c5140a7b04e7b369bad
refs/heads/master: 60f126d93b210ae708e2a5bb4a3be2121831f2a0
16 changes: 16 additions & 0 deletions trunk/fs/proc/proc_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ static int namecmp(const char *name1, int len1, const char *name2, int len2)
return cmp;
}

/* Called under sysctl_lock */
static struct ctl_table *find_entry(struct ctl_table_header **phead,
struct ctl_dir *dir, const char *name, int namelen)
{
Expand Down Expand Up @@ -864,6 +865,18 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
return new;
}

/**
* get_subdir - find or create a subdir with the specified name.
* @dir: Directory to create the subdirectory in
* @name: The name of the subdirectory to find or create
* @namelen: The length of name
*
* Takes a directory with an elevated reference count so we know that
* if we drop the lock the directory will not go away. Upon success
* the reference is moved from @dir to the returned subdirectory.
* Upon error an error code is returned and the reference on @dir is
* simply dropped.
*/
static struct ctl_dir *get_subdir(struct ctl_dir *dir,
const char *name, int namelen)
{
Expand All @@ -885,12 +898,14 @@ static struct ctl_dir *get_subdir(struct ctl_dir *dir,
if (!new)
goto failed;

/* Was the subdir added while we dropped the lock? */
subdir = find_subdir(dir, name, namelen);
if (!IS_ERR(subdir))
goto found;
if (PTR_ERR(subdir) != -ENOENT)
goto failed;

/* Nope. Use the our freshly made directory entry. */
err = insert_header(dir, &new->header);
subdir = ERR_PTR(err);
if (err)
Expand Down Expand Up @@ -1190,6 +1205,7 @@ struct ctl_table_header *__register_sysctl_table(

spin_lock(&sysctl_lock);
dir = &set->dir;
/* Reference moved down the diretory tree get_subdir */
dir->header.nreg++;
spin_unlock(&sysctl_lock);

Expand Down

0 comments on commit 64df37a

Please sign in to comment.