Disable mixing of DMA and FIFO messages in the Solaris ESP kernel module.
[openbios.git] / fs / ext2 / ext2_open.c
blob03a89bbd0c8b5504ce588438f19ef5fbc3b33a89
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_FILE* ext2_open(ext2_VOLUME *volume, const char* pathname)
15 ext2_FILE *file;
16 struct ext2_inode *inode;
17 int ino;
18 int ret;
20 ino = ext2_seek_name(volume, pathname);
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;
33 if (S_ISLNK(inode->i_mode)) {
34 static char buffer[1024];
35 int i, last = 0;
36 strcpy(buffer, pathname);
37 for (i = 0; buffer[i]; i++)
38 if (buffer[i] == '\\')
39 last = i;
40 buffer[last] = '\\';
41 strcpy(buffer + last + 1, (char*)inode->i_block);
42 ino = ext2_seek_name((ext2_VOLUME*)volume, buffer);
43 if (ino == 0) {
44 free(inode);
45 return NULL;
47 ret = ext2_get_inode((ext2_VOLUME*)volume, ino, inode);
48 if (ret == -1) {
49 free(inode);
50 return NULL;
54 file = (ext2_FILE*)malloc(sizeof(ext2_FILE));
55 if (file == NULL) {
56 free(inode);
57 return NULL;
59 file->volume = volume;
60 file->inode = inode;
61 file->offset = 0;
62 file->path = strdup(pathname);
64 return file;