Annotation of linux/fs/super.c, revision 1.1.1.2

1.1       root        1: /*
                      2:  * super.c contains code to handle the super-block tables.
                      3:  */
                      4: #include <linux/config.h>
                      5: #include <linux/sched.h>
                      6: #include <linux/kernel.h>
                      7: 
                      8: /* set_bit uses setb, as gas doesn't recognize setc */
                      9: #define set_bit(bitnr,addr) ({ \
1.1.1.2 ! root       10: register int __res;/* __asm__("ax");*/ \
1.1       root       11: __asm__("bt %2,%3;setb %%al":"=a" (__res):"a" (0),"r" (bitnr),"m" (*(addr))); \
                     12: __res; })
                     13: 
                     14: struct super_block super_block[NR_SUPER];
                     15: 
                     16: struct super_block * do_mount(int dev)
                     17: {
                     18:        struct super_block * p;
                     19:        struct buffer_head * bh;
                     20:        int i,block;
                     21: 
                     22:        for(p = &super_block[0] ; p < &super_block[NR_SUPER] ; p++ )
                     23:                if (!(p->s_dev))
                     24:                        break;
                     25:        p->s_dev = -1;          /* mark it in use */
                     26:        if (p >= &super_block[NR_SUPER])
                     27:                return NULL;
                     28:        if (!(bh = bread(dev,1)))
                     29:                return NULL;
                     30:        *p = *((struct super_block *) bh->b_data);
                     31:        brelse(bh);
                     32:        if (p->s_magic != SUPER_MAGIC) {
                     33:                p->s_dev = 0;
                     34:                return NULL;
                     35:        }
                     36:        for (i=0;i<I_MAP_SLOTS;i++)
                     37:                p->s_imap[i] = NULL;
                     38:        for (i=0;i<Z_MAP_SLOTS;i++)
                     39:                p->s_zmap[i] = NULL;
                     40:        block=2;
                     41:        for (i=0 ; i < p->s_imap_blocks ; i++)
1.1.1.2 ! root       42:                if ((p->s_imap[i]=bread(dev,block)))
1.1       root       43:                        block++;
                     44:                else
                     45:                        break;
                     46:        for (i=0 ; i < p->s_zmap_blocks ; i++)
1.1.1.2 ! root       47:                if ((p->s_zmap[i]=bread(dev,block)))
1.1       root       48:                        block++;
                     49:                else
                     50:                        break;
                     51:        if (block != 2+p->s_imap_blocks+p->s_zmap_blocks) {
                     52:                for(i=0;i<I_MAP_SLOTS;i++)
                     53:                        brelse(p->s_imap[i]);
                     54:                for(i=0;i<Z_MAP_SLOTS;i++)
                     55:                        brelse(p->s_zmap[i]);
                     56:                p->s_dev=0;
                     57:                return NULL;
                     58:        }
                     59:        p->s_imap[0]->b_data[0] |= 1;
                     60:        p->s_zmap[0]->b_data[0] |= 1;
                     61:        p->s_dev = dev;
                     62:        p->s_isup = NULL;
                     63:        p->s_imount = NULL;
                     64:        p->s_time = 0;
                     65:        p->s_rd_only = 0;
                     66:        p->s_dirt = 0;
                     67:        return p;
                     68: }
                     69: 
                     70: void mount_root(void)
                     71: {
                     72:        int i,free;
                     73:        struct super_block * p;
                     74:        struct m_inode * mi;
                     75: 
                     76:        if (32 != sizeof (struct d_inode))
                     77:                panic("bad i-node size");
                     78:        for(i=0;i<NR_FILE;i++)
                     79:                file_table[i].f_count=0;
                     80:        for(p = &super_block[0] ; p < &super_block[NR_SUPER] ; p++)
                     81:                p->s_dev = 0;
                     82:        if (!(p=do_mount(ROOT_DEV)))
                     83:                panic("Unable to mount root");
                     84:        if (!(mi=iget(ROOT_DEV,1)))
                     85:                panic("Unable to read root i-node");
                     86:        mi->i_count += 3 ;      /* NOTE! it is logically used 4 times, not 1 */
                     87:        p->s_isup = p->s_imount = mi;
                     88:        current->pwd = mi;
                     89:        current->root = mi;
                     90:        free=0;
                     91:        i=p->s_nzones;
                     92:        while (-- i >= 0)
                     93:                if (!set_bit(i&8191,p->s_zmap[i>>13]->b_data))
                     94:                        free++;
                     95:        printk("%d/%d free blocks\n\r",free,p->s_nzones);
                     96:        free=0;
                     97:        i=p->s_ninodes+1;
                     98:        while (-- i >= 0)
                     99:                if (!set_bit(i&8191,p->s_imap[i>>13]->b_data))
                    100:                        free++;
                    101:        printk("%d/%d free inodes\n\r",free,p->s_ninodes);
                    102: }

unix.superglobalmegacorp.com

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