inode: only check for population after lock

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-07-05 14:36:04 +02:00
commit 72cca62821

View file

@ -11,10 +11,13 @@ static mem_cache_t *dirent_slab = NULL;
int inode_populate_dirents(inode_t *inode)
{
if (inode->dirents.head != NULL)
return -EINVAL;
write_lock(&inode->rwlock);
if (inode->dirents.head != NULL) {
write_unlock(&inode->rwlock);
return -EINVAL;
}
dirent_t *dents;
ssize_t n = inode->i_ops.get_dents(inode, &dents);