Annotation of linux/fs/block_dev.c, revision 1.1.1.4

1.1.1.2   root        1: /*
                      2:  *  linux/fs/block_dev.c
                      3:  *
                      4:  *  (C) 1991  Linus Torvalds
                      5:  */
                      6: 
1.1       root        7: #include <errno.h>
                      8: 
1.1.1.2   root        9: #include <linux/sched.h>
1.1       root       10: #include <linux/kernel.h>
                     11: #include <asm/segment.h>
1.1.1.2   root       12: #include <asm/system.h>
1.1       root       13: 
1.1.1.3   root       14: extern int *blk_size[];
                     15: 
1.1.1.4 ! root       16: int block_write(struct inode * inode, struct file * filp, char * buf, int count)
1.1       root       17: {
1.1.1.4 ! root       18:        int block = filp->f_pos >> BLOCK_SIZE_BITS;
        !            19:        int offset = filp->f_pos & (BLOCK_SIZE-1);
1.1       root       20:        int chars;
                     21:        int written = 0;
1.1.1.3   root       22:        int size;
1.1.1.4 ! root       23:        unsigned int dev;
1.1       root       24:        struct buffer_head * bh;
                     25:        register char * p;
                     26: 
1.1.1.4 ! root       27:        dev = inode->i_rdev;
1.1.1.3   root       28:        if (blk_size[MAJOR(dev)])
                     29:                size = blk_size[MAJOR(dev)][MINOR(dev)];
                     30:        else
                     31:                size = 0x7fffffff;
1.1       root       32:        while (count>0) {
1.1.1.3   root       33:                if (block >= size)
1.1.1.4 ! root       34:                        return written;
1.1.1.2   root       35:                chars = BLOCK_SIZE - offset;
                     36:                if (chars > count)
                     37:                        chars=count;
                     38:                if (chars == BLOCK_SIZE)
                     39:                        bh = getblk(dev,block);
                     40:                else
                     41:                        bh = breada(dev,block,block+1,block+2,-1);
                     42:                block++;
1.1       root       43:                if (!bh)
                     44:                        return written?written:-EIO;
                     45:                p = offset + bh->b_data;
                     46:                offset = 0;
1.1.1.4 ! root       47:                filp->f_pos += chars;
1.1       root       48:                written += chars;
                     49:                count -= chars;
                     50:                while (chars-->0)
                     51:                        *(p++) = get_fs_byte(buf++);
                     52:                bh->b_dirt = 1;
                     53:                brelse(bh);
                     54:        }
                     55:        return written;
                     56: }
                     57: 
1.1.1.4 ! root       58: int block_read(struct inode * inode, struct file * filp, char * buf, int count)
1.1       root       59: {
1.1.1.4 ! root       60:        unsigned int block = filp->f_pos >> BLOCK_SIZE_BITS;
        !            61:        unsigned int offset = filp->f_pos & (BLOCK_SIZE-1);
        !            62:        unsigned int chars;
        !            63:        unsigned int size;
        !            64:        unsigned int dev;
1.1       root       65:        int read = 0;
                     66:        struct buffer_head * bh;
                     67:        register char * p;
                     68: 
1.1.1.4 ! root       69:        dev = inode->i_rdev;
1.1.1.3   root       70:        if (blk_size[MAJOR(dev)])
                     71:                size = blk_size[MAJOR(dev)][MINOR(dev)];
                     72:        else
                     73:                size = 0x7fffffff;
1.1       root       74:        while (count>0) {
1.1.1.3   root       75:                if (block >= size)
1.1.1.4 ! root       76:                        return read;
1.1.1.2   root       77:                chars = BLOCK_SIZE-offset;
                     78:                if (chars > count)
                     79:                        chars = count;
                     80:                if (!(bh = breada(dev,block,block+1,block+2,-1)))
1.1       root       81:                        return read?read:-EIO;
1.1.1.2   root       82:                block++;
1.1       root       83:                p = offset + bh->b_data;
                     84:                offset = 0;
1.1.1.4 ! root       85:                filp->f_pos += chars;
1.1       root       86:                read += chars;
                     87:                count -= chars;
                     88:                while (chars-->0)
                     89:                        put_fs_byte(*(p++),buf++);
                     90:                brelse(bh);
                     91:        }
                     92:        return read;
                     93: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.