so as to not pollute application namespace.
return(1);
}
- if(sp->s_magic != SUPER_V3) block_size = STATIC_BLOCK_SIZE;
+ if(sp->s_magic != SUPER_V3) block_size = _STATIC_BLOCK_SIZE;
else block_size = super.s_block_size;
- if(block_size < MIN_BLOCK_SIZE || block_size > MAX_BLOCK_SIZE) {
+ if(block_size < _MIN_BLOCK_SIZE || block_size > _MAX_BLOCK_SIZE) {
fprintf(stderr, "df: %s: funny block size (%d)\n",
mt->devname, block_size);
close(fd);
int i, b;
bit_t busy;
char *wlim;
- static char buf[MAX_BLOCK_SIZE];
+ static char buf[_MAX_BLOCK_SIZE];
static char bits_in_char[1 << CHAR_BIT];
/* Precalculate bitcount for each char. */
getsuper();
- if(block_size < MIN_BLOCK_SIZE || block_size > MAX_BLOCK_SIZE)
+ if(block_size < _MIN_BLOCK_SIZE || block_size > _MAX_BLOCK_SIZE)
fatal("funny block size");
if(!(rwbuf = malloc(block_size))) fatal("couldn't allocate fs buf (1)");
#include <stdio.h>
#include <dirent.h>
-#define BLOCK_SIZE STATIC_BLOCK_SIZE
+#define BLOCK_SIZE _STATIC_BLOCK_SIZE
#define BITSHIFT 4 /* = log2(#bits(int)) */
}
if(fs_version == 3) {
- if(!block_size) block_size = MAX_BLOCK_SIZE; /* V3 default block size */
- if(block_size%SECTOR_SIZE || block_size < MIN_BLOCK_SIZE) {
+ if(!block_size) block_size = _MAX_BLOCK_SIZE; /* V3 default block size */
+ if(block_size%SECTOR_SIZE || block_size < _MIN_BLOCK_SIZE) {
fprintf(stderr, "block size must be multiple of sector (%d) "
"and at least %d bytes\n",
- SECTOR_SIZE, MIN_BLOCK_SIZE);
+ SECTOR_SIZE, _MIN_BLOCK_SIZE);
pexit("specified block size illegal");
}
if(block_size%V2_INODE_SIZE) {
if(block_size) {
pexit("Can't specify a block size if FS version is <3");
}
- block_size = STATIC_BLOCK_SIZE; /* V1/V2 block size */
+ block_size = _STATIC_BLOCK_SIZE; /* V1/V2 block size */
}
if(!inodes_per_block)
zone_size = 1 << zone_shift; /* nr of blocks per zone */
- if (lseek(fd, (off_t) STATIC_BLOCK_SIZE, SEEK_SET) == (off_t) -1) {
+ if (lseek(fd, (off_t) _STATIC_BLOCK_SIZE, SEEK_SET) == (off_t) -1) {
pexit("super() couldn't seek");
}
- if (write(fd, buf, STATIC_BLOCK_SIZE) != STATIC_BLOCK_SIZE) {
+ if (write(fd, buf, _STATIC_BLOCK_SIZE) != _STATIC_BLOCK_SIZE) {
pexit("super() couldn't write");
}
perror("lseek");
pexit("seek failed");
}
- k = read(fd, buf, STATIC_BLOCK_SIZE);
- if (k != STATIC_BLOCK_SIZE) {
+ k = read(fd, buf, _STATIC_BLOCK_SIZE);
+ if (k != _STATIC_BLOCK_SIZE) {
pexit("get_super_block couldn't read");
}
}
ssize_t r;
struct super_block super;
swap_hdr_t swap_hdr;
- static u8_t block[MAX_BLOCK_SIZE];
+ static u8_t block[_MAX_BLOCK_SIZE];
first= 0;
i= 1;
/* Is there a file system? */
r= -1;
if (lseek(fd, SUPER_BLOCK_BYTES, SEEK_SET) == -1
- || (r= read(fd, block, STATIC_BLOCK_SIZE)) < STATIC_BLOCK_SIZE
+ || (r= read(fd, block, _STATIC_BLOCK_SIZE)) < _STATIC_BLOCK_SIZE
) {
fprintf(stderr, "mkswap: %s: %s\n",
file, r >= 0 ? "End of file" : strerror(errno));
}
memcpy(&super, block, sizeof(super));
if (super.s_magic == SUPER_MAGIC) {
- offset= (unsigned long) super.s_nzones * STATIC_BLOCK_SIZE;
+ offset= (unsigned long) super.s_nzones * _STATIC_BLOCK_SIZE;
} else
if (super.s_magic == SUPER_V2) {
- offset= (unsigned long) super.s_zones * STATIC_BLOCK_SIZE;
+ offset= (unsigned long) super.s_zones * _STATIC_BLOCK_SIZE;
} else if (super.s_magic == SUPER_V3) {
offset= (unsigned long) super.s_zones * super.s_block_size;
} else {
void swapon(file)
char *file;
{
- u32_t super[2][MAX_BLOCK_SIZE / 2 / sizeof(u32_t)];
+ u32_t super[2][_MAX_BLOCK_SIZE / 2 / sizeof(u32_t)];
swap_hdr_t *sp;
struct mmswapon mmswapon;
int fd, r;
if ((fd = open(file, O_RDWR)) < 0
|| lseek(fd, SUPER_BLOCK_BYTES, SEEK_SET) == -1
- || (r = read(fd, super, STATIC_BLOCK_SIZE)) < 0
+ || (r = read(fd, super, _STATIC_BLOCK_SIZE)) < 0
) {
err = strerror(errno);
std_err("mount: ");
sp = (swap_hdr_t *) &super[0];
if (memcmp(sp->sh_magic, MAGIC, sizeof(MAGIC)) != 0)
sp = (swap_hdr_t *) &super[1];
- if (r == STATIC_BLOCK_SIZE && memcmp(sp->sh_magic, MAGIC, sizeof(MAGIC)) != 0
+ if (r == _STATIC_BLOCK_SIZE && memcmp(sp->sh_magic, MAGIC, sizeof(MAGIC)) != 0
|| sp->sh_version > SH_VERSION) {
std_err("mount: ");
std_err(file);
#include <utime.h>
#include <dirent.h>
-#define BLOCK_SIZE STATIC_BLOCK_SIZE
+#define BLOCK_SIZE _STATIC_BLOCK_SIZE
#include <minix/config.h>
#include <minix/const.h>
/* The block size must be at least 1024 bytes, because otherwise
* the superblock (at 1024 bytes) overlaps with other filesystem data.
*/
-#define MIN_BLOCK_SIZE 1024
+#define _MIN_BLOCK_SIZE 1024
/* The below is allocated in some parts of the system as the largest
* a filesystem block can be. For instance, the boot monitor allocates
* 3 of these blocks and has to fit within 64kB, so this can't be
* increased without taking that into account.
*/
-#define MAX_BLOCK_SIZE 4096
+#define _MAX_BLOCK_SIZE 4096
/* This is the block size for the fixed versions of the filesystem (V1/V2) */
-#define STATIC_BLOCK_SIZE 1024
+#define _STATIC_BLOCK_SIZE 1024
-#define STATIC_FLEX_PER_BLOCK (STATIC_BLOCK_SIZE/sizeof(struct _fl_direct))
-#define FLEX_PER_V7 (_EXTENT(DIRSIZ) + 1)
-#define FLEX_PER_BLOCK (STATIC_BLOCK_SIZE/sizeof(struct _fl_direct))
+#define _STATIC_FLEX_PER_BLOCK (_STATIC_BLOCK_SIZE/sizeof(struct _fl_direct))
+#define _FLEX_PER_V7 (_EXTENT(DIRSIZ) + 1)
+#define _FLEX_PER_BLOCK (_STATIC_BLOCK_SIZE/sizeof(struct _fl_direct))
/* Definitions for the directory(3) routines: */
typedef struct {
short _count; /* This many objects in buf */
off_t _pos; /* Position in directory file */
struct _fl_direct *_ptr; /* Next slot in buf */
- struct _fl_direct _buf[FLEX_PER_BLOCK]; /* One block of a directory file */
- struct _fl_direct _v7f[FLEX_PER_V7]; /* V7 entry transformed to flex */
+ struct _fl_direct _buf[_FLEX_PER_BLOCK]; /* One block of a directory file */
+ struct _fl_direct _v7f[_FLEX_PER_V7]; /* V7 entry transformed to flex */
} DIR;
#define _DIRENT_NAME_LEN 61
EXTERN struct buf {
/* Data portion of the buffer. */
union {
- char b__data[MAX_BLOCK_SIZE]; /* ordinary user data */
+ char b__data[_MAX_BLOCK_SIZE]; /* ordinary user data */
/* directory block */
- struct direct b__dir[NR_DIR_ENTRIES(MAX_BLOCK_SIZE)];
+ struct direct b__dir[NR_DIR_ENTRIES(_MAX_BLOCK_SIZE)];
/* V1 indirect block */
zone1_t b__v1_ind[V1_INDIRECTS];
/* V2 indirect block */
- zone_t b__v2_ind[V2_INDIRECTS(MAX_BLOCK_SIZE)];
+ zone_t b__v2_ind[V2_INDIRECTS(_MAX_BLOCK_SIZE)];
/* V1 inode block */
d1_inode b__v1_ino[V1_INODES_PER_BLOCK];
/* V2 inode block */
- d2_inode b__v2_ino[V2_INODES_PER_BLOCK(MAX_BLOCK_SIZE)];
+ d2_inode b__v2_ino[V2_INODES_PER_BLOCK(_MAX_BLOCK_SIZE)];
/* bit map block */
- bitchunk_t b__bitmap[FS_BITMAP_CHUNKS(MAX_BLOCK_SIZE)];
+ bitchunk_t b__bitmap[FS_BITMAP_CHUNKS(_MAX_BLOCK_SIZE)];
} b;
/* Header portion of the buffer. */
#define V1_INODE_SIZE usizeof (d1_inode) /* bytes in V1 dsk ino */
/* # zones/indir block */
-#define V1_INDIRECTS (STATIC_BLOCK_SIZE/V1_ZONE_NUM_SIZE)
+#define V1_INDIRECTS (_STATIC_BLOCK_SIZE/V1_ZONE_NUM_SIZE)
/* # V1 dsk inodes/blk */
-#define V1_INODES_PER_BLOCK (STATIC_BLOCK_SIZE/V1_INODE_SIZE)
+#define V1_INODES_PER_BLOCK (_STATIC_BLOCK_SIZE/V1_INODE_SIZE)
/* Derived sizes pertaining to the V2 file system. */
#define V2_ZONE_NUM_SIZE usizeof (zone_t) /* # bytes in V2 zone */
struct super_block *sp, *dsp;
block_t b;
Dev_t image_dev;
- static char sbbuf[MIN_BLOCK_SIZE];
+ static char sbbuf[_MIN_BLOCK_SIZE];
int block_size_image, block_size_ram, ramfs_block_size;
int s;
/* Resize the RAM disk root file system. */
if (dev_io(DEV_READ, root_dev, FS_PROC_NR,
- sbbuf, SUPER_BLOCK_BYTES, MIN_BLOCK_SIZE, 0) != MIN_BLOCK_SIZE) {
+ sbbuf, SUPER_BLOCK_BYTES, _MIN_BLOCK_SIZE, 0) != _MIN_BLOCK_SIZE) {
printf("WARNING: ramdisk read for resizing failed\n");
}
dsp = (struct super_block *) sbbuf;
if (dsp->s_magic == SUPER_V3)
ramfs_block_size = dsp->s_block_size;
else
- ramfs_block_size = STATIC_BLOCK_SIZE;
+ ramfs_block_size = _STATIC_BLOCK_SIZE;
zones = (ram_size_kb * 1024 / ramfs_block_size) >> sp->s_log_zone_size;
dsp->s_nzones = conv2(sp->s_native, (u16_t) zones);
dsp->s_zones = conv4(sp->s_native, zones);
if (dev_io(DEV_WRITE, root_dev, FS_PROC_NR,
- sbbuf, SUPER_BLOCK_BYTES, MIN_BLOCK_SIZE, 0) != MIN_BLOCK_SIZE) {
+ sbbuf, SUPER_BLOCK_BYTES, _MIN_BLOCK_SIZE, 0) != _MIN_BLOCK_SIZE) {
printf("WARNING: ramdisk write for resizing failed\n");
}
}
}
/* no mounted filesystem? use this block size then. */
- return MIN_BLOCK_SIZE;
+ return _MIN_BLOCK_SIZE;
}
/*===========================================================================*
dev_t dev;
int magic;
int version, native, r;
- static char sbbuf[MIN_BLOCK_SIZE];
+ static char sbbuf[_MIN_BLOCK_SIZE];
dev = sp->s_dev; /* save device (will be overwritten by copy) */
if (dev == NO_DEV)
panic(__FILE__,"request for super_block of NO_DEV", NO_NUM);
r = dev_io(DEV_READ, dev, FS_PROC_NR,
- sbbuf, SUPER_BLOCK_BYTES, MIN_BLOCK_SIZE, 0);
- if (r != MIN_BLOCK_SIZE) {
+ sbbuf, SUPER_BLOCK_BYTES, _MIN_BLOCK_SIZE, 0);
+ if (r != _MIN_BLOCK_SIZE) {
return EINVAL;
}
memcpy(sp, sbbuf, sizeof(*sp));
* hide some of the differences.
*/
if (version == V1) {
- sp->s_block_size = STATIC_BLOCK_SIZE;
+ sp->s_block_size = _STATIC_BLOCK_SIZE;
sp->s_zones = sp->s_nzones; /* only V1 needs this copy */
sp->s_inodes_per_block = V1_INODES_PER_BLOCK;
sp->s_ndzones = V1_NR_DZONES;
sp->s_nindirs = V1_INDIRECTS;
} else {
if (version == V2)
- sp->s_block_size = STATIC_BLOCK_SIZE;
- if (sp->s_block_size < MIN_BLOCK_SIZE)
+ sp->s_block_size = _STATIC_BLOCK_SIZE;
+ if (sp->s_block_size < _MIN_BLOCK_SIZE)
return EINVAL;
sp->s_inodes_per_block = V2_INODES_PER_BLOCK(sp->s_block_size);
sp->s_ndzones = V2_NR_DZONES;
sp->s_nindirs = V2_INDIRECTS(sp->s_block_size);
}
- if (sp->s_block_size < MIN_BLOCK_SIZE) {
+ if (sp->s_block_size < _MIN_BLOCK_SIZE) {
return EINVAL;
}
- if (sp->s_block_size > MAX_BLOCK_SIZE) {
+ if (sp->s_block_size > _MAX_BLOCK_SIZE) {
printf("Filesystem block size is %d kB; maximum filesystem\n"
"block size is %d kB. This limit can be increased by recompiling.\n",
- sp->s_block_size/1024, MAX_BLOCK_SIZE/1024);
+ sp->s_block_size/1024, _MAX_BLOCK_SIZE/1024);
return EINVAL;
}
if ((sp->s_block_size % 512) != 0) {
register struct buf *bp; /* pointer to buffer to zero */
{
/* Zero a block. */
- memset(bp->b_data, 0, MAX_BLOCK_SIZE);
+ memset(bp->b_data, 0, _MAX_BLOCK_SIZE);
bp->b_dirt = DIRTY;
}