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

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;
1.1.1.5 ! root       50:                memcpy_fromfs(p,buf,chars);
        !            51:                p += chars;
        !            52:                buf += chars;
1.1       root       53:                bh->b_dirt = 1;
                     54:                brelse(bh);
                     55:        }
                     56:        return written;
                     57: }
                     58: 
1.1.1.4   root       59: int block_read(struct inode * inode, struct file * filp, char * buf, int count)
1.1       root       60: {
1.1.1.4   root       61:        unsigned int block = filp->f_pos >> BLOCK_SIZE_BITS;
                     62:        unsigned int offset = filp->f_pos & (BLOCK_SIZE-1);
                     63:        unsigned int chars;
                     64:        unsigned int size;
                     65:        unsigned int dev;
1.1       root       66:        int read = 0;
                     67:        struct buffer_head * bh;
                     68:        register char * p;
                     69: 
1.1.1.4   root       70:        dev = inode->i_rdev;
1.1.1.3   root       71:        if (blk_size[MAJOR(dev)])
                     72:                size = blk_size[MAJOR(dev)][MINOR(dev)];
                     73:        else
                     74:                size = 0x7fffffff;
1.1       root       75:        while (count>0) {
1.1.1.3   root       76:                if (block >= size)
1.1.1.4   root       77:                        return read;
1.1.1.2   root       78:                chars = BLOCK_SIZE-offset;
                     79:                if (chars > count)
                     80:                        chars = count;
                     81:                if (!(bh = breada(dev,block,block+1,block+2,-1)))
1.1       root       82:                        return read?read:-EIO;
1.1.1.2   root       83:                block++;
1.1       root       84:                p = offset + bh->b_data;
                     85:                offset = 0;
1.1.1.4   root       86:                filp->f_pos += chars;
1.1       root       87:                read += chars;
                     88:                count -= chars;
1.1.1.5 ! root       89:                memcpy_tofs(buf,p,chars);
        !            90:                p += chars;
        !            91:                buf += chars;
1.1       root       92:                brelse(bh);
                     93:        }
                     94:        return read;
                     95: }

unix.superglobalmegacorp.com

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