ppc64: Don't set Kp bit on SLB
[openbios.git] / fs / ext2 / ext2_opendir.c
blob3363e0b3a68907a463af6f95086375731d7ffaf6
1 /*
3 * (c) 2008-2009 Laurent Vivier <Laurent@lvivier.info>
5 * This file has been copied from EMILE, http://emile.sf.net
7 */
9 #include "libext2.h"
10 #include "ext2.h"
11 #include "ext2_utils.h"
13 ext2_DIR* ext2_opendir(ext2_VOLUME *volume, const char *name)
15 ext2_DIR* dir;
16 int ino;
17 struct ext2_inode *inode;
18 int ret;
20 ino = ext2_seek_name(volume, name);
21 if (ino == 0)
22 return NULL;
24 inode = (struct ext2_inode*)malloc(sizeof(struct ext2_inode));
25 if (inode == NULL)
26 return NULL;
28 ret = ext2_get_inode(volume, ino, inode);
29 if (ret == -1) {
30 free(inode);
31 return NULL;
34 if (!S_ISDIR(inode->i_mode)) {
35 free(inode);
36 return NULL;
39 dir = (ext2_DIR*)malloc(sizeof(ext2_DIR));
40 if (dir == NULL) {
41 free(inode);
42 return NULL;
44 dir->volume = (ext2_VOLUME*)volume;
45 dir->inode = inode;
46 dir->index = 0;
48 return dir;