Commit 27c43263 authored by Linus Torvalds's avatar Linus Torvalds

Import 0.99.14i

parent 3b100d90
......@@ -922,8 +922,12 @@ static int check_sense (Scsi_Cmnd * SCpnt)
switch (SCpnt->sense_buffer[2] & 0xf)
{
case NO_SENSE:
case RECOVERED_ERROR:
return 0;
case RECOVERED_ERROR:
if (scsi_devices[SCpnt->index].type == TYPE_TAPE)
return SUGGEST_IS_OK;
else
return 0;
case ABORTED_COMMAND:
return SUGGEST_RETRY;
......@@ -1041,6 +1045,8 @@ static void scsi_done (Scsi_Cmnd * SCpnt)
update_timeout(SCpnt, oldto);
status = REDO;
break;
case SUGGEST_IS_OK:
break;
case SUGGEST_REMAP:
case SUGGEST_RETRY:
#ifdef DEBUG
......
......@@ -192,6 +192,7 @@ extern const unsigned char scsi_command_size[8];
#define SUGGEST_REMAP 0x30
#define SUGGEST_DIE 0x40
#define SUGGEST_SENSE 0x80
#define SUGGEST_IS_OK 0xff
#define DRIVER_SENSE 0x08
......
This diff is collapsed.
......@@ -18,6 +18,7 @@ typedef struct {
int read_pointer;
int writing;
int last_result;
int last_result_fatal;
unsigned char b_data[1];
} ST_buffer;
......@@ -37,9 +38,20 @@ typedef struct {
int block_size;
int min_block;
int max_block;
int recover_count;
Scsi_Cmnd SCpnt;
} Scsi_Tape;
/* Values of eof */
#define ST_NOEOF 0
#define ST_FM 1
#define ST_EOM_OK 2
#define ST_EOM_ERROR 3
/* Values of rw */
#define ST_IDLE 0
#define ST_READING 1
#define ST_WRITING 2
/* Positioning SCSI-commands for Tandberg, etc. drives */
#define QFA_REQUEST_BLOCK 0x02
......
This diff is collapsed.
......@@ -132,6 +132,15 @@ __ntohl(unsigned long int x)
return x;
}
static __inline__ unsigned long int
__constant_ntohl(unsigned long int x)
{
return (((x & 0x000000ff) << 24) |
((x & 0x0000ff00) << 8) |
((x & 0x00ff0000) >> 8) |
((x & 0xff000000) >> 24));
}
static __inline__ unsigned short int
__ntohs(unsigned short int x)
{
......@@ -141,31 +150,35 @@ __ntohs(unsigned short int x)
return x;
}
static __inline__ unsigned long int
__htonl(unsigned long int x)
{
__asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */
"rorl $16,%0\n\t" /* swap words */
"xchgb %b0,%h0" /* swap higher bytes */
:"=q" (x)
: "0" (x));
return x;
}
static __inline__ unsigned short int
__htons(unsigned short int x)
__constant_ntohs(unsigned short int x)
{
__asm__("xchgb %b0,%h0" /* swap bytes */
: "=q" (x)
: "0" (x));
return x;
return (((x & 0x00ff) << 8) |
((x & 0xff00) >> 8));
}
#define __htonl(x) __ntohl(x)
#define __htons(x) __ntohs(x)
#define __constant_htonl(x) __constant_ntohl(x)
#define __constant_htons(x) __constant_ntohs(x)
#ifdef __OPTIMIZE__
# define ntohl(x) __ntohl((x))
# define ntohs(x) __ntohs((x))
# define htonl(x) __htonl((x))
# define htons(x) __htons((x))
# define ntohl(x) \
(__builtin_constant_p((x)) ? \
__constant_ntohl((x)) : \
__ntohl((x)))
# define ntohs(x) \
(__builtin_constant_p((x)) ? \
__constant_ntohs((x)) : \
__ntohs((x)))
# define htonl(x) \
(__builtin_constant_p((x)) ? \
__constant_htonl((x)) : \
__htonl((x)))
# define htons(x) \
(__builtin_constant_p((x)) ? \
__constant_htons((x)) : \
__htons((x)))
#endif
#endif /* _LINUX_IN_H */
......@@ -20,7 +20,7 @@ static int findkey (key_t key);
static struct msqid_ds *msgque[MSGMNI];
static int msgbytes = 0;
static int msghdrs = 0;
static int msg_seq = 0;
static unsigned short msg_seq = 0;
static int used_queues = 0;
static int max_msqid = 0;
static struct wait_queue *msg_lock = NULL;
......@@ -264,7 +264,7 @@ static int newque (key_t key, int msgflg)
used_queues++;
if (msg_lock)
wake_up (&msg_lock);
return msg_seq * MSGMNI + id;
return (int) msg_seq * MSGMNI + id;
}
int sys_msgget (key_t key, int msgflg)
......@@ -295,8 +295,7 @@ static void freeque (int id)
struct msg *msgp, *msgh;
msq->msg_perm.seq++;
if ((int)((++msg_seq + 1) * MSGMNI) < 0)
msg_seq = 0;
msg_seq++;
msgbytes -= msq->msg_cbytes;
if (id == max_msqid)
while (max_msqid && (msgque[--max_msqid] == IPC_UNUSED));
......
......@@ -20,9 +20,10 @@ static void freeary (int id);
static struct semid_ds *semary[SEMMNI];
static int used_sems = 0, used_semids = 0;
static struct wait_queue *sem_lock = NULL;
static int sem_seq = 0;
static int max_semid = 0;
static unsigned short sem_seq = 0;
void sem_init (void)
{
int i=0;
......@@ -95,7 +96,7 @@ static int newary (key_t key, int nsems, int semflg)
semary[id] = sma;
if (sem_lock)
wake_up (&sem_lock);
return sem_seq * SEMMNI + id;
return (int) sem_seq * SEMMNI + id;
}
int sys_semget (key_t key, int nsems, int semflg)
......@@ -128,8 +129,7 @@ static void freeary (int id)
struct sem_undo *un;
sma->sem_perm.seq++;
if ((int)((++sem_seq + 1) * SEMMNI) < 0)
sem_seq = 0;
sem_seq++;
used_sems -= sma->sem_nsems;
if (id == max_semid)
while (max_semid && (semary[--max_semid] == IPC_UNUSED));
......
......@@ -23,11 +23,12 @@ static void killseg (int id);
static int shm_tot = 0; /* total number of shared memory pages */
static int shm_rss = 0; /* number of shared memory pages that are in memory */
static int shm_swp = 0; /* number of shared memory pages that are in swap */
static int shm_seq = 0; /* is incremented, for recognizing stale ids */
static int max_shmid = 0; /* every used id is <= max_shmid */
static struct wait_queue *shm_lock = NULL;
static struct shmid_ds *shm_segs[SHMMNI];
static unsigned short shm_seq = 0; /* incremented, for recognizing stale ids */
/* some statistics */
static ulong swap_attempts = 0;
static ulong swap_successes = 0;
......@@ -119,7 +120,7 @@ static int newseg (key_t key, int shmflg, int size)
used_segs++;
if (shm_lock)
wake_up (&shm_lock);
return id + shm_seq*SHMMNI;
return id + (int)shm_seq*SHMMNI;
}
int sys_shmget (key_t key, int size, int shmflg)
......@@ -165,8 +166,7 @@ static void killseg (int id)
}
shp->shm_perm.seq++; /* for shmat */
numpages = shp->shm_npages;
if ((int)((++shm_seq + 1) * SHMMNI) < 0)
shm_seq = 0;
shm_seq++;
shm_segs[id] = (struct shmid_ds *) IPC_UNUSED;
used_segs--;
if (id == max_shmid)
......
......@@ -80,7 +80,7 @@ asmlinkage int sys_syslog(int type, char * buf, int len)
sti();
return -ERESTARTSYS;
}
interruptible_sleep_on(&log_wait);
interruptible_sleep_on(&log_wait);
}
i = 0;
while (log_size && i < len) {
......@@ -88,9 +88,11 @@ asmlinkage int sys_syslog(int type, char * buf, int len)
log_start++;
log_size--;
log_start &= LOG_BUF_LEN-1;
sti();
put_fs_byte(c,buf);
buf++;
i++;
cli();
}
sti();
return i;
......
......@@ -210,11 +210,11 @@ icmp_redirect(struct icmphdr *icmph, struct sk_buff *skb, struct device *dev)
ip = iph->daddr;
switch(icmph->code & 7) {
case ICMP_REDIR_NET:
rt_add((RTF_DYNAMIC | RTF_MODIFIED),
rt_add((RTF_DYNAMIC | RTF_MODIFIED | RTF_GATEWAY),
ip, icmph->un.gateway, dev);
break;
case ICMP_REDIR_HOST:
rt_add((RTF_DYNAMIC | RTF_MODIFIED | RTF_HOST),
rt_add((RTF_DYNAMIC | RTF_MODIFIED | RTF_HOST | RTF_GATEWAY),
ip, icmph->un.gateway, dev);
break;
case ICMP_REDIR_NETTOS:
......
......@@ -59,7 +59,7 @@
#ifdef INET_DEBUG
# define DPRINTF(x) dprintf x
#else
# define DPRINTF(x) /*zilch*/
# define DPRINTF(x) do ; while (0)
#endif
/* Debug levels. One per module. */
......
......@@ -112,6 +112,16 @@ void rt_flush(struct device *dev)
/*
* Used by 'rt_add()' when we can't get the netmask from the device..
*
* If the lower byte or two are zero, we guess the mask based on the
* number of zero 8-bit net numbers, otherwise we use the "default"
* masks judging by the destination address.
*
* We should really use masks everywhere, but the current system
* interface for adding routes doesn't even contain a netmask field.
* Similarly, ICMP redirect messages contain only the address to
* redirect.. Anyway, this function should give reasonable values
* for almost anything.
*/
static unsigned long guess_mask(unsigned long dst)
{
......@@ -119,7 +129,29 @@ static unsigned long guess_mask(unsigned long dst)
while (mask & dst)
mask <<= 8;
return ~mask;
if (mask)
return ~mask;
dst = ntohl(dst);
if (IN_CLASSA(dst))
return htonl(IN_CLASSA_NET);
if (IN_CLASSB(dst))
return htonl(IN_CLASSB_NET);
return htonl(IN_CLASSC_NET);
}
static inline struct device * get_gw_dev(unsigned long gw)
{
struct rtable * rt;
for (rt = rt_base ; rt ; rt = rt->rt_next) {
if ((gw ^ rt->rt_dst) & rt->rt_mask)
continue;
/* gateways behind gateways are a no-no */
if (rt->rt_flags & RTF_GATEWAY)
return NULL;
return rt->rt_dev;
}
return NULL;
}
/*
......@@ -133,42 +165,40 @@ rt_add(short flags, unsigned long dst, unsigned long gw, struct device *dev)
unsigned long mask;
unsigned long cpuflags;
/* Allocate an entry. */
rt = (struct rtable *) kmalloc(sizeof(struct rtable), GFP_ATOMIC);
if (rt == NULL) {
DPRINTF((DBG_RT, "RT: no memory for new route!\n"));
return;
}
/* Fill in the fields. */
memset(rt, 0, sizeof(struct rtable));
rt->rt_flags = (flags | RTF_UP);
/*
* Gateway to our own interface is really direct
*/
if (gw == dev->pa_addr || gw == dst) {
gw=0;
rt->rt_flags&=~RTF_GATEWAY;
}
if (gw != 0)
rt->rt_flags |= RTF_GATEWAY;
rt->rt_dev = dev;
rt->rt_gateway = gw;
if (flags & RTF_HOST) {
mask = 0xffffffff;
rt->rt_dst = dst;
} else {
if (!((dst ^ dev->pa_addr) & dev->pa_mask)) {
mask = dev->pa_mask;
dst &= mask;
flags &= ~RTF_GATEWAY;
if (flags & RTF_DYNAMIC) {
kfree_s(rt, sizeof(struct rtable));
/*printk("Dynamic route to my own net rejected\n");*/
return;
}
} else
mask = guess_mask(dst);
rt->rt_dst = dst;
}
if (gw == dev->pa_addr)
flags &= ~RTF_GATEWAY;
if (flags & RTF_GATEWAY) {
/* don't try to add a gateway we can't reach.. */
if (dev != get_gw_dev(gw))
return;
flags |= RTF_GATEWAY;
} else
gw = 0;
/* Allocate an entry. */
rt = (struct rtable *) kmalloc(sizeof(struct rtable), GFP_ATOMIC);
if (rt == NULL) {
DPRINTF((DBG_RT, "RT: no memory for new route!\n"));
return;
}
memset(rt, 0, sizeof(struct rtable));
rt->rt_flags = flags | RTF_UP;
rt->rt_dst = dst;
rt->rt_dev = dev;
rt->rt_gateway = gw;
rt->rt_mask = mask;
rt_print(rt);
/*
......@@ -181,11 +211,11 @@ rt_add(short flags, unsigned long dst, unsigned long gw, struct device *dev)
/* remove old route if we are getting a duplicate. */
rp = &rt_base;
while ((r = *rp) != NULL) {
if (r->rt_dst != dst) {
rp = &r->rt_next;
continue;
}
*rp = r->rt_next;
if (r->rt_dst != dst) {
rp = &r->rt_next;
continue;
}
*rp = r->rt_next;
kfree_s(r, sizeof(struct rtable));
}
/* add the new route */
......@@ -206,7 +236,6 @@ static int
rt_new(struct rtentry *r)
{
struct device *dev;
struct rtable *rt;
if ((r->rt_dst.sa_family != AF_INET) ||
(r->rt_gateway.sa_family != AF_INET)) {
......@@ -226,11 +255,7 @@ rt_new(struct rtentry *r)
if (!(r->rt_flags & RTF_GATEWAY))
dev = dev_check(((struct sockaddr_in *) &r->rt_dst)->sin_addr.s_addr);
else
if ((rt = rt_route(((struct sockaddr_in *) &r->rt_gateway)->sin_addr.
s_addr,NULL)))
dev = rt->rt_dev;
else
dev = NULL;
dev = get_gw_dev(((struct sockaddr_in *) &r->rt_gateway)->sin_addr.s_addr);
DPRINTF((DBG_RT, "RT: dev for %s gw ",
in_ntoa((*(struct sockaddr_in *)&r->rt_dst).sin_addr.s_addr)));
......@@ -269,13 +294,14 @@ rt_get_info(char *buffer)
pos = buffer;
pos += sprintf(pos,
"Iface\tDestination\tGateway \tFlags\tRefCnt\tUse\tMetric\n");
"Iface\tDestination\tGateway \tFlags\tRefCnt\tUse\tMetric\tMask\n");
/* This isn't quite right -- r->rt_dst is a struct! */
for (r = rt_base; r != NULL; r = r->rt_next) {
pos += sprintf(pos, "%s\t%08lX\t%08lX\t%02X\t%d\t%lu\t%d\n",
pos += sprintf(pos, "%s\t%08lX\t%08lX\t%02X\t%d\t%lu\t%d\t%08lX\n",
r->rt_dev->name, r->rt_dst, r->rt_gateway,
r->rt_flags, r->rt_refcnt, r->rt_use, r->rt_metric);
r->rt_flags, r->rt_refcnt, r->rt_use, r->rt_metric,
r->rt_mask);
}
return(pos - buffer);
}
......
......@@ -212,14 +212,16 @@ int main(int argc, char ** argv)
fprintf(stderr, "Unexpected EOF\n");
die("Can't read 'system'");
}
write(1, buf, l);
if (write(1, buf, l) != l)
die("Write failed");
sz -= l;
}
close(id);
if (lseek(1,500,0) == 500) {
buf[0] = (sys_size & 0xff);
buf[1] = ((sys_size >> 8) & 0xff);
write(1, buf, 2);
if (write(1, buf, 2) != 2)
die("Write failed");
}
return(0);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment