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

1.1     ! root        1: #include <errno.h>
        !             2: 
        !             3: #include <linux/fs.h>
        !             4: #include <linux/kernel.h>
        !             5: #include <asm/segment.h>
        !             6: 
        !             7: #define NR_BLK_DEV ((sizeof (rd_blk))/(sizeof (rd_blk[0])))
        !             8: 
        !             9: int block_write(int dev, long * pos, char * buf, int count)
        !            10: {
        !            11:        int block = *pos / BLOCK_SIZE;
        !            12:        int offset = *pos % BLOCK_SIZE;
        !            13:        int chars;
        !            14:        int written = 0;
        !            15:        struct buffer_head * bh;
        !            16:        register char * p;
        !            17: 
        !            18:        while (count>0) {
        !            19:                bh = bread(dev,block);
        !            20:                if (!bh)
        !            21:                        return written?written:-EIO;
        !            22:                chars = (count<BLOCK_SIZE) ? count : BLOCK_SIZE;
        !            23:                p = offset + bh->b_data;
        !            24:                offset = 0;
        !            25:                block++;
        !            26:                *pos += chars;
        !            27:                written += chars;
        !            28:                count -= chars;
        !            29:                while (chars-->0)
        !            30:                        *(p++) = get_fs_byte(buf++);
        !            31:                bh->b_dirt = 1;
        !            32:                brelse(bh);
        !            33:        }
        !            34:        return written;
        !            35: }
        !            36: 
        !            37: int block_read(int dev, unsigned long * pos, char * buf, int count)
        !            38: {
        !            39:        int block = *pos / BLOCK_SIZE;
        !            40:        int offset = *pos % BLOCK_SIZE;
        !            41:        int chars;
        !            42:        int read = 0;
        !            43:        struct buffer_head * bh;
        !            44:        register char * p;
        !            45: 
        !            46:        while (count>0) {
        !            47:                bh = bread(dev,block);
        !            48:                if (!bh)
        !            49:                        return read?read:-EIO;
        !            50:                chars = (count<BLOCK_SIZE) ? count : BLOCK_SIZE;
        !            51:                p = offset + bh->b_data;
        !            52:                offset = 0;
        !            53:                block++;
        !            54:                *pos += chars;
        !            55:                read += chars;
        !            56:                count -= chars;
        !            57:                while (chars-->0)
        !            58:                        put_fs_byte(*(p++),buf++);
        !            59:                bh->b_dirt = 1;
        !            60:                brelse(bh);
        !            61:        }
        !            62:        return read;
        !            63: }
        !            64: 
        !            65: extern void rw_hd(int rw, struct buffer_head * bh);
        !            66: 
        !            67: typedef void (*blk_fn)(int rw, struct buffer_head * bh);
        !            68: 
        !            69: static blk_fn rd_blk[]={
        !            70:        NULL,           /* nodev */
        !            71:        NULL,           /* dev mem */
        !            72:        NULL,           /* dev fd */
        !            73:        rw_hd,          /* dev hd */
        !            74:        NULL,           /* dev ttyx */
        !            75:        NULL,           /* dev tty */
        !            76:        NULL};          /* dev lp */
        !            77: 
        !            78: void ll_rw_block(int rw, struct buffer_head * bh)
        !            79: {
        !            80:        blk_fn blk_addr;
        !            81:        unsigned int major;
        !            82: 
        !            83:        if ((major=MAJOR(bh->b_dev)) >= NR_BLK_DEV || !(blk_addr=rd_blk[major]))
        !            84:                panic("Trying to read nonexistent block-device");
        !            85:        blk_addr(rw, bh);
        !            86: }

unix.superglobalmegacorp.com

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