netbsd dirent.h, import sys/sys *.h, mfs cleanup
. add all sys/sys headers not already present to help compiling . take netbsd dirent.h and struct dirent; main result is introducing d_type and d_namlen that have to be set by getdents() in all FS code implementing it . d_off is gone . alignment of the struct has become 8 bytes instead of 4 . remove _MAX_BLOCK_SIZE, _MIN_BLOCK_SIZE, _STATIC_BLOCK_SIZE . libminlib: cleanup unused yet duplicate code . mfs: throw out the long-broken v1, v2 support . new test for dirent contents filled by getdents() Change-Id: I1459755c7ba5e5d1c9396d3a587ce6e63ddc283e
This commit is contained in:
@@ -5,8 +5,8 @@ SRCS= balloc.c link.c \
|
||||
stadir.c table.c time.c utility.c \
|
||||
write.c ialloc.c inode.c main.c path.c \
|
||||
super.c
|
||||
DPADD+= ${LIBMINIXFS} ${LIBBDEV} ${LIBSYS}
|
||||
LDADD+= -lminixfs -lbdev -lsys
|
||||
DPADD+= ${LIBMINIXFS} ${LIBBDEV} ${LIBSYS} ${LIBMINLIB}
|
||||
LDADD+= -lminixfs -lbdev -lsys -lminlib
|
||||
|
||||
WARNS=3
|
||||
|
||||
|
||||
+4
-4
@@ -14,14 +14,14 @@
|
||||
#ifndef EXT2_BUF_H
|
||||
#define EXT2_BUF_H
|
||||
|
||||
#include <dirent.h>
|
||||
#include <sys/dirent.h>
|
||||
|
||||
union fsdata_u {
|
||||
char b__data[_MAX_BLOCK_SIZE]; /* ordinary user data */
|
||||
char b__data[1]; /* ordinary user data */
|
||||
/* indirect block */
|
||||
block_t b__ind[_MAX_BLOCK_SIZE/sizeof(block_t)];
|
||||
block_t b__ind[1];
|
||||
/* bit map block */
|
||||
bitchunk_t b__bitmap[FS_BITMAP_CHUNKS(_MAX_BLOCK_SIZE)];
|
||||
bitchunk_t b__bitmap[1];
|
||||
};
|
||||
|
||||
/* A block is free if b_dev == NO_DEV. */
|
||||
|
||||
+13
-8
@@ -12,6 +12,7 @@
|
||||
#include "inode.h"
|
||||
#include "super.h"
|
||||
#include <minix/vfsif.h>
|
||||
#include <minix/minlib.h>
|
||||
#include <sys/param.h>
|
||||
#include <assert.h>
|
||||
#include <sys/param.h>
|
||||
@@ -619,7 +620,7 @@ int fs_getdents(void)
|
||||
#define GETDENTS_ENTRIES 8
|
||||
static char getdents_buf[GETDENTS_BUFSIZE * GETDENTS_ENTRIES];
|
||||
struct inode *rip;
|
||||
int o, r, done;
|
||||
int r, done;
|
||||
unsigned int block_size, len, reclen;
|
||||
pino_t ino;
|
||||
cp_grant_id_t gid;
|
||||
@@ -694,11 +695,8 @@ int fs_getdents(void)
|
||||
assert(len <= NAME_MAX);
|
||||
assert(len <= EXT2_NAME_MAX);
|
||||
|
||||
/* Compute record length */
|
||||
reclen = offsetof(struct dirent, d_name) + len + 1;
|
||||
o = (reclen % sizeof(long));
|
||||
if (o != 0)
|
||||
reclen += sizeof(long) - o;
|
||||
/* Compute record length, incl alignment. */
|
||||
reclen = _DIRENT_RECLEN(dep, len);
|
||||
|
||||
/* Need the position of this entry in the directory */
|
||||
ent_pos = block_pos + ((char *)d_desc - b_data(bp));
|
||||
@@ -729,11 +727,18 @@ int fs_getdents(void)
|
||||
}
|
||||
|
||||
dep = (struct dirent *) &getdents_buf[tmpbuf_off];
|
||||
dep->d_ino = (ino_t) conv4(le_CPU, d_desc->d_ino);
|
||||
dep->d_off = (off_t) ent_pos;
|
||||
dep->d_fileno = (ino_t) conv4(le_CPU, d_desc->d_ino);
|
||||
dep->d_reclen = (unsigned short) reclen;
|
||||
dep->d_namlen = len;
|
||||
memcpy(dep->d_name, d_desc->d_name, len);
|
||||
dep->d_name[len] = '\0';
|
||||
{
|
||||
struct inode *entrip;
|
||||
if(!(entrip = get_inode(fs_dev, dep->d_fileno)))
|
||||
panic("unexpected get_inode failure");
|
||||
dep->d_type = fs_mode_to_type(entrip->i_mode);
|
||||
put_inode(entrip);
|
||||
}
|
||||
tmpbuf_off += reclen;
|
||||
}
|
||||
|
||||
|
||||
+7
-10
@@ -15,6 +15,7 @@
|
||||
#include <minix/com.h>
|
||||
#include <minix/u64.h>
|
||||
#include <minix/bdev.h>
|
||||
#include <machine/vmparam.h>
|
||||
#include "buf.h"
|
||||
#include "inode.h"
|
||||
#include "super.h"
|
||||
@@ -74,6 +75,9 @@ register struct super_block *sp; /* pointer to a superblock */
|
||||
char *buf;
|
||||
block_t gd_size; /* group descriptors table size in blocks */
|
||||
int gdt_position;
|
||||
static char superblock_buf[1024];
|
||||
|
||||
ondisk_superblock = (struct super_block *) superblock_buf;
|
||||
|
||||
dev = sp->s_dev; /* save device (will be overwritten by copy) */
|
||||
if (dev == NO_DEV)
|
||||
@@ -86,16 +90,10 @@ register struct super_block *sp; /* pointer to a superblock */
|
||||
super_block_offset = opt.block_with_super * 1024;
|
||||
}
|
||||
|
||||
STATICINIT(ondisk_superblock, 1);
|
||||
|
||||
if (!ondisk_superblock)
|
||||
panic("can't allocate memory for super_block buffers");
|
||||
|
||||
assert(_MIN_BLOCK_SIZE <= sizeof(*ondisk_superblock));
|
||||
r = bdev_read(dev, ((u64_t)(super_block_offset)), (char*) ondisk_superblock,
|
||||
_MIN_BLOCK_SIZE, BDEV_NOFLAGS);
|
||||
sizeof(superblock_buf), BDEV_NOFLAGS);
|
||||
|
||||
if (r != _MIN_BLOCK_SIZE)
|
||||
if (r != sizeof(superblock_buf))
|
||||
return(EINVAL);
|
||||
|
||||
super_copy(sp, ondisk_superblock);
|
||||
@@ -107,8 +105,7 @@ register struct super_block *sp; /* pointer to a superblock */
|
||||
|
||||
sp->s_block_size = 1024*(1<<sp->s_log_block_size);
|
||||
|
||||
if (sp->s_block_size < _MIN_BLOCK_SIZE
|
||||
|| sp->s_block_size >_MAX_BLOCK_SIZE) {
|
||||
if (sp->s_block_size < PAGE_SIZE) {
|
||||
printf("data block size (%u) is invalid\n", sp->s_block_size);
|
||||
return(EINVAL);
|
||||
}
|
||||
|
||||
@@ -100,20 +100,6 @@ void mfs_nul_f(const char *file, int line, const char *str, unsigned int len,
|
||||
file, line, #c); panic("sanity check " #c " failed: %d", __LINE__); }
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
* sanity_check *
|
||||
*===========================================================================*/
|
||||
void sanitycheck(char *file, int line)
|
||||
{
|
||||
MYASSERT(SELF_E > 0);
|
||||
if(superblock->s_dev != NO_DEV) {
|
||||
MYASSERT(superblock->s_dev == fs_dev);
|
||||
MYASSERT(superblock->s_block_size == lmfs_fs_block_size());
|
||||
} else {
|
||||
MYASSERT(_MIN_BLOCK_SIZE == lmfs_fs_block_size());
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* ansi_strcmp *
|
||||
*===========================================================================*/
|
||||
|
||||
Reference in New Issue
Block a user