3 * (c) 2008-2009 Laurent Vivier <Laurent@lvivier.info>
5 * This file has been copied from EMILE, http://emile.sf.net
11 #include "ext2_utils.h"
13 ext2_FILE
* ext2_open(ext2_VOLUME
*volume
, const char* pathname
)
16 struct ext2_inode
*inode
;
20 ino
= ext2_seek_name(volume
, pathname
);
24 inode
= (struct ext2_inode
*)malloc(sizeof(struct ext2_inode
));
28 ret
= ext2_get_inode(volume
, ino
, inode
);
33 if (S_ISLNK(inode
->i_mode
)) {
34 static char buffer
[1024];
36 strcpy(buffer
, pathname
);
37 for (i
= 0; buffer
[i
]; i
++)
38 if (buffer
[i
] == '\\')
41 strcpy(buffer
+ last
+ 1, (char*)inode
->i_block
);
42 ino
= ext2_seek_name((ext2_VOLUME
*)volume
, buffer
);
47 ret
= ext2_get_inode((ext2_VOLUME
*)volume
, ino
, inode
);
54 file
= (ext2_FILE
*)malloc(sizeof(ext2_FILE
));
59 file
->volume
= volume
;
62 file
->path
= strdup(pathname
);