int direct_read_char(unsigned char *ch)
{
- unsigned long b, sb;
+ unsigned long sb;
sb = inb(KB_STATUS);
return 0;
}
- b = inb(KEYBD);
+ inb(KEYBD);
if (!(sb & KB_AUX_BYTE))
return 1;
int vm_memset(endpoint_t who, phys_bytes ph, const u8_t c, phys_bytes bytes)
{
u32_t p;
- int r = OK;
struct proc *whoptr = NULL;
/* NONE for physical, otherwise virtual */
*/
if((pfa=phys_memset(ptr, p, chunk))) {
printf("kernel memset pagefault\n");
- r = EFAULT;
break;
}
bytes -= chunk;
for (i = 0; i < size; i++) {
/* Process each entry in the table and store the result in the table.
* If we're done handling a message, copy the result to the sender. */
- int pending_recv = FALSE;
dst = NONE;
/* Copy message to kernel */
/* Inform receiver that something is pending */
set_sys_bit(priv(dst_ptr)->s_asyn_pending,
priv(caller_ptr)->s_id);
- pending_recv = TRUE;
done = FALSE;
continue;
}
#include "fs.h"
#include <sys/stat.h>
#include <string.h>
+#include <assert.h>
#include <minix/com.h>
#include "buf.h"
#include "inode.h"
struct inode *ldirp; /* directory containing link */
register int r; /* error code */
char string[NAME_MAX]; /* last component of the new dir's path name */
- char* link_target_buf; /* either sip->i_block or bp->b_data */
+ char* link_target_buf = NULL; /* either sip->i_block or bp->b_data */
struct buf *bp = NULL; /* disk buffer for link */
caller_uid = (uid_t) fs_m_in.REQ_UID;
}
}
if (r == OK) {
+ assert(link_target_buf);
link_target_buf[fs_m_in.REQ_MEM_SIZE] = '\0';
sip->i_size = (off_t) strlen(link_target_buf);
if (sip->i_size != fs_m_in.REQ_MEM_SIZE) {
ip_hdr_t *pack_hdr;
{
ip_ass_t *ass_ent;
- size_t pack_hdr_len, pack_offset, tmp_offset;
+ size_t pack_offset, tmp_offset;
u16_t pack_flags_fragoff;
acc_t *prev_acc, *curr_acc, *next_acc, *head_acc, *tmp_acc;
ip_hdr_t *tmp_hdr;
pack_hdr->ih_proto, pack_hdr->ih_src, pack_hdr->ih_dst);
pack_flags_fragoff= ntohs(pack_hdr->ih_flags_fragoff);
- pack_hdr_len= (pack_hdr->ih_vers_ihl & IH_IHL_MASK) * 4;
pack_offset= (pack_flags_fragoff & IH_FRAGOFF_MASK)*8;
pack->acc_ext_link= NULL;
{
tcp_fd_t *connuser;
int tcp_hdr_flags;
- int ip_hdr_len, tcp_hdr_len;
u32_t seg_ack, seg_seq, rcv_hi, snd_una, snd_nxt;
u16_t seg_wnd, mtu;
size_t mss;
int acceptable_ACK, segm_acceptable, send_rst, close_connection;
- ip_hdr_len= (ip_hdr->ih_vers_ihl & IH_IHL_MASK) << 2;
- tcp_hdr_len= (tcp_hdr->th_data_off & TH_DO_MASK) >> 2;
-
tcp_hdr_flags= tcp_hdr->th_flags & TH_FLAGS_MASK;
seg_ack= ntohl(tcp_hdr->th_ack_nr);
seg_seq= ntohl(tcp_hdr->th_seq_nr);
tcp_sel_read(tcp_conn)
tcp_conn_t *tcp_conn;
{
- tcp_fd_t *tcp_fd;
size_t data_size;
int fin_recv, urg, push;
- tcp_fd= tcp_conn->tc_fd;
-
if (tcp_conn->tc_state == TCS_CLOSED)
return 1;
{
tcp_conn_t *tcp_conn;
size_t data_size;
- int fin_recv, urg, push;
+ int fin_recv, urg;
*bytesp= 0; /* The default is that nothing is available */
return;
urg= tcp_Gmod4G(tcp_conn->tc_RCV_UP, tcp_conn->tc_RCV_LO);
- push= (tcp_conn->tc_flags & TCF_RCV_PUSH);
fin_recv= (tcp_conn->tc_flags & TCF_FIN_RECV);
data_size= tcp_conn->tc_RCV_NXT-tcp_conn->tc_RCV_LO;
mq_t *m;
{
sr_fd_t *sr_fd;
- mq_t **q_head_ptr, **q_tail_ptr;
- int ip_flag, susp_flag, first_flag;
- int r;
+ mq_t **q_head_ptr = NULL, **q_tail_ptr = NULL;
+ int ip_flag = 0, susp_flag = 0, first_flag = 0;
+ int r = OK;
ioreq_t request;
size_t size;
int cmd = m->SHMCTL_CMD;
struct shmid_ds *ds = (struct shmid_ds *)m->SHMCTL_BUF;
struct shmid_ds tmp_ds;
- struct shm_struct *shm;
+ struct shm_struct *shm = NULL;
struct shminfo sinfo;
struct shm_info s_info;
uid_t uid;
int fs_ftrunc(message *fs_m_in, message *fs_m_out)
{
struct inode *rip;
- off_t start, end;
+ off_t start;
ino_t inumb;
inumb = (ino_t) fs_m_in->REQ_INODE_NR;
if( (rip = find_inode(inumb)) == NULL) return(EINVAL);
start = fs_m_in->REQ_TRC_START_LO;
- end = fs_m_in->REQ_TRC_END_LO;
return truncate_inode(rip, start);
}
int do_getsockopt_sndbuf(message *dev_m_in, message *dev_m_out)
{
- int minor;
int rc;
size_t sndbuf = PIPE_BUF;
uds_minor(dev_m_in), ++call_count);
#endif
- minor = uds_minor(dev_m_in);
-
rc = sys_safecopyto(VFS_PROC_NR, (cp_grant_id_t) dev_m_in->IO_GRANT,
(vir_bytes) 0, (vir_bytes) &(sndbuf), sizeof(size_t));
int do_setsockopt_sndbuf(message *dev_m_in, message *dev_m_out)
{
- int minor;
int rc;
size_t sndbuf;
uds_minor(dev_m_in), ++call_count);
#endif
- minor = uds_minor(dev_m_in);
-
-
rc = sys_safecopyfrom(VFS_PROC_NR, (cp_grant_id_t) dev_m_in->IO_GRANT,
(vir_bytes) 0, (vir_bytes) &sndbuf,
sizeof(size_t));
int do_getsockopt_rcvbuf(message *dev_m_in, message *dev_m_out)
{
- int minor;
int rc;
size_t rcvbuf = PIPE_BUF;
uds_minor(dev_m_in), ++call_count);
#endif
- minor = uds_minor(dev_m_in);
-
rc = sys_safecopyto(VFS_PROC_NR, (cp_grant_id_t) dev_m_in->IO_GRANT,
(vir_bytes) 0, (vir_bytes) &(rcvbuf), sizeof(size_t));
int do_setsockopt_rcvbuf(message *dev_m_in, message *dev_m_out)
{
- int minor;
int rc;
size_t rcvbuf;
uds_minor(dev_m_in), ++call_count);
#endif
- minor = uds_minor(dev_m_in);
-
-
rc = sys_safecopyfrom(VFS_PROC_NR, (cp_grant_id_t) dev_m_in->IO_GRANT,
(vir_bytes) 0, (vir_bytes) &rcvbuf,
sizeof(size_t));
char *ptr;
struct mproc *rmp;
struct exec_info args;
- int r, flags;
+ int r, flags = 0;
if (who_e != VFS_PROC_NR && who_e != RS_PROC_NR)
return EPERM;
void share_exec(rp_dst, rp_src)
struct rproc *rp_dst, *rp_src;
{
- struct rprocpub *rpub_src;
- struct rprocpub *rpub_dst;
-
- rpub_src = rp_src->r_pub;
- rpub_dst = rp_dst->r_pub;
-
if(rs_verbose)
printf("RS: %s shares exec image with %s\n",
srv_to_string(rp_dst), srv_to_string(rp_src));
int do_down(message *m_ptr)
{
register struct rproc *rp;
- register struct rprocpub *rpub;
int s;
char label[RS_MAX_LABEL_LEN];
printf("RS: do_down: service '%s' not found\n", label);
return(ESRCH);
}
- rpub = rp->r_pub;
/* Check if the call can be allowed. */
if((s = check_call_permission(m_ptr->m_source, RS_DOWN, rp)) != OK)
int do_refresh(message *m_ptr)
{
register struct rproc *rp;
- register struct rprocpub *rpub;
int s;
char label[RS_MAX_LABEL_LEN];
printf("RS: do_refresh: service '%s' not found\n", label);
return(ESRCH);
}
- rpub = rp->r_pub;
/* Check if the call can be allowed. */
if((s = check_call_permission(m_ptr->m_source, RS_REFRESH, rp)) != OK)
int status;
struct rproc *rp;
struct rproc **rps;
- struct rprocpub *rpub;
int i, nr_rps;
if(rs_verbose)
while ( (pid = waitpid(-1, &status, WNOHANG)) != 0 ) {
rp = lookup_slot_by_pid(pid);
if(rp != NULL) {
- rpub = rp->r_pub;
if(rs_verbose)
printf("RS: %s exited via another signal manager\n",
int code; /* status code */
{
/* If a caller is waiting for a reply, unblock it. */
- struct rprocpub *rpub;
-
- rpub = rp->r_pub;
-
if(rp->r_flags & RS_LATEREPLY) {
message m;
m.m_type = code;
}
for (off = 0; off < (off_t) len; off += CLICK_SIZE) {
- r = sys_vircopy(fp->fp_endpoint,
- (vir_bytes) (seg_off + off),
+ vir_bytes p = (vir_bytes) (seg_off + off);
+ r = sys_vircopy(fp->fp_endpoint, p,
SELF, (vir_bytes) buf,
(phys_bytes) CLICK_SIZE);
+ if(r != OK) {
+ printf("VFS: vircopy failed for %d @ 0x%lx during coredump\n",
+ fp->fp_endpoint, p);
+ break;
+ }
+
write_buf(f, (char *) buf, (off + CLICK_SIZE <= (off_t) len) ?
CLICK_SIZE : (len - off));
}
/*===========================================================================*
* do_pm *
*===========================================================================*/
-static void *do_pm(void *arg)
+static void *do_pm(void *arg __unused)
{
- struct job my_job;
- struct fproc *rfp;
-
- my_job = *((struct job *) arg);
- rfp = fp = my_job.j_fp;
-
lock_pm();
service_pm();
unlock_pm();
{
/* Go get path and put it in 'dest'.
*/
- register char *rpu, *rpm;
-
if (len > PATH_MAX) { /* 'len' includes terminating-nul */
err_code = ENAMETOOLONG;
return(EGENERIC);
if (len <= M3_STRING) {
/* Just copy the path from the message */
- rpu = &dest[0];
- rpm = job_m_in.pathname; /* contained in input message */
strncpy(dest, job_m_in.pathname, len);
} else {
/* String is not contained in the message. */
message msg;
int result, who_e, rcv_sts;
int caller_slot;
- struct vmproc *vmp_caller;
/* Initialize system so that all processes are runnable */
init_vm();
who_e = msg.m_source;
if(vm_isokendpt(who_e, &caller_slot) != OK)
panic("invalid caller %d", who_e);
- vmp_caller = &vmproc[caller_slot];
c = CALLNUMBER(msg.m_type);
result = ENOSYS; /* Out of range or restricted calls return this. */
int r, n;
endpoint_t ep;
vir_bytes sp;
- struct vmproc *vmp;
ep = msg->VMPS_ENDPOINT;
printf("VM: bogus endpoint %d from %d\n", ep, msg->m_source);
return r;
}
- vmp = &vmproc[n];
if ((r=get_stack_ptr(ep, &sp)) != OK)
panic("couldn't get new stack pointer (for sig): %d", r);
FS=ext2fs
CLEANFILES= lib
CPPFLAGS+= -D_MINIX
+CFLAGS+= -Os
.include <../Makefile.bootxx>