## diffname port/devwren.c 1991/0110
## diff -e /dev/null /n/bootesdump/1991/0110/sys/src/9/68020/devwren.c
0a
#include "u.h"
#include "lib.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
#include "errno.h"
#include "devtab.h"
#include "io.h"
#include "scsi.h"
enum {
Qdir, Qdata, Qstruct,
};
static Dirtab wrendir[]={
"data", {Qdata}, 0, 0600,
"struct", {Qstruct}, 8, 0400,
};
#define NWREN (sizeof wrendir/sizeof(Dirtab))
static long maxblock[64];
static long blocksize[64];
static Scsi staticcmd; /* BUG */
static uchar datablk[4*512]; /* BUG */
/*
* accepts [0-7].[0-7], or abbreviation
*/
static int
wrendev(char *p)
{
int dev = 0;
if (p==0 || p[0]==0)
goto out;
if (p[0]<'0' || p[0]>'7')
goto cant;
dev = (p[0]-'0')<<3;
if (p[1]==0)
goto out;
if (p[1]!='.')
goto cant;
if (p[2]==0)
goto out;
if (p[2]<'0' || p[2]>'7')
goto cant;
dev |= p[2]-'0';
if (p[3]!=0)
goto cant;
out:
return dev;
cant:
error(Ebadarg);
}
static int
wrengen(Chan *c, Dirtab *tab, long ntab, long s, Dir *dp)
{
long l;
if(tab==0 || s>=ntab)
return -1;
tab+=s;
if (tab->qid.path==Qdata && 0<=c->dev && c->dev<64)
l = maxblock[c->dev]*blocksize[c->dev];
else
l = tab->length;
devdir(c, tab->qid, tab->name, l, tab->perm, dp);
return 1;
}
void
wrenreset(void)
{}
void
wreninit(void)
{
Scsi *cmd = &staticcmd;
cmd->cmd.base = cmd->cmdblk;
cmd->data.base = datablk;
}
/*
* param is #r<target>.<lun>
*/
Chan *
wrenattach(char *param)
{
uchar buf[32];
int dev;
Chan *c;
dev = wrendev(param);
scsiready(dev);
scsisense(dev, buf);
scsicap(dev, buf);
c = devattach('r', param);
c->dev = dev;
maxblock[dev] = BGLONG(&buf[0]);
blocksize[dev] = BGLONG(&buf[4]);
return c;
}
Chan *
wrenclone(Chan *c, Chan *nc)
{
return devclone(c, nc);
}
int
wrenwalk(Chan *c, char *name)
{
return devwalk(c, name, wrendir, NWREN, wrengen);
}
void
wrenstat(Chan *c, char *db)
{
devstat(c, db, wrendir, NWREN, wrengen);
}
Chan *
wrenopen(Chan *c, int omode)
{
if (c->qid.path == Qdata && scsiready(c->dev) != 0)
error(Eio);
return devopen(c, omode, wrendir, NWREN, wrengen);
}
void
wrencreate(Chan *c, char *name, int omode, ulong perm)
{
error(Eperm);
}
void
wrenclose(Chan *c)
{}
#define PSHORT(p, v) ((p)[0]=(v), (p)[1]=((v)>>8))
#define PLONG(p, v) (PSHORT(p, (v)), PSHORT(p+2, (v)>>16))
long
wrenread(Chan *c, char *a, long n)
{
Scsi *cmd = &staticcmd;
unsigned long lbn;
if (n == 0)
return 0;
switch ((int)(c->qid.path & ~CHDIR)) {
case Qdir:
return devdirread(c, a, n, wrendir, NWREN, wrengen);
case Qdata:
if (n % blocksize[c->dev] || c->offset % blocksize[c->dev])
error(Ebadarg);
lbn = c->offset/blocksize[c->dev];
if (lbn >= maxblock[c->dev])
error(Ebadarg);
if (n > sizeof datablk)
n = sizeof datablk;
qlock(cmd);
if (waserror()) {
qunlock(cmd);
nexterror();
}
cmd->target = c->dev>>3;
cmd->lun = c->dev&7;
cmd->cmd.ptr = cmd->cmd.base;
cmd->cmdblk[0] = 0x08;
cmd->cmdblk[1] = lbn>>16;
cmd->cmdblk[2] = lbn>>8;
cmd->cmdblk[3] = lbn;
cmd->cmdblk[4] = n/blocksize[c->dev];
cmd->cmdblk[5] = 0x00;
cmd->cmd.lim = &cmd->cmdblk[6];
cmd->data.lim = cmd->data.base + n;
cmd->data.ptr = cmd->data.base;
cmd->save = cmd->data.base;
scsiexec(cmd, 1);
n = cmd->data.ptr - cmd->data.base;
memcpy(a, cmd->data.base, n);
qunlock(cmd);
break;
case Qstruct:
if (n < 8)
error(Ebadarg);
if (c->offset >= 8)
return 0;
n = 8;
PLONG((uchar *)&a[0], maxblock[c->dev]);
PLONG((uchar *)&a[4], blocksize[c->dev]);
break;
default:
panic("wrenread");
}
return n;
}
long
wrenwrite(Chan *c, char *a, long n)
{
Scsi *cmd = &staticcmd;
unsigned long lbn;
if (n == 0)
return 0;
switch ((int)(c->qid.path & ~CHDIR)) {
case Qdata:
if (n % blocksize[c->dev] || c->offset % blocksize[c->dev])
error(Ebadarg);
lbn = c->offset/blocksize[c->dev];
if (lbn >= maxblock[c->dev])
error(Ebadarg);
if (n > sizeof datablk)
n = sizeof datablk;
qlock(cmd);
if (waserror()) {
qunlock(cmd);
nexterror();
}
cmd->target = c->dev>>3;
cmd->lun = c->dev&7;
cmd->cmd.ptr = cmd->cmd.base;
cmd->cmdblk[0] = 0x0a;
cmd->cmdblk[1] = lbn>>16;
cmd->cmdblk[2] = lbn>>8;
cmd->cmdblk[3] = lbn;
cmd->cmdblk[4] = n/blocksize[c->dev];
cmd->cmdblk[5] = 0x00;
cmd->cmd.lim = &cmd->cmdblk[6];
cmd->data.lim = cmd->data.base + n;
cmd->data.ptr = cmd->data.base;
cmd->save = cmd->data.base;
memcpy(cmd->data.base, a, n);
scsiexec(cmd, 0);
n = cmd->data.ptr - cmd->data.base;
qunlock(cmd);
break;
default:
panic("wrenwrite");
}
return n;
}
void
wrenremove(Chan *c)
{
error(Eperm);
}
void
wrenwstat(Chan *c, char *dp)
{
error(Eperm);
}
.
## diffname port/devwren.c 1991/0112
## diff -e /n/bootesdump/1991/0110/sys/src/9/68020/devwren.c /n/bootesdump/1991/0112/sys/src/9/68020/devwren.c
227c
cmd->cmdblk[4] = n/d->blocksize;
.
210,211c
lbn = c->offset/d->blocksize + p->firstblock;
if (lbn >= p->maxblock)
.
208c
if (n % d->blocksize || c->offset % d->blocksize)
.
206c
d = &wren[c->dev];
p = &(d->p[Mask&c->qid.path]);
switch ((int)(c->qid.path & ~Mask)) {
.
203a
Part *p;
Disk *d;
.
190,191c
PLONG((uchar *)&a[0], p->maxblock - p->firstblock);
PLONG((uchar *)&a[4], d->blocksize);
.
173c
cmd->cmdblk[4] = n/d->blocksize;
.
156,157c
lbn = (c->offset/d->blocksize) + p->firstblock;
if (lbn >= p->maxblock)
.
154c
if (n % d->blocksize || c->offset % d->blocksize)
.
152a
d = &wren[c->dev];
p = &(d->p[Mask&c->qid.path]);
switch ((int)(c->qid.path & ~Mask)) {
.
150,151c
if(c->qid.path == CHDIR)
.
147a
Part *p;
Disk *d;
.
100,101c
d = &wren[dev];
d->blocksize = BGLONG(&buf[4]);
plen = BGLONG(&buf[0]);
d->p[Npart].firstblock = 0;
d->p[Npart].maxblock = plen;
plen = plen/Npart;
for(i = 0; i < Npart; i++){
d->p[i].firstblock = i*plen;
d->p[i].maxblock = (i+1)*plen;
}
.
93a
Disk *d;
ulong plen;
int i;
.
76a
p = wrendir = ialloc((Npart+1) * 2 * sizeof(Dirtab), 0);
for(i = 0; i < Npart; i++){
sprint(p->name, "data%d", i);
p->qid.path = Qdata + i;
p->perm = 0600;
p++->length = 0;
strcpy(p->name, "struct%d");
p->qid.path = Qstruct + i;
p->perm = 0600;
p++->length = 0;
}
strcpy(p->name, "data");
p->qid.path = Qdata + Npart;
p->perm = 0600;
p++->length = 0;
strcpy(p->name, "struct");
p->qid.path = Qstruct + Npart;
p->perm = 0600;
p->length = 0;
}
.
75c
{
Dirtab *p;
int i;
.
68c
l = 8;
.
64,66c
if(c->dev >= Ndisk)
return -1;
tab += s;
d = &wren[c->dev];
p = &d->p[tab->qid.path&Mask];
if((tab->qid.path&~Mask) == Qdata)
l = d->blocksize * (p->maxblock - p->firstblock);
.
62c
Part *p;
Disk *d;
if(s >= ntab)
.
52a
if(dev >= Ndisk)
error(Ebadarg);
.
28a
static Scsi staticcmd; /* BUG */
static uchar datablk[2*4*512]; /* BUG */
.
26,27c
static Disk wren[Ndisk];
.
23,24c
struct Part
{
ulong firstblock;
ulong maxblock;
};
struct Disk
{
ulong blocksize;
Part p[Npart];
};
.
21c
static Dirtab *wrendir;
#define NWREN (2*(Npart+1))
.
16,18c
Qdir= 0,
Qdata= 16,
Qstruct= 32,
Mask= 0x7,
.
13,14c
Npart= 2, /* maximum partitions per disk */
Ndisk= 64, /* maximum disks */
.
11a
typedef struct Part Part;
typedef struct Disk Disk;
.
## diffname port/devwren.c 1991/0115
## diff -e /n/bootesdump/1991/0112/sys/src/9/68020/devwren.c /n/bootesdump/1991/0115/sys/src/9/68020/devwren.c
111c
sprint(p->name, "struct%d", i);
.
44a
#define BGLONG(p) (((((((p)[0]<<8)|(p)[1])<<8)|(p)[2])<<8)|(p)[3])
.
42,43c
static Scsi staticcmd; /* BUG */
static uchar datablk[BY2PG]; /* BUG */
.
10,11d
## diffname port/devwren.c 1991/0318
## diff -e /n/bootesdump/1991/0201/sys/src/9/68020/devwren.c /n/bootesdump/1991/0318/sys/src/9/gnot/devwren.c
307c
memmove(cmd->data.base, a, n);
.
249c
memmove(a, cmd->data.base, n);
.
## diffname port/devwren.c 1991/0411
## diff -e /n/bootesdump/1991/0318/sys/src/9/gnot/devwren.c /n/bootesdump/1991/0411/sys/src/9/gnot/devwren.c
284c
lbn = offset/d->blocksize + p->firstblock;
.
282c
if (n % d->blocksize || offset % d->blocksize)
.
268c
wrenwrite(Chan *c, char *a, long n, ulong offset)
.
255c
if (offset >= 8)
.
224c
lbn = (offset/d->blocksize) + p->firstblock;
.
222c
if (n % d->blocksize || offset % d->blocksize)
.
205c
wrenread(Chan *c, char *a, long n, ulong offset)
.
## diffname port/devwren.c 1991/0419
## diff -e /n/bootesdump/1991/0411/sys/src/9/gnot/devwren.c /n/bootesdump/1991/0419/sys/src/9/gnot/devwren.c
177a
Chan*
wrenclwalk(Chan *c, char *name)
{
return devclwalk(c, name);
}
.
## diffname port/devwren.c 1991/0423
## diff -e /n/bootesdump/1991/0423/sys/src/9/gnot/devwren.c /n/bootesdump/1991/0423/sys/src/9/port/devwren.c
308,312d
300,303d
293,295c
if (n > DATASIZE)
n = DATASIZE;
cmd = scsicmd(c->dev, 0x0a, n);
.
276,277c
Scsi *cmd;
ulong lbn;
.
248,252d
240,243d
233,235c
if (n > DATASIZE)
n = DATASIZE;
cmd = scsicmd(c->dev, 0x08, n);
.
213,214c
Scsi *cmd;
ulong lbn;
.
128,132c
{}
.
40,41c
#define DATASIZE (8*1024) /* BUG */
.
## diffname port/devwren.c 1991/0427
## diff -e /n/bootesdump/1991/0423/sys/src/9/port/devwren.c /n/bootesdump/1991/0427/sys/src/9/port/devwren.c
173,178d
## diffname port/devwren.c 1991/0429
## diff -e /n/bootesdump/1991/0427/sys/src/9/port/devwren.c /n/bootesdump/1991/0429/sys/src/9/port/devwren.c
149a
print("Block size %lux capacity %lux\n", d->blocksize, BGLONG(&buf[0]));
.
## diffname port/devwren.c 1991/0530
## diff -e /n/bootesdump/1991/0429/sys/src/9/port/devwren.c /n/bootesdump/1991/0530/sys/src/9/port/devwren.c
151,152d
## diffname port/devwren.c 1991/0603
## diff -e /n/bootesdump/1991/0530/sys/src/9/port/devwren.c /n/bootesdump/1991/0603/sys/src/9/port/devwren.c
305a
}
void
wrenint(uchar *a, ulong x)
{
a[0] = x >> 24;
a[1] = x >> 16;
a[2] = x >> 8;
a[3] = x;
.
244,246c
n = 2*sizeof(ulong);
wrenint((uchar*)a, p->maxblock - p->firstblock);
wrenint((uchar*)a+sizeof(ulong), d->blocksize);
.
242c
if (offset >= 2*sizeof(ulong))
.
240c
if (n < 2*sizeof(ulong))
.
198,199d
39a
void wrenint(uchar*, ulong);
.
## diffname port/devwren.c 1991/0604
## diff -e /n/bootesdump/1991/0603/sys/src/9/port/devwren.c /n/bootesdump/1991/0604/sys/src/9/port/devwren.c
288a
poperror();
.
237a
poperror();
.
## diffname port/devwren.c 1991/0615
## diff -e /n/bootesdump/1991/0604/sys/src/9/port/devwren.c /n/bootesdump/1991/0615/sys/src/9/port/devwren.c
153c
plen = BGLONG(&buf[0])+1;
.
## diffname port/devwren.c 1991/0705
## diff -e /n/bootesdump/1991/0615/sys/src/9/port/devwren.c /n/bootesdump/1991/0705/sys/src/9/port/devwren.c
153c
plen = BGLONG(&buf[0]);
.
## diffname port/devwren.c 1991/0706
## diff -e /n/bootesdump/1991/0705/sys/src/9/port/devwren.c /n/bootesdump/1991/0706/sys/src/9/port/devwren.c
153c
plen = BGLONG(&buf[0])+1;
.
## diffname port/devwren.c 1991/0823
## diff -e /n/bootesdump/1991/0706/sys/src/9/port/devwren.c /n/bootesdump/1991/0823/sys/src/9/port/devwren.c
310,316c
/*
* read partition table from disk, null terminate
*/
cmd = scsicmd(dev, 0x08, dp->bytes);
if(waserror()){
qunlock(cmd);
nexterror();
}
n = dp->p[0].end-1;
cmd->cmdblk[1] = n>>16;
cmd->cmdblk[2] = n>>8;
cmd->cmdblk[3] = n;
cmd->cmdblk[4] = 1;
scsiexec(cmd, 1);
cmd->data.base[dp->bytes-1] = 0;
/*
* parse partition table.
*/
n = getfields((char *)cmd->data.base, line, Npart+1, '\n');
if(strncmp(line[0], MAGIC, sizeof(MAGIC)-1) != 0)
goto out;
for(i = 1; i < n; i++){
pp++;
if(getfields(line[i], field, 3, ' ') != 3){
break;
}
strncpy(pp->name, field[0], NAMELEN);
pp->start = strtoul(field[1], 0, 0);
pp->end = strtoul(field[2], 0, 0);
if(pp->start > pp->end || pp->start >= dp->p[0].end){
break;
}
dp->npart++;
}
out:
qunlock(cmd);
poperror();
.
304,308c
scsiready(dev);
scsisense(dev, buf);
scsicap(dev, buf);
dp = &wren[dev];
dp->drive = dev;
if(dp->npart)
return;
/*
* we always have a partition for the whole disk
* and one for the partition table
*/
dp->bytes = (buf[4]<<24)+(buf[5]<<16)+(buf[6]<<8)+(buf[7]);
pp = &dp->p[0];
strcpy(pp->name, "disk");
pp->start = 0;
pp->end = (buf[0]<<24)+(buf[1]<<16)+(buf[2]<<8)+(buf[3]) + 1;
pp++;
strcpy(pp->name, "partition");
pp->start = dp->p[0].end - 1;
pp->end = dp->p[0].end;
dp->npart = 2;
.
301,302c
Scsi *cmd;
Drive *dp;
Partition *pp;
uchar buf[32];
char *b;
char *line[Npart+1];
char *field[3];
ulong n;
int i;
.
298,299c
/*
* read partition table. The partition table is just ascii strings.
*/
#define MAGIC "plan9 partitions"
static void
wrenpart(int dev)
.
294a
cmd->cmdblk[1] = block>>16;
cmd->cmdblk[2] = block>>8;
cmd->cmdblk[3] = block;
cmd->cmdblk[4] = n;
if(write)
memmove(cmd->data.base, a, n*d->bytes);
scsiexec(cmd, !write);
n = cmd->data.ptr - cmd->data.base;
if(!write)
memmove(a, cmd->data.base, n);
qunlock(cmd);
poperror();
.
290,293c
nexterror();
.
265,288c
if(n > DATASIZE)
n = DATASIZE;
n /= d->bytes;
if(block + n > p->end)
n = p->end - block;
if(n == 0)
return 0;
if(write)
cmd = scsicmd(d->drive, 0x0a, n*d->bytes);
else
cmd = scsicmd(d->drive, 0x08, n*d->bytes);
if(waserror()){
.
263c
if(n % d->bytes || offset % d->bytes)
error(Ebadarg);
block = offset / d->bytes + p->start;
if(block >= p->end)
.
259,261c
void *b;
ulong block;
.
257a
Drive *d;
Partition *p;
d = &wren[DRIVE(c->qid.path)];
p = &d->p[PART(c->qid.path)];
return wrenio(d, p, 1, a, n, offset);
}
static long
wrenio(Drive *d, Partition *p, int write, char *a, ulong n, ulong offset)
{
.
214,252c
d = &wren[DRIVE(c->qid.path)];
p = &d->p[PART(c->qid.path)];
return wrenio(d, p, 0, a, n, offset);
.
212c
return devdirread(c, a, n, 0, 0, wrengen);
.
208,209d
203,206c
Drive *d;
Partition *p;
.
199a
void
wrenremove(Chan *c)
{
error(Eperm);
}
void
wrenwstat(Chan *c, char *dp)
{
error(Eperm);
}
.
198c
{
}
.
185,187c
return devopen(c, omode, 0, 0, wrengen);
.
182c
Chan*
.
179c
devstat(c, dp, 0, 0, wrengen);
.
177c
wrenstat(Chan *c, char *dp)
.
173c
return devwalk(c, name, 0, 0, wrengen);
.
164c
Chan*
.
149,160c
c->dev = drive;
.
144,147c
drive = wrendev(param);
wrenpart(drive);
.
140,142c
int drive;
.
137,138d
129c
{
}
.
103,124d
89,96c
if(s >= dp->npart)
return 0;
pp = &dp->p[s];
sprint(name, "hd%d%s", drive, pp->name);
name[NAMELEN] = 0;
qid.path = MKQID(drive, s);
l = (pp->end - pp->start) * dp->bytes;
devdir(c, qid, name, l, 0600, dirp);
.
86,87c
dp = &wren[drive];
.
84c
qid.vers = 0;
drive = s/Npart;
s = s % Npart;
if(drive >= Ndisk)
.
80,82c
Qid qid;
int drive;
char name[NAMELEN+4];
Drive *dp;
Partition *pp;
ulong l;
.
78c
wrengen(Chan *c, Dirtab *tab, long ntab, long s, Dir *dirp)
.
66,67c
dev |= p[2] - '0';
if(p[3] != 0)
.
64c
if(p[2] < '0' || p[2] > '7')
.
62c
if(p[2] == 0)
.
60c
if(p[1] != '.')
.
57,58c
dev = (p[0] - '0') << 3;
if(p[1] == 0)
.
55c
if(p[0] < '0' || p[0] > '7')
.
53c
if(p == 0 || p[0] == 0)
.
44c
static void wrenpart(int);
static long wrenio(Drive *, Partition *, int, char *, ulong, ulong);
.
40,41d
38c
static Drive wren[Ndisk];
.
34,35c
ulong bytes; /* bytes per block */
int npart; /* actual number of partitions */
int drive;
Partition p[Npart];
.
32c
struct Drive
.
29,30c
ulong start;
ulong end;
char name[NAMELEN+1];
.
24,27c
struct Partition
.
22a
#define PART(x) ((x)&0xF)
#define DRIVE(x) (((x)>>4)&0x7)
#define MKQID(d,p) (((d)<<4) | (p))
.
18,21d
16a
/* file types */
.
14c
Npart= 8+2, /* 8 sub partitions, disk, and partition */
.
10,11c
typedef struct Partition Partition;
typedef struct Drive Drive;
.
## diffname port/devwren.c 1991/0921
## diff -e /n/bootesdump/1991/0823/sys/src/9/port/devwren.c /n/bootesdump/1991/0921/sys/src/9/port/devwren.c
128c
c = devattach('w', param);
.
## diffname port/devwren.c 1991/0927
## diff -e /n/bootesdump/1991/0921/sys/src/9/port/devwren.c /n/bootesdump/1991/0927/sys/src/9/port/devwren.c
324a
scsifree(b);
.
322,323d
314,320d
306,312c
n = getfields(rawpart, line, Npart+1, '\n');
if(strncmp(line[0], MAGIC, sizeof(MAGIC)-1) == 0){
for(i = 1; i < n; i++){
pp++;
if(getfields(line[i], field, 3, ' ') != 3){
break;
}
strncpy(pp->name, field[0], NAMELEN);
pp->start = strtoul(field[1], 0, 0);
pp->end = strtoul(field[2], 0, 0);
if(pp->start > pp->end || pp->start >= dp->p[0].end){
break;
}
dp->npart++;
.
295,301c
scsibread(dev, b, 1, dp->bytes, dp->p[0].end-1);
rawpart = b->virt;
rawpart[dp->bytes-1] = 0;
.
292c
scsifree(b);
.
290c
b = scsibuf();
.
270,271c
.
259,261c
Scsibuf *b;
char *rawpart, *line[Npart+1], *field[3];
.
255d
244a
scsifree(b);
.
233,243c
if(write){
memmove(b->virt, a, n*d->bytes);
n = scsibwrite(d->drive, b, n, d->bytes, block);
}else{
n = scsibread(d->drive, b, n, d->bytes, block);
memmove(a, b->virt, n);
}
.
230c
scsifree(b);
.
225,228c
b = scsibuf();
.
209,210c
Scsibuf *b;
.
201a
if(d->npart == 0)
errors("bad drive");
.
190a
if(d->npart == 0)
errors("bad drive");
.
99c
if(drive & 7)
sprint(name, "hd%d.%d%s", drive>>3, drive&7, pp->name);
else
sprint(name, "hd%d%s", drive>>3, pp->name);
.
96c
return -1;
.
89,90c
drive = c->dev;
.
41,42d
21c
#define DRIVE(x) (((x)>>4)&(Ndisk-1))
.
15c
Ndisk= 64, /* maximum disks; must be power of 2 or change DRIVE */
.
9a
#define DATASIZE (8*1024)
.
## diffname port/devwren.c 1991/1019
## diff -e /n/bootesdump/1991/0927/sys/src/9/port/devwren.c /n/bootesdump/1991/1019/sys/src/9/port/devwren.c
219c
errors("io not block aligned");
.
207c
errors("drive repartitioned");
.
194c
errors("drive repartitioned");
.
57,75c
errors("bad scsi drive specifier");
drive = p[0] - '0';
unit = 0;
if(p[1]){
if(p[1] != '.' || p[2] < '0' || p[2] > '7' || p[3] != '\0')
errors("bad scsi unit specifier");
unit = p[2] - '0';
}
return (drive << 3) | unit;
.
54,55c
if(p == 0 || p[0] == '\0')
return 0;
.
52c
int drive, unit;
.
17c
Ndisk= 64, /* maximum disks; if you change it, you must
map from dev to disk */
.
## diffname port/devwren.c 1991/1109
## diff -e /n/bootesdump/1991/1019/sys/src/9/port/devwren.c /n/bootesdump/1991/1109/sys/src/9/port/devwren.c
96c
devdir(c, qid, name, l, eve, 0600, dirp);
.
## diffname port/devwren.c 1991/1112
## diff -e /n/bootesdump/1991/1109/sys/src/9/port/devwren.c /n/bootesdump/1991/1112/sys/src/9/port/devwren.c
96c
devdir(c, qid, name, l, eve, 0666, dirp);
.
## diffname port/devwren.c 1991/1203
## diff -e /n/bootesdump/1991/1112/sys/src/9/port/devwren.c /n/bootesdump/1991/1203/sys/src/9/port/devwren.c
235c
return len;
.
230,231c
x = scsibread(d->drive, b, n, d->bytes, block);
if(x < offset)
len = 0;
else if(len > x - offset)
len = x - offset;
memmove(a, (char*)b->virt + offset, len);
.
227,228c
if(offset || len % d->bytes){
x = scsibread(d->drive, b, n, d->bytes, block);
if(x < n * d->bytes){
n = x / d->bytes;
x = n * d->bytes - offset;
if(len > x)
len = x;
}
}
memmove((char*)b->virt + offset, a, len);
x = scsibwrite(d->drive, b, n, d->bytes, block);
if(x < offset)
len = 0;
else if(len > x - offset)
len = x - offset;
.
225a
offset %= d->bytes;
.
219c
if(block >= p->end || n == 0)
.
212,216c
n = (offset + len + d->bytes - 1) / d->bytes + p->start - block;
max = DATASIZE / d->bytes;
if(n > max)
n = max;
.
203,210d
200,201d
194a
Scsibuf *b;
ulong block, n, max, x;
.
192a
return wrenio(c, 1, a, n, offset);
}
static long
wrenio(Chan *c, int write, char *a, ulong len, ulong offset)
{
.
182,187c
return wrenio(c, 0, a, n, offset);
.
176,179d
45c
static long wrenio(Chan*, int, char*, ulong, ulong);
.
## diffname port/devwren.c 1991/1210
## diff -e /n/bootesdump/1991/1203/sys/src/9/port/devwren.c /n/bootesdump/1991/1210/sys/src/9/port/devwren.c
169a
USED(c, dp);
.
163a
USED(c);
.
158a
USED(c);
.
152a
USED(c, name, omode, perm);
.
## diffname port/devwren.c 1991/1220
## diff -e /n/bootesdump/1991/1210/sys/src/9/port/devwren.c /n/bootesdump/1991/1220/sys/src/9/port/devwren.c
265c
if (scsicap(dev, buf))
error(Eio);
.
## diffname port/devwren.c 1992/0109
## diff -e /n/bootesdump/1991/1220/sys/src/9/port/devwren.c /n/bootesdump/1992/0109/sys/src/9/port/devwren.c
301c
if(n > 0 && strncmp(line[0], MAGIC, sizeof(MAGIC)-1) == 0){
.
## diffname port/devwren.c 1992/0111
## diff -e /n/bootesdump/1992/0109/sys/src/9/port/devwren.c /n/bootesdump/1992/0111/sys/src/9/port/devwren.c
6c
#include "../port/error.h"
.
## diffname port/devwren.c 1992/0114
## diff -e /n/bootesdump/1992/0111/sys/src/9/port/devwren.c /n/bootesdump/1992/0114/sys/src/9/port/devwren.c
200,201c
if(d->npart == 0) /* drive repartitioned */
error(Eio);
.
63c
error(Ebadarg);
.
58c
error(Ebadarg);
.
## diffname port/devwren.c 1992/0129
## diff -e /n/bootesdump/1992/0114/sys/src/9/port/devwren.c /n/bootesdump/1992/0129/sys/src/9/port/devwren.c
188c
n = wrenio(c, 1, a, n, offset);
if(n)
return n;
error("end of device");
.
## diffname port/devwren.c 1992/0219
## diff -e /n/bootesdump/1992/0129/sys/src/9/port/devwren.c /n/bootesdump/1992/0219/sys/src/9/port/devwren.c
315d
313c
if(pp->start > pp->end || pp->start >= dp->p[0].end)
.
309d
307c
if(getfields(line[i], field, 3, ' ') != 3)
.
304c
if(strncmp(line[0], MAGIC, sizeof(MAGIC)-1) == 0){
.
266,268c
if(scsiready(dev)){
scsisense(dev, buf);
if(scsiready(dev))
print("scsi %d.%d not ready: sense 0x%2.2ux, code 0x%2.2ux\n",
dev>>3, dev&7, buf[2], buf[12]);
}
if(scsicap(dev, buf))
.
## diffname port/devwren.c 1992/0301
## diff -e /n/bootesdump/1992/0219/sys/src/9/port/devwren.c /n/bootesdump/1992/0301/sys/src/9/port/devwren.c
322a
qunlock(dp);
.
320a
dp->npart = pp - dp->p;
.
318c
pp++;
.
310d
306a
pp = &dp->p[2];
.
278,292d
272,275d
268,270c
if (scsicap(dev, buf))
error(Eio);
dp->drive = dev;
dp->ready = 1;
/*
* we always have a partition for the whole disk
* and one for the partition table
*/
dp->bytes = (buf[4]<<24)+(buf[5]<<16)+(buf[6]<<8)+(buf[7]);
pp = &dp->p[0];
strcpy(pp->name, "disk");
pp->start = 0;
pp->end = (buf[0]<<24)+(buf[1]<<16)+(buf[2]<<8)+(buf[3]) + 1;
pp++;
strcpy(pp->name, "partition");
pp->start = dp->p[0].end - 1;
pp->end = dp->p[0].end;
.
266c
dp = &wren[dev];
if(waserror()){
qunlock(dp);
nexterror();
}
qlock(dp);
if(!dp->ready){
scsiready(dev);
.
38a
int ready; /* true if ever ready */
.
35a
QLock;
.
## diffname port/devwren.c 1992/0303
## diff -e /n/bootesdump/1992/0301/sys/src/9/port/devwren.c /n/bootesdump/1992/0303/sys/src/9/port/devwren.c
328a
poperror();
.
## diffname port/devwren.c 1992/0321
## diff -e /n/bootesdump/1992/0303/sys/src/9/port/devwren.c /n/bootesdump/1992/0321/sys/src/9/port/devwren.c
2c
#include "../port/lib.h"
.
## diffname port/devwren.c 1992/0603
## diff -e /n/bootesdump/1992/0321/sys/src/9/port/devwren.c /n/bootesdump/1992/0603/sys/src/9/port/devwren.c
193a
return 0; /* not reached */
.
## diffname port/devwren.c 1992/0711
## diff -e /n/bootesdump/1992/0603/sys/src/9/port/devwren.c /n/bootesdump/1992/0711/sys/src/9/port/devwren.c
80a
USED(tab, ntab);
.
## diffname port/devwren.c 1992/0808
## diff -e /n/bootesdump/1992/0711/sys/src/9/port/devwren.c /n/bootesdump/1992/0808/sys/src/9/port/devwren.c
316c
if(n > 0 && strncmp(line[0], MAGIC, sizeof(MAGIC)-1) == 0){
.
284,297c
/*
* we always have a partition for the whole disk
* and one for the partition table
*/
dp->bytes = (buf[4]<<24)+(buf[5]<<16)+(buf[6]<<8)+(buf[7]);
pp = &dp->p[0];
strcpy(pp->name, "disk");
pp->start = 0;
pp->end = (buf[0]<<24)+(buf[1]<<16)+(buf[2]<<8)+(buf[3]) + 1;
pp++;
strcpy(pp->name, "partition");
pp->start = dp->p[0].end - 1;
pp->end = dp->p[0].end;
.
276,282c
scsiready(dev);
scsisense(dev, buf);
if(scsicap(dev, buf))
error(Eio);
dp->drive = dev;
dp->readonly = scsiwp(dev);
.
114c
* param is #w<target>.<lun>
.
99c
devdir(c, qid, name, l, eve, dp->readonly ? 0444 : 0666, dirp);
.
40c
int readonly;
.
## diffname port/devwren.c 1992/0825
## diff -e /n/bootesdump/1992/0808/sys/src/9/port/devwren.c /n/bootesdump/1992/0825/sys/src/9/port/devwren.c
296a
scsiinquiry(dev, buf, sizeof buf);
if(memcmp(&buf[8], "INSITE I325VM *F", 24) == 0)
scsimodesense(dev, 0x2e, buf, 0x2a);
.
264c
uchar buf[128];
.
## diffname port/devwren.c 1992/1009
## diff -e /n/bootesdump/1992/0825/sys/src/9/port/devwren.c /n/bootesdump/1992/1009/sys/src/9/port/devwren.c
277a
scsistartstop(dev, ScsiStartunit);
.
## diffname port/devwren.c 1992/1215
## diff -e /n/bootesdump/1992/1009/sys/src/9/port/devwren.c /n/bootesdump/1992/1215/sys/src/9/port/devwren.c
278a
scsisense(dev, buf);
.
## diffname port/devwren.c 1993/0115
## diff -e /n/bootesdump/1992/1215/sys/src/9/port/devwren.c /n/bootesdump/1993/0115/sys/src/9/port/devwren.c
95c
sprint(name, "sd%d%s", drive>>3, pp->name);
.
93c
sprint(name, "sd%d.%d%s", drive>>3, drive&7, pp->name);
.
## diffname port/devwren.c 1993/1124 # deleted
## diff -e /n/bootesdump/1993/0115/sys/src/9/port/devwren.c /n/fornaxdump/1993/1124/sys/src/brazil/port/devwren.c
1,336d
|