}
if (!data->log_connected) {
#if defined(__minix)
- if(ioctl(data->log_file, NWIOSUDSTADDR, (void *) &sun) < 0)
+ if(ioctl(data->log_file, NWIOSUDSTADDR, __UNCONST(&sun)) < 0)
#else
if (connect(data->log_file,
lpuffs_debug("%"PRIu64": %d %s %u %u\n",
ino,
pn_cur->pn_count,
- pn_cur->pn_po.po_path,
+ (char *)pn_cur->pn_po.po_path,
pn_cur->pn_po.po_len,
pn_cur->pn_po.po_hash);
}
r = fsdriver_copyout(data, 0, path, bytes);
- return (r == OK) ? bytes : r;
+ return (r == OK) ? (ssize_t)bytes : r;
}
/* Copy the link name's last component */
pcn.pcn_namelen = strlen(name);
- if (pcn.pcn_namelen <= NAME_MAX);
+ if (pcn.pcn_namelen > NAME_MAX)
+ return(ENAMETOOLONG);
strcpy(pcn.pcn_name, name);
if (bytes >= PATH_MAX)
-# LSC For nwo
-NOGCCERROR:= yes
-
PROG= backup
MAN=
# malloc() and its relatives (most do).
#
#DEFS = -DUNIX -DMALLOCH
-#LSC For now...
-NOGCCERROR:= yes
-
DEFS= -DUNIX -DUSG -DSTDLIB
CPPFLAGS+= ${DEFS}
-# LSC For now
-NOGCCERROR:= yes
PROG= cleantmp
MAN=
-# LSC For Now...
-NOGCCERROR:= yes
PROG= compress
MAN=
# Makefile for cron.
-
-# LSC For Now...
-NOGCCERROR:=yes
PROG= cron
SRCS= cron.c tab.c misc.c
MAN=
.include <bsd.own.mk>
-# LSC For now...
-NOGCCERROR:= yes
-
PROG= crontab
SRCS= crontab.c tab.c misc.c
CPPFLAGS+= -I${.CURDIR} -I${NETBSDSRCDIR}/minix/commands/cron
#include <sys/ioctl.h>
#include <limits.h>
#include <stdint.h>
+#include <inttypes.h>
#include <assert.h>
#ifdef __minix
printf("%3d ", (n-1) / 2);
show_chs(p->lowsec);
show_chs(p->lowsec + p->size - 1);
- printf(" %8u %8u %7u\n", p->lowsec, p->size, p->size / 2);
+ printf(" %8"PRIu32" %8"PRIu32" %7"PRIu32"\n",
+ p->lowsec, p->size, p->size / 2);
}
void usage(void)
#include <assert.h>
#include <ctype.h>
#include <partition.h>
+#include <inttypes.h>
#include <sys/stat.h>
}
if(!(dirnodes = malloc(sizeof(*dirnodes)*reserved_dirnodes))) {
- fprintf(stderr, "couldn't allocate dirnodes (%d bytes)\n",
+ fprintf(stderr, "couldn't allocate dirnodes (%zu bytes)\n",
sizeof(*dirnodes)*reserved_dirnodes);
exit(1);
}
if(*bytes % ISO_SECTOR) {
ssize_t x;
x = ISO_SECTOR-(*bytes % ISO_SECTOR);
- write(fd, block, x);
+ Write(fd, block, x);
*bytes += x;
}
if(total != entry.recordsize || (total % 2) != 0) {
printf("%2d, %2d! ", total, entry.recordsize);
- printf("%3d = %3d - %2d + %2d\n",
+ printf("%3d = %3zu - %2zu + %2d\n",
entry.recordsize, sizeof(entry), sizeof(entry.name), namelen);
}
exit(1);
}
- fprintf(stderr, " * appended sector info: 0x%llx len 0x%x\n",
+ fprintf(stderr,
+ " * appended sector info: 0x%"PRIx64" len 0x%x\n",
bap[0].sector, bap[0].length);
addr = buf;
w += Writefield(fd, bootrecord.zero2);
if(w != ISO_SECTOR) {
- fprintf(stderr, "WARNING: something went wrong - boot record (%d) isn't a sector size (%d)\n",
+ fprintf(stderr, "WARNING: something went wrong - "
+ "boot record (%zd) isn't a sector size (%d)\n",
w, ISO_SECTOR);
}
if(sizeof(struct pvd) != ISO_SECTOR) {
fprintf(stderr, "Something confusing happened at\n"
- "compile-time; pvd should be a sector size. %d != %d\n",
- sizeof(struct pvd), ISO_SECTOR);
+ "compile-time; pvd should be a sector size. "
+ "%zd != %d\n", sizeof(struct pvd), ISO_SECTOR);
return 1;
}
CPPFLAGS+= -I${NETBSDSRCDIR}
-NOCLANGERROR=yes
-
.include <minix.service.mk>
#define CAL_COEF_FIRST AC1_MSB_REG
#define CAL_COEF_LAST MD_LSB_REG
-#define CAL_COEF_IS_VALID(x) (x != 0x0000 && x != 0xffff)
+#define CAL_COEF_IS_VALID(x) (x != 0x0000 && (uint16_t)x != 0xffff)
#define SENSOR_VAL_MSB_REG 0xf6
#define SENSOR_VAL_LSB_REG 0xf7
char type[MNTNAMELEN], char flags[MNTFLAGLEN]);
int servxcheck(unsigned long peer, const char *service,
void (*logf)(int pass, const char *name));
-char *servxfile(const char *file);
+const char *servxfile(const char *file);
/* read_tsc() and friends */
void read_tsc(u32_t *hi, u32_t *lo);
# Makefile for the common audio framework
-NOGCCERROR=yes
-
CPPFLAGS+= -D_MINIX_SYSTEM
LIB= audiodriver
static int get_started(sub_dev_t *sub_dev_ptr);
static int io_ctl_length(int io_request);
static special_file_t* get_special_file(int minor_dev_nr);
+#if defined(__i386__)
static void tell_dev(vir_bytes buf, size_t size, int pci_bus,
int pci_dev, int pci_func);
+#endif
static char io_ctl_buf[IOCPARM_MASK];
static int irq_hook_id = 0; /* id of irq hook at the kernel */
return NULL;
}
+#if defined(__i386__)
static void tell_dev(vir_bytes buf, size_t size, int pci_bus,
int pci_dev, int pci_func)
{
return;
}
}
+#endif
# Makefile for libbdev
.include <bsd.own.mk>
-NOGCCERROR=yes
-
CPPFLAGS+= -D_MINIX_SYSTEM
LIB= bdev
return FALSE;
}
-static int bdev_opcl(int req, dev_t dev, int access)
+static int bdev_opcl(int req, dev_t dev, int bits)
{
/* Open or close the given minor device.
*/
memset(&m, 0, sizeof(m));
m.m_type = req;
m.m_lbdev_lblockdriver_msg.minor = minor(dev);
- m.m_lbdev_lblockdriver_msg.access = access;
+ m.m_lbdev_lblockdriver_msg.access = bits;
r = bdev_sendrec(dev, &m);
} while (bdev_retry(&driver_tries, NULL, &r));
return r;
}
-int bdev_open(dev_t dev, int access)
+int bdev_open(dev_t dev, int bits)
{
/* Open the given minor device.
* File system usage note: typically called from mount, after bdev_driver.
*/
int r;
- r = bdev_opcl(BDEV_OPEN, dev, access);
+ r = bdev_opcl(BDEV_OPEN, dev, bits);
if (r == OK)
- bdev_minor_add(dev, access);
+ bdev_minor_add(dev, bits);
return r;
}
*/
endpoint_t endpt;
cp_grant_id_t grant;
- int access;
+ int perm;
assert((ssize_t) count >= 0);
if ((endpt = bdev_driver_get(dev)) == NONE)
return EDEADSRCDST;
- access = (req == BDEV_READ) ? CPF_WRITE : CPF_READ;
+ perm = (req == BDEV_READ) ? CPF_WRITE : CPF_READ;
- grant = cpf_grant_direct(endpt, (vir_bytes) buf, count, access);
+ grant = cpf_grant_direct(endpt, (vir_bytes) buf, count, perm);
if (!GRANT_VALID(grant)) {
printf("bdev: unable to allocate grant!\n");
ssize_t size;
endpoint_t endpt;
cp_grant_id_t grant;
- int i, access;
+ int i, perm;
assert(count <= NR_IOREQS);
if ((endpt = bdev_driver_get(dev)) == NONE)
return EDEADSRCDST;
- access = (req == BDEV_GATHER) ? CPF_WRITE : CPF_READ;
+ perm = (req == BDEV_GATHER) ? CPF_WRITE : CPF_READ;
size = 0;
for (i = 0; i < count; i++) {
grant = cpf_grant_direct(endpt, vec[i].iov_addr, vec[i].iov_size,
- access);
+ perm);
if (!GRANT_VALID(grant)) {
printf("bdev: unable to allocate grant!\n");
endpoint_t endpt;
size_t size;
cp_grant_id_t grant;
- int access;
+ int perm;
if ((endpt = bdev_driver_get(dev)) == NONE)
return EDEADSRCDST;
else
size = _MINIX_IOCTL_SIZE(request);
- access = 0;
- if (_MINIX_IOCTL_IOR(request)) access |= CPF_WRITE;
- if (_MINIX_IOCTL_IOW(request)) access |= CPF_READ;
+ perm = 0;
+ if (_MINIX_IOCTL_IOR(request)) perm |= CPF_WRITE;
+ if (_MINIX_IOCTL_IOW(request)) perm |= CPF_READ;
/* The size may be 0, in which case 'buf' need not be a valid pointer. */
- grant = cpf_grant_direct(endpt, (vir_bytes) buf, size, access);
+ grant = cpf_grant_direct(endpt, (vir_bytes) buf, size, perm);
if (!GRANT_VALID(grant)) {
printf("bdev: unable to allocate grant!\n");
return OK;
}
-void bdev_minor_add(dev_t dev, int access)
+void bdev_minor_add(dev_t dev, int bits)
{
/* Increase the reference count of the given minor device.
*/
- int i, free = -1;
+ int i, ifree = -1;
for (i = 0; i < NR_OPEN_DEVS; i++) {
if (open_dev[i].dev == dev) {
open_dev[i].count++;
- open_dev[i].access |= access;
+ open_dev[i].access |= bits;
return;
}
- if (free < 0 && open_dev[i].dev == NO_DEV)
- free = i;
+ if (ifree < 0 && open_dev[i].dev == NO_DEV)
+ ifree = i;
}
- if (free < 0) {
+ if (ifree < 0) {
printf("bdev: too many open devices, increase NR_OPEN_DEVS\n");
return;
}
- open_dev[free].dev = dev;
- open_dev[free].count = 1;
- open_dev[free].access = access;
+ open_dev[ifree].dev = dev;
+ open_dev[ifree].count = 1;
+ open_dev[ifree].access = bits;
}
void bdev_minor_del(dev_t dev)
# Makefile for libblockdriver
.include <bsd.own.mk>
-NOGCCERROR=yes
-
CPPFLAGS+= -D_MINIX_SYSTEM
LIB= blockdriver
worker_id = TID_WORKER(id);
assert(device_id >= 0 && device_id < MAX_DEVICES);
- assert(worker_id >= 0 && worker_id < MAX_WORKERS);
+ assert(worker_id < MAX_WORKERS);
wp = &device[device_id].worker[worker_id];
return state == PASS;
}
-char *servxfile(const char *file)
+const char *servxfile(const char *file)
/* Specify a file to use for the access checks other than the default. Return
* the old path.
*/
{
const char *oldpath= path_servacces;
path_servacces= file;
- return (char *) oldpath; /* (avoid const poisoning) */
+ return oldpath;
}
{
ip_hdr_t *ip_hdr;
- struct sockaddr_in *sinp;
+ const struct sockaddr_in *sinp;
+ ssize_t retval;
+ int saved_errno;
- sinp = (struct sockaddr_in *) __UNCONST(dest_addr);
+ sinp = (const struct sockaddr_in *)dest_addr;
if (sinp->sin_family != AF_INET)
{
errno= EAFNOSUPPORT;
}
/* raw */
- ip_hdr= (ip_hdr_t *)message;
+ /* XXX this is horrible: we have to copy the entire buffer
+ * because we have to change one header field. Obviously we
+ * can't modify the user buffer directly..
+ */
+ if ((ip_hdr = malloc(length)) == NULL)
+ return -1; /* errno is ENOMEM */
+ memcpy(ip_hdr, message, length);
ip_hdr->ih_dst= sinp->sin_addr.s_addr;
- return write(sock, message, length);
+ retval = write(sock, ip_hdr, length);
+
+ saved_errno = errno;
+ free(ip_hdr);
+ errno = saved_errno;
+ return retval;
}
#if DEBUG
# Makefile for libchardriver
.include <bsd.own.mk>
-NOGCCERROR=yes
-
CPPFLAGS+= -D_MINIX_SYSTEM
LIB= chardriver
/* Open a minor device. */
endpoint_t user_endpt;
devminor_t minor;
- int r, access;
+ int r, bits;
/* Default action if no open hook is in place. */
if (cdp->cdr_open == NULL)
/* Call the open hook. */
minor = m_ptr->m_vfs_lchardriver_openclose.minor;
- access = m_ptr->m_vfs_lchardriver_openclose.access;
+ bits = m_ptr->m_vfs_lchardriver_openclose.access;
user_endpt = m_ptr->m_vfs_lchardriver_openclose.user;
- r = cdp->cdr_open(minor, access, user_endpt);
+ r = cdp->cdr_open(minor, bits, user_endpt);
/* If the device has been cloned, mark the new minor as open too. */
if (r >= 0 && (r & CDEV_CLONED)) {
#
# Makefile for libclkconf
-NOGCCERROR=yes
-
CPPFLAGS+= -D_SYSTEM -D_MINIX_SYSTEM
LIB= clkconf
#include <assert.h>
/* used for logging */
-static struct log log = {
+static struct log clk_log = {
.name = "omap_clkconf",
.log_level = LEVEL_INFO,
.log_func = default_log
if (base != 0) {
/* when used in a library we can't guaranty we only call this
* method once */
- log_trace(&log, "Called %d times\n", use_count);
+ log_trace(&clk_log, "Called %d times\n", use_count);
return OK;
}
mr.mr_limit = cm_base + 0x1000;
if (sys_privctl(SELF, SYS_PRIV_ADD_MEM, &mr) != 0) {
- log_warn(&log, "Unable to request permission to map memory\n");
+ log_warn(&clk_log,
+ "Unable to request permission to map memory\n");
return EPERM;
}
base = (uint32_t) vm_map_phys(SELF, (void *) cm_base, 0x1000);
if (base == (uint32_t) MAP_FAILED) {
- log_warn(&log, "Unable to map GPIO memory\n");
+ log_warn(&clk_log, "Unable to map GPIO memory\n");
return EPERM;
}
return OK;
-NOGCCERROR=yes
-
CPPFLAGS+= -D_MINIX_SYSTEM
LIB = devman
size_t grant_size;
void *buf = serialize_dev(dev, &grant_size);
+ if (buf == NULL)
+ panic("out of memory");
+
cp_grant_id_t gid =
cpf_grant_direct(devman_ep,(vir_bytes) buf,
grant_size, CPF_READ);
# Makefile for libexec
-# LSC For now
-NOGCCERROR:= yes
-
LIB= exec
INCS= libexec.h
SRCS= exec_elf.c exec_general.c
# Makefile for libi2cdriver
-NOGCCERROR=yes
-
CPPFLAGS+=-D_MINIX_SYSTEM
LIB= i2cdriver
# Makefile for libminixfs
.include <bsd.own.mk>
-NOGCCERROR=yes
-
CPPFLAGS+= -D_MINIX_SYSTEM
LIB= minixfs
size_t block_size, off, block_off, last_size, size, chunk;
unsigned int blocks_left;
struct buf *bp;
- int r, write, how;
+ int r, do_write, how;
if (dev == NO_DEV)
return EINVAL;
block_size = lmfs_fs_block_size();
- write = (call == FSC_WRITE);
+ do_write = (call == FSC_WRITE);
assert(block_size > 0);
* For read requests, help the block driver form larger I/O
* requests.
*/
- if (!write)
+ if (!do_write)
block_prefetch(dev, block, blocks_left, block_size,
last_size);
* Do not read the block from disk if we will end up
* overwriting all of its contents.
*/
- how = (write && chunk == size) ? NO_READ : NORMAL;
+ how = (do_write && chunk == size) ? NO_READ : NORMAL;
if (size < block_size)
r = lmfs_get_partial_block(&bp, dev, block, how, size);
/* Perform the actual copy. */
if (r == OK && data != NULL) {
- if (write) {
+ if (do_write) {
r = fsdriver_copyin(data, off,
(char *)bp->data + block_off, chunk);
static void raisecount(struct buf *bp)
{
- assert(bufs_in_use >= 0);
- ASSERT(bp->lmfs_count >= 0);
+ ASSERT(bp->lmfs_count < CHAR_MAX);
bp->lmfs_count++;
if(bp->lmfs_count == 1) bufs_in_use++;
assert(bufs_in_use > 0);
ASSERT(bp->lmfs_count > 0);
bp->lmfs_count--;
if(bp->lmfs_count == 0) bufs_in_use--;
- assert(bufs_in_use >= 0);
}
static void freeblock(struct buf *bp)
# Makefile for libnetdriver
-NOGCCERROR=yes
-
CPPFLAGS+= -D_MINIX_SYSTEM
LIB= netdriver
*/
static void
do_readwrite(const struct netdriver * __restrict ndp, endpoint_t endpt,
- cp_grant_id_t grant, unsigned int count, int write)
+ cp_grant_id_t grant, unsigned int count, int do_write)
{
struct netdriver_data *data;
unsigned int i;
int r;
/* Copy in the I/O vector. */
- data = (write) ? &pending_send : &pending_recv;
+ data = (do_write) ? &pending_send : &pending_recv;
if (data->size != 0)
panic("netdriver: multiple concurrent requests");
data->size += data->iovec[i].iov_size;
if (data->size < ETH_MIN_PACK_SIZE ||
- (!write && data->size < ETH_MAX_PACK_SIZE_TAGGED))
+ (!do_write && data->size < ETH_MAX_PACK_SIZE_TAGGED))
panic("netdriver: invalid I/O vector size: %zu\n", data->size);
/* Save the endpoint to which we should reply. */
/* Resume sending or receiving. */
defer_replies();
- if (write)
+ if (do_write)
netdriver_send();
else
netdriver_recv();
const message * __restrict m_ptr)
{
message m_reply;
- eth_stat_t stat;
+ eth_stat_t st;
int r;
- memset(&stat, 0, sizeof(stat));
+ memset(&st, 0, sizeof(st));
if (ndp->ndr_stat != NULL)
- ndp->ndr_stat(&stat);
+ ndp->ndr_stat(&st);
if ((r = sys_safecopyto(m_ptr->m_source,
- m_ptr->m_net_netdrv_dl_getstat_s.grant, 0, (vir_bytes)&stat,
- sizeof(stat))) != OK)
+ m_ptr->m_net_netdrv_dl_getstat_s.grant, 0, (vir_bytes)&st,
+ sizeof(st))) != OK)
panic("netdriver: unable to copy out statistics: %d", r);
memset(&m_reply, 0, sizeof(m_reply));
case DL_READV_S:
do_readwrite(ndp, m_ptr->m_source,
m_ptr->m_net_netdrv_dl_readv_s.grant,
- m_ptr->m_net_netdrv_dl_readv_s.count, FALSE /*write*/);
+ m_ptr->m_net_netdrv_dl_readv_s.count, FALSE /*do_write*/);
break;
case DL_WRITEV_S:
do_readwrite(ndp, m_ptr->m_source,
m_ptr->m_net_netdrv_dl_writev_s.grant,
- m_ptr->m_net_netdrv_dl_writev_s.count, TRUE /*write*/);
+ m_ptr->m_net_netdrv_dl_writev_s.count, TRUE /*do_write*/);
break;
default:
netdriver_portinw(struct netdriver_data * data, size_t off, long port,
size_t size)
{
- uint8_t buf[2];
+ uint16_t buf;
uint32_t value;
size_t chunk;
unsigned int i;
if (odd_byte) {
if ((r = sys_safecopyto(data->endpt,
- data->iovec[i].iov_grant, off, (vir_bytes)&buf[1],
- 1)) != OK)
+ data->iovec[i].iov_grant, off,
+ (vir_bytes)&((char *)&buf)[1], 1)) != OK)
panic("netdriver: unable to copy data: %d", r);
off++;
if (odd_byte) {
if ((r = sys_inw(port, &value)) != OK)
panic("netdriver: port input failed: %d", r);
- *(uint16_t *)buf = (uint16_t)value;
+ buf = (uint16_t)value;
if ((r = sys_safecopyto(data->endpt,
- data->iovec[i].iov_grant, off, (vir_bytes)&buf[0],
- 1)) != OK)
+ data->iovec[i].iov_grant, off,
+ (vir_bytes)&((char *)&buf)[0], 1)) != OK)
panic("netdriver: unable to copy data: %d", r);
size--;
netdriver_portoutw(struct netdriver_data * data, size_t off, long port,
size_t size)
{
- uint8_t buf[2];
+ uint16_t buf;
size_t chunk;
unsigned int i;
int r, odd_byte;
if (odd_byte) {
if ((r = sys_safecopyfrom(data->endpt,
- data->iovec[i].iov_grant, off, (vir_bytes)&buf[1],
- 1)) != OK)
+ data->iovec[i].iov_grant, off,
+ (vir_bytes)&((char *)&buf)[1], 1)) != OK)
panic("netdriver: unable to copy data: %d", r);
- if ((r = sys_outw(port, *(uint16_t *)buf)) != OK)
+ if ((r = sys_outw(port, buf)) != OK)
panic("netdriver: port output failed: %d", r);
off++;
if (odd_byte) {
if ((r = sys_safecopyfrom(data->endpt,
- data->iovec[i].iov_grant, off, (vir_bytes)&buf[0],
- 1)) != OK)
+ data->iovec[i].iov_grant, off,
+ (vir_bytes)&((char *)&buf)[0], 1)) != OK)
panic("netdriver: unable to copy data: %d", r);
size--;
}
if (odd_byte) {
- buf[1] = 0;
+ ((char *)&buf)[1] = 0;
- if ((r = sys_outw(port, *(uint16_t *)buf)) != OK)
+ if ((r = sys_outw(port, buf)) != OK)
panic("netdriver: port output failed: %d", r);
}
}
-NOGCCERROR=yes
-
CPPFLAGS+= -D_MINIX_SYSTEM
LIB = netsock
# Makefile for libsffs
.include <bsd.own.mk>
-NOGCCERROR=yes
-
CPPFLAGS+= -D_MINIX_SYSTEM
LIB= sffs
/* Initialize inode table. Return the root inode.
*/
struct inode *ino;
- unsigned int index;
+ unsigned int i;
TAILQ_INIT(&free_list);
sffs_name, NUM_INODES, sizeof(struct inode), sizeof(inodes)));
/* Mark all inodes except the root inode as free. */
- for (index = 1; index < NUM_INODES; index++) {
- ino = &inodes[index];
+ for (i = 1; i < NUM_INODES; i++) {
+ ino = &inodes[i];
ino->i_parent = NULL;
LIST_INIT(&ino->i_child);
- ino->i_num = index + 1;
+ ino->i_num = i + 1;
ino->i_gen = (unsigned short)-1; /* aesthetics */
ino->i_ref = 0;
ino->i_flags = 0;
/* Get an inode based on its inode number. Do not increase its reference count.
*/
struct inode *ino;
- int index;
+ int i;
/* Inode 0 (= index -1) is not a valid inode number. */
- index = INODE_INDEX(ino_nr);
- if (index < 0) {
+ i = INODE_INDEX(ino_nr);
+ if (i < 0) {
printf("%s: VFS passed invalid inode number!\n", sffs_name);
return NULL;
}
- assert(index < NUM_INODES);
+ assert(i < NUM_INODES);
- ino = &inodes[index];
+ ino = &inodes[i];
/* Make sure the generation number matches. */
if (INODE_GEN(ino_nr) != ino->i_gen) {
/* Check whether any inodes are still in use, that is, any of the inodes have
* a reference count larger than zero.
*/
- unsigned int index;
+ unsigned int i;
- for (index = 0; index < NUM_INODES; index++)
- if (inodes[index].i_ref > 0)
+ for (i = 0; i < NUM_INODES; i++)
+ if (inodes[i].i_ref > 0)
return TRUE;
return FALSE;
/*===========================================================================*
* do_statvfs *
*===========================================================================*/
-int do_statvfs(struct statvfs *statvfs)
+int do_statvfs(struct statvfs *st)
{
/* Retrieve file system statistics.
*/
struct inode *ino;
char path[PATH_MAX];
- u64_t free, total;
+ u64_t bfree, btotal;
int r;
/* Unfortunately, we cannot be any more specific than this, because we are
if ((r = verify_inode(ino, path, NULL)) != OK)
return r;
- if ((r = sffs_table->t_queryvol(path, &free, &total)) != OK)
+ if ((r = sffs_table->t_queryvol(path, &bfree, &btotal)) != OK)
return r;
/* Returning zero for unknown values seems to be the convention. However, we
* do have to use a nonzero block size, even though it is entirely arbitrary.
*/
- statvfs->f_flag = ST_NOTRUNC;
- statvfs->f_bsize = BLOCK_SIZE;
- statvfs->f_frsize = BLOCK_SIZE;
- statvfs->f_iosize = BLOCK_SIZE;
- statvfs->f_blocks = (fsblkcnt_t)(total / BLOCK_SIZE);
- statvfs->f_bfree = (fsblkcnt_t)(free / BLOCK_SIZE);
- statvfs->f_bavail = statvfs->f_bfree;
- statvfs->f_namemax = NAME_MAX;
+ st->f_flag = ST_NOTRUNC;
+ st->f_bsize = BLOCK_SIZE;
+ st->f_frsize = BLOCK_SIZE;
+ st->f_iosize = BLOCK_SIZE;
+ st->f_blocks = (fsblkcnt_t)(btotal / BLOCK_SIZE);
+ st->f_bfree = (fsblkcnt_t)(bfree / BLOCK_SIZE);
+ st->f_bavail = st->f_bfree;
+ st->f_namemax = NAME_MAX;
return OK;
}
/*===========================================================================*
* do_stat *
*===========================================================================*/
-int do_stat(ino_t ino_nr, struct stat *stat)
+int do_stat(ino_t ino_nr, struct stat *st)
{
/* Retrieve inode status.
*/
if ((r = verify_inode(ino, path, &attr)) != OK)
return r;
- stat->st_mode = get_mode(ino, attr.a_mode);
- stat->st_uid = sffs_params->p_uid;
- stat->st_gid = sffs_params->p_gid;
- stat->st_rdev = NO_DEV;
- stat->st_size = attr.a_size;
- stat->st_atimespec = attr.a_atime;
- stat->st_mtimespec = attr.a_mtime;
- stat->st_ctimespec = attr.a_ctime;
- stat->st_birthtimespec = attr.a_crtime;
+ st->st_mode = get_mode(ino, attr.a_mode);
+ st->st_uid = sffs_params->p_uid;
+ st->st_gid = sffs_params->p_gid;
+ st->st_rdev = NO_DEV;
+ st->st_size = attr.a_size;
+ st->st_atimespec = attr.a_atime;
+ st->st_mtimespec = attr.a_mtime;
+ st->st_ctimespec = attr.a_ctime;
+ st->st_birthtimespec = attr.a_crtime;
- stat->st_blocks = stat->st_size / S_BLKSIZE;
- if (stat->st_size % S_BLKSIZE != 0)
- stat->st_blocks += 1;
+ st->st_blocks = st->st_size / S_BLKSIZE;
+ if (st->st_size % S_BLKSIZE != 0)
+ st->st_blocks += 1;
- stat->st_blksize = BLOCK_SIZE;
+ st->st_blksize = BLOCK_SIZE;
/* We could make this more accurate by iterating over directory inodes'
* children, counting how many of those are directories as well.
* It's just not worth it.
*/
- stat->st_nlink = 0;
- if (ino->i_parent != NULL) stat->st_nlink++;
+ st->st_nlink = 0;
+ if (ino->i_parent != NULL) st->st_nlink++;
if (IS_DIR(ino)) {
- stat->st_nlink++;
- if (HAS_CHILDREN(ino)) stat->st_nlink++;
+ st->st_nlink++;
+ if (HAS_CHILDREN(ino)) st->st_nlink++;
}
return OK;
# Makefile for libsys
.include <bsd.own.mk>
-NOGCCERROR=yes
-
CPPFLAGS+= -D_MINIX_SYSTEM -D_SYSTEM
LIB= sys
int env_argc = 0;
char **env_argv = NULL;
-static char *find_key(const char *params, const char *key);
+static const char *find_key(const char *params, const char *key);
/*===========================================================================*
* env_setargs *
{
message m;
static char mon_params[MULTIBOOT_PARAM_BUF_SIZE]; /* copy parameters here */
- char *key_value;
+ const char *key_value;
int i, s;
size_t keylen;
/*==========================================================================*
- * find_key *
+ * find_key *
*==========================================================================*/
-static char *find_key(const char *params, const char *name)
+static const char *find_key(const char *params, const char *name)
{
- const char *namep;
- char *envp;
+ const char *namep, *envp;
- for (envp = (char *) params; *envp != 0;) {
+ for (envp = params; *envp != 0;) {
for (namep = name; *namep != 0 && *namep == *envp; namep++, envp++)
;
if (*namep == '\0' && *envp == '=')
/*===========================================================================*
* sef_llvm_magic_enabled *
*===========================================================================*/
-int sef_llvm_magic_enabled()
+int sef_llvm_magic_enabled(void)
{
- extern void __attribute__((weak)) magic_init();
+ extern void __attribute__((weak)) magic_init(void);
if (!magic_init)
return 0;
return 1;
/*===========================================================================*
* sef_llvm_state_cleanup *
*===========================================================================*/
-int sef_llvm_state_cleanup()
+int sef_llvm_state_cleanup(void)
{
return OK;
}
/*===========================================================================*
* sef_llvm_state_table_addr *
*===========================================================================*/
-void *sef_llvm_state_table_addr()
+void *sef_llvm_state_table_addr(void)
{
extern void* __attribute__((weak)) _magic_vars_addr(void);
if (!_magic_vars_addr)
/*===========================================================================*
* sef_llvm_state_table_size *
*===========================================================================*/
-size_t sef_llvm_state_table_size()
+size_t sef_llvm_state_table_size(void)
{
extern size_t __attribute__((weak)) _magic_vars_size(void);
if (!_magic_vars_size)
int sef_llvm_add_special_mem_region(void *addr, size_t len, const char* name)
{
extern int __attribute__((weak)) st_add_special_mmapped_region(void *addr,
- size_t len, char* name);
+ size_t len, const char* name);
if (!st_add_special_mmapped_region)
return 0;
- return st_add_special_mmapped_region(addr, len, (char*) name);
+ return st_add_special_mmapped_region(addr, len, name);
}
/*===========================================================================*
/*===========================================================================*
* sef_llvm_ltckpt_enabled *
*===========================================================================*/
-int sef_llvm_ltckpt_enabled()
+int sef_llvm_ltckpt_enabled(void)
{
extern int __attribute__((weak)) ltckpt_mechanism_enabled(void);
if (!sef_llvm_get_ltckpt_offset() || !ltckpt_mechanism_enabled())
/*===========================================================================*
* sef_llvm_ltckpt_get_offset *
*===========================================================================*/
-int sef_llvm_get_ltckpt_offset()
+int sef_llvm_get_ltckpt_offset(void)
{
- extern int __attribute__((weak)) ltckpt_get_offset();
+ extern int __attribute__((weak)) ltckpt_get_offset(void);
if (!ltckpt_get_offset)
return 0;
return ltckpt_get_offset();
assert(ltckpt_restart);
return ltckpt_restart(info);
}
-
{
/* A signal manager has pending signals in the kernel. Process them. */
endpoint_t target;
- sigset_t sigset;
+ sigset_t set;
int signo, r;
while (TRUE) {
/* Get an arbitrary pending signal. */
- if((r=sys_getksig(&target, &sigset)) != OK)
+ if((r=sys_getksig(&target, &set)) != OK)
panic("SEF: sys_getksig failed: %d", r);
if (target == NONE) {
/* Process every signal in the signal set. */
r = OK;
for (signo = SIGS_FIRST; signo <= SIGS_LAST; signo++) {
- int s = sigismember(&sigset, signo);
+ int s = sigismember(&set, signo);
assert(s >= 0);
if(s) {
/* Let the callback code process the signal. */
/*===========================================================================*
* process_sigmgr_self_signals *
*===========================================================================*/
-static void process_sigmgr_self_signals(sigset_t sigset)
+static void process_sigmgr_self_signals(sigset_t set)
{
/* A signal manager has pending signals for itself. Process them. */
int signo;
for (signo = SIGS_FIRST; signo <= SIGS_LAST; signo++) {
- int s = sigismember(&sigset, signo);
+ int s = sigismember(&set, signo);
assert(s >= 0);
if(s) {
/* Let the callback code process the signal. */
{
/* Handle a SEF Signal request. */
int signo;
- sigset_t sigset;
+ sigset_t set;
if(m_ptr->m_source == SYSTEM) {
/* Handle kernel signals. */
- sigset = m_ptr->m_notify.sigset;
+ set = m_ptr->m_notify.sigset;
for (signo = SIGK_FIRST; signo <= SIGK_LAST; signo++) {
- int s = sigismember(&sigset, signo);
+ int s = sigismember(&set, signo);
assert(s >= 0);
if (s) {
/* Let the callback code handle the kernel signal. */
}
/* Handle SIGKSIGSM for a signal manager. */
else if(signo == SIGKSIGSM) {
- process_sigmgr_self_signals(sigset);
+ process_sigmgr_self_signals(set);
}
}
}
# Makefile for libdriver
-NOGCCERROR=yes
-
CPPFLAGS+= -D_MINIX_SYSTEM
LIB = usb
# Makefile for libvassert library
-NOGCCERROR=yes
-
MKPIC?= no
LIB= vassert
SRCS= backdoor.S vassert.c
# Makefile for libvirtio
.include <bsd.own.mk>
-NOGCCERROR=yes
-
CPPFLAGS+= -D_MINIX_SYSTEM
LIB= virtio
# Makefile for libvtreefs
-NOGCCERROR=yes
-
CPPFLAGS+= -D_MINIX_SYSTEM
LIB= vtreefs
* return a partial result. Otherwise return the error.
*/
if (r < 0)
- return (off > 0) ? off : r;
+ return (off > 0) ? (ssize_t)off : r;
off += len;
pos += len;
* return a partial result. Otherwise return the error.
*/
if (r < 0)
- return (off > 0) ? off : r;
+ return (off > 0) ? (ssize_t)off : r;
off += r;
pos += r;
* Initialize the inode-related state.
*/
int
-init_inodes(unsigned int inodes, struct inode_stat * stat,
+init_inodes(unsigned int inodes, struct inode_stat * istat,
index_t nr_indexed_entries)
{
struct inode *node;
TAILQ_INIT(&node->i_children);
node->i_flags = 0;
node->i_index = NO_INDEX;
- set_inode_stat(node, stat);
+ set_inode_stat(node, istat);
node->i_indexed = nr_indexed_entries;
node->i_cbdata = NULL;
* Return the hash value of a <parent,index> tuple.
*/
static int
-parent_index_hash(const struct inode * parent, index_t index)
+parent_index_hash(const struct inode * parent, index_t idx)
{
- return (parent->i_num ^ index) % nr_inodes;
+ return (parent->i_num ^ idx) % nr_inodes;
}
/*
* Add an inode.
*/
struct inode *
-add_inode(struct inode * parent, const char * name, index_t index,
- const struct inode_stat * stat, index_t nr_indexed_entries,
+add_inode(struct inode * parent, const char * name, index_t idx,
+ const struct inode_stat * istat, index_t nr_indexed_entries,
cbdata_t cbdata)
{
struct inode *newnode;
assert(S_ISDIR(parent->i_stat.mode));
assert(!(parent->i_flags & I_DELETED));
assert(strlen(name) <= NAME_MAX);
- assert(index >= 0 || index == NO_INDEX);
- assert(stat != NULL);
+ assert(idx >= 0 || idx == NO_INDEX);
+ assert(istat != NULL);
assert(nr_indexed_entries >= 0);
assert(get_inode_by_name(parent, name) == NULL);
newnode->i_parent = parent;
newnode->i_name = newname;
newnode->i_flags = 0;
- newnode->i_index = index;
- newnode->i_stat = *stat;
+ newnode->i_index = idx;
+ newnode->i_stat = *istat;
newnode->i_indexed = nr_indexed_entries;
newnode->i_cbdata = cbdata;
strcpy(newnode->i_name, name);
LIST_INSERT_HEAD(&parent_name_head[slot], newnode, i_hname);
/* Add the inode to the <parent,index> hash table. */
- if (index != NO_INDEX) {
- slot = parent_index_hash(parent, index);
+ if (idx != NO_INDEX) {
+ slot = parent_index_hash(parent, idx);
LIST_INSERT_HEAD(&parent_index_head[slot], newnode, i_hindex);
}
* Retrieve an inode's status.
*/
void
-get_inode_stat(const struct inode * node, struct inode_stat * stat)
+get_inode_stat(const struct inode * node, struct inode_stat * istat)
{
CHECK_INODE(node);
- *stat = node->i_stat;
+ *istat = node->i_stat;
}
/*
* Set an inode's status.
*/
void
-set_inode_stat(struct inode * node, struct inode_stat * stat)
+set_inode_stat(struct inode * node, struct inode_stat * istat)
{
CHECK_INODE(node);
- node->i_stat = *stat;
+ node->i_stat = *istat;
}
/*
* Look up an inode using a <parent,index> tuple.
*/
struct inode *
-get_inode_by_index(const struct inode * parent, index_t index)
+get_inode_by_index(const struct inode * parent, index_t idx)
{
struct inode *node;
int slot;
CHECK_INODE(parent);
assert(S_ISDIR(parent->i_stat.mode));
- assert(index >= 0);
+ assert(idx >= 0);
- if (index >= parent->i_indexed)
+ if (idx >= parent->i_indexed)
return NULL;
/* Get the hash value, and search for the inode. */
- slot = parent_index_hash(parent, index);
+ slot = parent_index_hash(parent, idx);
LIST_FOREACH(node, &parent_index_head[slot], i_hindex) {
- if (parent == node->i_parent && index == node->i_index)
+ if (parent == node->i_parent && idx == node->i_index)
return node; /* found */
}
{
char path[PATH_MAX];
struct inode *node;
- struct inode_stat stat;
+ struct inode_stat istat;
int r;
if ((node = find_inode(dir_nr)) == NULL)
return r;
path[bytes] = 0;
- memset(&stat, 0, sizeof(stat));
- stat.mode = S_IFLNK | RWX_MODES;
- stat.uid = uid;
- stat.gid = gid;
- stat.size = strlen(path);
- stat.dev = 0;
+ memset(&istat, 0, sizeof(istat));
+ istat.mode = S_IFLNK | RWX_MODES;
+ istat.uid = uid;
+ istat.gid = gid;
+ istat.size = strlen(path);
+ istat.dev = 0;
- return vtreefs_hooks->slink_hook(node, name, &stat, path,
+ return vtreefs_hooks->slink_hook(node, name, &istat, path,
get_inode_cbdata(node));
}
dev_t rdev)
{
struct inode *node;
- struct inode_stat stat;
+ struct inode_stat istat;
if ((node = find_inode(dir_nr)) == NULL)
return EINVAL;
if (vtreefs_hooks->mknod_hook == NULL)
return ENOSYS;
- memset(&stat, 0, sizeof(stat));
- stat.mode = mode;
- stat.uid = uid;
- stat.gid = gid;
- stat.size = 0;
- stat.dev = rdev;
+ memset(&istat, 0, sizeof(istat));
+ istat.mode = mode;
+ istat.uid = uid;
+ istat.gid = gid;
+ istat.size = 0;
+ istat.dev = rdev;
- return vtreefs_hooks->mknod_hook(node, name, &stat,
+ return vtreefs_hooks->mknod_hook(node, name, &istat,
get_inode_cbdata(node));
}
fs_chmod(ino_t ino_nr, mode_t * mode)
{
struct inode *node;
- struct inode_stat stat;
+ struct inode_stat istat;
int r;
if ((node = find_inode(ino_nr)) == NULL)
if (vtreefs_hooks->chstat_hook == NULL)
return ENOSYS;
- get_inode_stat(node, &stat);
+ get_inode_stat(node, &istat);
- stat.mode = (stat.mode & ~ALL_MODES) | (*mode & ALL_MODES);
+ istat.mode = (istat.mode & ~ALL_MODES) | (*mode & ALL_MODES);
- r = vtreefs_hooks->chstat_hook(node, &stat, get_inode_cbdata(node));
+ r = vtreefs_hooks->chstat_hook(node, &istat, get_inode_cbdata(node));
if (r != OK)
return r;
- get_inode_stat(node, &stat);
+ get_inode_stat(node, &istat);
- *mode = stat.mode;
+ *mode = istat.mode;
return OK;
}
fs_chown(ino_t ino_nr, uid_t uid, gid_t gid, mode_t * mode)
{
struct inode *node;
- struct inode_stat stat;
+ struct inode_stat istat;
int r;
if ((node = find_inode(ino_nr)) == NULL)
if (vtreefs_hooks->chstat_hook == NULL)
return ENOSYS;
- get_inode_stat(node, &stat);
+ get_inode_stat(node, &istat);
- stat.uid = uid;
- stat.gid = gid;
- stat.mode &= ~(S_ISUID | S_ISGID);
+ istat.uid = uid;
+ istat.gid = gid;
+ istat.mode &= ~(S_ISUID | S_ISGID);
- r = vtreefs_hooks->chstat_hook(node, &stat, get_inode_cbdata(node));
+ r = vtreefs_hooks->chstat_hook(node, &istat, get_inode_cbdata(node));
if (r != OK)
return r;
- get_inode_stat(node, &stat);
+ get_inode_stat(node, &istat);
- *mode = stat.mode;
+ *mode = istat.mode;
return OK;
}
* We received a signal.
*/
static void
-got_signal(int signal)
+got_signal(int sig)
{
- if (signal != SIGTERM)
+ if (sig != SIGTERM)
return;
fsdriver_terminate();
*/
void
run_vtreefs(struct fs_hooks * hooks, unsigned int nr_inodes,
- size_t inode_extra, struct inode_stat * stat,
+ size_t inode_extra, struct inode_stat * istat,
index_t nr_indexed_entries, size_t bufsize)
{
vtreefs_hooks = hooks;
inodes = nr_inodes;
extra_size = inode_extra;
- root_stat = stat;
+ root_stat = istat;
root_entries = nr_indexed_entries;
buf_size = bufsize;
char *name, char *parent_name);
PUBLIC struct _magic_obdsentry* magic_create_obdsentry(void *data_ptr,
struct _magic_type *type, size_t size, int flags,
- char *name, char *parent_name);
+ const char *name, char *parent_name);
PUBLIC int magic_update_dsentry_state(struct _magic_dsentry *dsentry,
unsigned long mstate);
PUBLIC void magic_free_dead_dsentries();
/* Public functions for special types and regions. */
PUBLIC void st_register_typename_key(char *key);
PUBLIC void st_register_typename_keys(char **keys);
-PUBLIC int st_add_special_mmapped_region(void *address, size_t size, char* name);
+PUBLIC int st_add_special_mmapped_region(void *address, size_t size,
+ const char* name);
PUBLIC int st_del_special_mmapped_region_by_addr(void *address);
#endif /* ST_SPECIAL_H */
*===========================================================================*/
PUBLIC struct _magic_obdsentry* magic_create_obdsentry(void *data_ptr,
struct _magic_type *type, size_t size, int flags,
- char *name, char *parent_name)
+ const char *name, char *parent_name)
{
struct _magic_obdsentry *obdsentry = NULL;
int i, ret;
/* Metadata management. */
PUBLIC int st_add_special_mmapped_region(void *address, size_t size,
- char* name)
+ const char* name)
{
struct _magic_obdsentry* obdsentry;
char addr_name[24];
.PATH: ${.CURDIR}/generic
-WARNS=
-
-NOCLANGERROR=yes
-
DPADD+= ${LIBCHARDRIVER} ${LIBSYS}
LDADD+= -lchardriver -lsys
return;
}
- if (rc < strlen(buf)) {
+ if (rc < strlen((char *)buf)) {
test_fail("[server] write didn't write all the bytes");
}
return;
}
- if (rc < strlen(buf)) {
+ if (rc < strlen((char *)buf)) {
test_fail("[server] write didn't write all the bytes");
}
return;
}
- if (rc < strlen(buf)) {
+ if (rc < strlen((char *)buf)) {
test_fail("[server] write didn't write all the bytes");
}
perror(PASSWD_FILE);
}
while (fp != NULL && fgets(line, sizeof(line), fp) != NULL) {
- p = strchr(line, ':');
- if (p != NULL) p = strchr(p + 1, ':');
+ p = (unsigned char *)strchr(line, ':');
+ if (p != NULL) p = (unsigned char *)strchr((char *)p + 1, ':');
if (p != NULL) {
p++;
uid = 0;
perror(PASSWD_FILE);
}
while (fp != NULL && fgets(line, sizeof(line), fp) != NULL) {
- p = strchr(line, ':');
- if (p != NULL) p = strchr(p + 1, ':');
+ p = (unsigned char *)strchr(line, ':');
+ if (p != NULL) p = (unsigned char *)strchr((char *)p + 1, ':');
if (p != NULL) {
p++;
uid = 0;
}
pid_t traced_fork(c)
-void(*c) (void);
+void (*c)(void);
{
pid_t pid;
int r, status;
detach_running(ppid);
break;
+
+ default:
+ abort();
}
return pid;
}
}
-static void test_select()
+static void test_select(void)
{
int nfds = -1;
int socks[2];
close(socks[0]);
}
-static void test_fchmod()
+static void test_fchmod(void)
{
int socks[2];
struct stat st1, st2;
int main(void);
void quit(void);
-static void test_clock_getres();
-static void test_clock_gettime();
-static void test_clock_settime();
-static void test_adjtime();
+static void test_clock_getres(void);
+static void test_clock_gettime(void);
+static void test_clock_settime(void);
+static void test_adjtime(void);
static void show_timespec(char *msg, struct timespec *ts);
-static void test_clock_getres()
+static void test_clock_getres(void)
{
struct timespec res;
if (clock_getres(-1, &res) == 0) e(14);
}
-static void test_clock_gettime()
+static void test_clock_gettime(void)
{
struct timespec ts, ts2;
#endif /* DEBUG == 1 */
}
-int main()
+int main(void)
{
start(69);
struct timespec starttime, endtime;
}
int
-main()
+main(void)
{
start(70);
pid_t f;
((char *) buf)[rl] = '\0';
if(strcmp(buf, TARGETNAME)) {
fprintf(stderr, "readlink: expected %s, got %s\n",
- TARGETNAME, buf);
+ TARGETNAME, (char *)buf);
e(3);
}
return;
fragsize = payloadsize;
fragstep = 0;
break;
+ default:
+ abort();
}
while (fragcount > 0) {
CPPFLAGS+= -I${.CURDIR}
NOGCCERROR?= yes
-NOCLANGERROR?= yes
.include <bsd.prog.mk>
(int)next_inode-1, next_zone);
}
- if(insertmode) printf("%llu\n", written_fs_size);
+ if(insertmode) printf("%"PRIu64"\n", written_fs_size);
return(0);
PROG= mkproto
MAN=
-NOGCCERROR?= yes
-NOCLANGERROR?= yes
-
.include <bsd.prog.mk>