#include <lunaix/fs.h>
-#include <lunaix/fs/iso9660.h>
+#include "iso9660.h"
#include <lunaix/mm/cake.h>
#include <lunaix/mm/valloc.h>
#include <lunaix/spike.h>
#include <klibc/string.h>
-#include <usr/sys/dirent_defs.h>
+#include <usr/lunaix/dirent.h>
extern struct cake_pile* drec_cache_pile;
}
done:
- if (!cache->name.len) {
- // Load ISO9660 file id if no NM found.
- u32_t l = drec->name.len;
- while (l < (u32_t)-1 && drec->name.content[l--] != ';')
- ;
- l = (l + 1) ? l : drec->name.len;
- l = MIN(l, ISO9660_IDLEN - 1);
-
- strncpy(cache->name_val, drec->name.content, l);
- cache->name = HSTR(cache->name_val, l);
- hstr_rehash(&cache->name, HSTR_FULL_HASH);
+ if (cache->name.len) {
+ return;
}
+
+ // Load ISO9660 file id if no NM found.
+
+ ;
+ char name_val = drec->name.content[0];
+ u32_t l = drec->name.len;
+
+ if (l == 1 && !name_val) {
+ cache->name = vfs_dot;
+ return;
+ }
+
+ if(l == 1 && name_val == 1) {
+ cache->name = vfs_ddot;
+ return;
+ }
+
+ while (l < (u32_t)-1 && drec->name.content[l--] != ';')
+ ;
+
+ l = (l + 1) ? l : drec->name.len;
+ l = MIN(l, ISO9660_IDLEN - 1);
+
+ strncpy(cache->name_val, (const char*)drec->name.content, l);
+ cache->name = HSTR(cache->name_val, l);
+ hstr_rehash(&cache->name, HSTR_FULL_HASH);
}
int
iso9660_setup_dnode(struct v_dnode* dnode, struct v_inode* inode)
{
- if (!(inode->itype & VFS_IFDIR)) {
+ if (!check_directory_node(inode)) {
vfs_assign_inode(dnode, inode);
return 0;
}
do {
if (blk_offset >= ISO9660_BLKSZ - sizeof(struct iso_drecord)) {
current_pos += ISO9660_BLKSZ;
- errno = dev->read(dev, records, blk + current_pos, ISO9660_BLKSZ);
+ errno =
+ dev->ops.read(dev, records, blk + current_pos, ISO9660_BLKSZ);
if (errno < 0) {
errno = EIO;
goto done;
break;
}
- // ignore the '.', '..' as we have built-in support
- if (drec->name.len == 1) {
- goto cont;
- }
-
struct iso_drecache* cache = cake_grab(drec_cache_pile);
iso9660_fill_drecache(cache, drec, mdu->len);
llist_append(&isoino->drecaches, &cache->caches);
- cont:
+
blk_offset += mdu->len;
} while (current_pos + blk_offset < max_pos);
int
iso9660_readdir(struct v_file* file, struct dir_context* dctx)
-{
+{
struct llist_header* lead = file->dnode->data;
struct iso_drecache *pos, *n;
- u32_t counter = dctx->index - 1;
+ u32_t counter = 0;
llist_for_each(pos, n, lead, caches)
{
- if (counter == (u32_t)-1 && !(pos->flags & ISO_FHIDDEN)) {
+ if (counter == file->f_pos && !(pos->flags & ISO_FHIDDEN)) {
dctx->read_complete_callback(
- dctx, pos->name_val, pos->name.len, __get_dtype(pos));
+ dctx, HSTR_VAL(pos->name), HSTR_LEN(pos->name), __get_dtype(pos));
return 1;
}
- counter--;
+ counter++;
}
+
return 0;
}
\ No newline at end of file