The devfs directory entries are now always sorted.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12803 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -271,8 +271,22 @@ devfs_insert_in_dir(struct devfs_vnode *dir, struct devfs_vnode *vnode)
|
|||||||
if (!S_ISDIR(dir->stream.type))
|
if (!S_ISDIR(dir->stream.type))
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
vnode->dir_next = dir->stream.u.dir.dir_head;
|
// make sure the directory stays sorted alphabetically
|
||||||
dir->stream.u.dir.dir_head = vnode;
|
|
||||||
|
devfs_vnode *node = dir->stream.u.dir.dir_head, *last = NULL;
|
||||||
|
while (node && strcmp(node->name, vnode->name) < 0) {
|
||||||
|
last = node;
|
||||||
|
node = node->dir_next;
|
||||||
|
}
|
||||||
|
if (last == NULL) {
|
||||||
|
// the new vnode is the first entry in the list
|
||||||
|
vnode->dir_next = dir->stream.u.dir.dir_head;
|
||||||
|
dir->stream.u.dir.dir_head = vnode;
|
||||||
|
} else {
|
||||||
|
// insert after that node
|
||||||
|
vnode->dir_next = last->dir_next;
|
||||||
|
last->dir_next = vnode;
|
||||||
|
}
|
||||||
|
|
||||||
vnode->parent = dir;
|
vnode->parent = dir;
|
||||||
dir->modification_time = time(NULL);
|
dir->modification_time = time(NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user