register struct dinode
*dp
;
io
->i_bn
= fsbtodb(itod(n
)) + io
->i_boff
;
dp
= (struct dinode
*)io
->i_buf
;
io
->i_ino
.i_mode
= dp
->di_mode
;
io
->i_ino
.i_size
= dp
->di_size
;
l3tol((char *)io
->i_ino
.i_un
.i_addr
, (char *)dp
->di_addr
, NADDR
);
if (path
==NULL
|| *path
=='\0') {
openi((ino_t
) ROOTINO
, file
);
while(*q
!= '/' && *q
!= '\0')
if ((n
=dlook(path
, file
))!=0) {
printf("%s not found\n",path
);
register struct inode
*ip
;
* blocks 0..NADDR-4 are direct blocks
* addresses NADDR-3, NADDR-2, and NADDR-1
* have single, double, triple indirect blocks.
* the first step is to determine
* how many levels of indirection.
printf("bn ovf %D\n",bn
);
* fetch the address from the inode
nb
= ip
->i_un
.i_addr
[NADDR
-j
];
printf("bn void %D\n",bn
);
* fetch through the indirect blocks
io
->i_bn
= fsbtodb(nb
) + io
->i_boff
;
printf("bn void %D\n",bn
);
register struct direct
*dp
;
register struct inode
*ip
;
if ((ip
->i_mode
&IFMT
)!=IFDIR
) {
printf("not a directory\n");
n
= ip
->i_size
/sizeof(struct direct
);
printf("zero length directory\n");
if (++dc
>= BSIZE
/sizeof(struct direct
)) {
io
->i_bn
= fsbtodb(sbmap(io
, bn
++)) + io
->i_boff
;
dp
= (struct direct
*)io
->i_buf
;
if (match(s
, dp
->d_name
))
printf("Seek not from beginning of file\n");
if (fdesc
< 0 || fdesc
>= NFILES
|| ((io
= &iob
[fdesc
])->i_flgs
&F_ALLOC
) == 0)
io
->i_bn
= fsbtodb(addr
/BSIZE
) + io
->i_boff
;
if (fdesc
>= 0 && fdesc
<= 2)
if (fdesc
< 0 || fdesc
>= NFILES
|| ((io
= &iob
[fdesc
])->i_flgs
&F_ALLOC
) == 0)
io
->i_bn
= fsbtodb(io
->i_offset
/(off_t
)BSIZE
);
io
->i_bn
= fsbtodb(sbmap(io
, dbtofsb(io
->i_bn
))) + io
->i_boff
;
off
= io
->i_offset
% (off_t
)BSIZE
;
if (io
->i_offset
+(BSIZE
-off
) >= io
->i_ino
.i_size
)
io
->i_cc
= io
->i_ino
.i_size
- io
->i_offset
+ off
;
for (i = 0, val = 0, cp = &val; i < sizeof(val); i++) {
register struct iob
*file
;
if (fdesc
>= 0 & fdesc
<= 2) {
} while (--i
&& *buf
++ != '\n');
if (fdesc
< 0 || fdesc
>= NFILES
|| ((file
= &iob
[fdesc
])->i_flgs
&F_ALLOC
) == 0)
if ((file
->i_flgs
&F_READ
) == 0)
if ((file
->i_flgs
&F_FILE
) == 0) {
if (file
->i_offset
+count
> file
->i_ino
.i_size
)
count
= file
->i_ino
.i_size
- file
->i_offset
;
register struct iob
*file
;
if (fdesc
>= 0 && fdesc
<= 2) {
if (fdesc
< 0 || fdesc
>= NFILES
|| ((file
= &iob
[fdesc
])->i_flgs
&F_ALLOC
) == 0)
if ((file
->i_flgs
&F_WRITE
) == 0)
register struct iob
*file
;
register struct devsw
*dp
;
for (i
= 0; i
< NFILES
; i
++)
for (fdesc
= 0; fdesc
< NFILES
; fdesc
++)
if (iob
[fdesc
].i_flgs
== 0)
_stop("No more file slots");
(file
= &iob
[fdesc
])->i_flgs
|= F_ALLOC
;
for (cp
= str
; *cp
&& *cp
!= '('; cp
++)
for (dp
= devsw
; dp
->dv_name
; dp
++) {
if (match(str
, dp
->dv_name
))
printf("Unknown device\n");
file
->i_ino
.i_dev
= dp
-devsw
;
file
->i_unit
= *cp
++ - '0';
if (*cp
>= '0' && *cp
<= '9')
file
->i_unit
= file
->i_unit
* 10 + *cp
++ - '0';
if (file
->i_unit
< 0 || file
->i_unit
> 31) {
printf("Bad unit specifier\n");
printf("Missing offset specification\n");
if ((i
= find(cp
, file
)) == 0) {
printf("Can't write files yet.. Sorry\n");
file
->i_flgs
|= F_FILE
| (how
+1);
if (fdesc
< 0 || fdesc
>= NFILES
|| ((file
= &iob
[fdesc
])->i_flgs
&F_ALLOC
) == 0)
if ((file
->i_flgs
&F_FILE
) == 0)
for (i
= 0; i
< NFILES
; i
++)