--- a/src/server/safs/service.c Sat Mar 16 23:11:34 2013 +0100 +++ b/src/server/safs/service.c Sun Mar 17 12:47:59 2013 +0100 @@ -107,15 +107,6 @@ net_sendfile(sn->csd, &sfd); vfs_close(fd); - - - /* send file*/ - //SystemIOStream *io = (SystemIOStream*) sn->csd; - //off_t fileoffset = 0; - //int len = atoi(pblock_findkeyval(pb_key_content_length, rq->srvhdrs)); - //sendfile(io->fd, fd->fd, &fileoffset, len); - - //close(fd); return REQ_PROCEED; } @@ -139,30 +130,9 @@ sstr_t r_uri = sstr(uri); /* open the file */ - int fd = open(ppath, O_RDONLY); - if(fd < 0) { - //perror("service_index: open"); - - int status = 500; - switch(errno) { - case EACCES: { - status = 403; - break; - } - case ENOENT: { - status = 404; - break; - } - } - protocol_status(sn, rq, status, NULL); - //printf("REQ_ABORTED\n"); - return REQ_ABORTED; - } - - DIR *dir = fdopendir(fd); - if(dir == NULL) { - protocol_status(sn, rq, 500, NULL); - //printf("DIR is null\n"); + VFSContext *vfs = vfs_request_context(sn, rq); + VFS_DIR dir = vfs_opendir(vfs, ppath); + if(!dir) { return REQ_ABORTED; } @@ -175,13 +145,14 @@ sbuf_puts(out, uri); sbuf_puts(out, "</h1><hr>\n\n"); - struct dirent *f; - while((f = readdir(dir)) != NULL) { - if(strcmp(f->d_name, ".") == 0 || strcmp(f->d_name, "..") == 0) { + //struct dirent *f; + VFS_ENTRY f; + while((vfs_readdir(dir, &f)) != NULL) { + if(strcmp(f.name, ".") == 0 || strcmp(f.name, "..") == 0) { continue; } - - sstr_t filename = sstr(f->d_name); + + sstr_t filename = sstr(f.name); sbuf_puts(out, "<a href=\""); sbuf_append(out, r_uri); @@ -203,7 +174,7 @@ net_write(sn->csd, out->ptr, out->length); /* close */ - closedir(dir); + vfs_closedir(dir); sbuf_free(out); return REQ_PROCEED;