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

1.1     ! root        1: #include <linux/sched.h>
        !             2: 
        !             3: #include <sys/stat.h>
        !             4: 
        !             5: static void free_ind(int dev,int block)
        !             6: {
        !             7:        struct buffer_head * bh;
        !             8:        unsigned short * p;
        !             9:        int i;
        !            10: 
        !            11:        if (!block)
        !            12:                return;
        !            13:        if (bh=bread(dev,block)) {
        !            14:                p = (unsigned short *) bh->b_data;
        !            15:                for (i=0;i<512;i++,p++)
        !            16:                        if (*p)
        !            17:                                free_block(dev,*p);
        !            18:                brelse(bh);
        !            19:        }
        !            20:        free_block(dev,block);
        !            21: }
        !            22: 
        !            23: static void free_dind(int dev,int block)
        !            24: {
        !            25:        struct buffer_head * bh;
        !            26:        unsigned short * p;
        !            27:        int i;
        !            28: 
        !            29:        if (!block)
        !            30:                return;
        !            31:        if (bh=bread(dev,block)) {
        !            32:                p = (unsigned short *) bh->b_data;
        !            33:                for (i=0;i<512;i++,p++)
        !            34:                        if (*p)
        !            35:                                free_ind(dev,*p);
        !            36:                brelse(bh);
        !            37:        }
        !            38:        free_block(dev,block);
        !            39: }
        !            40: 
        !            41: void truncate(struct m_inode * inode)
        !            42: {
        !            43:        int i;
        !            44: 
        !            45:        if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)))
        !            46:                return;
        !            47:        for (i=0;i<7;i++)
        !            48:                if (inode->i_zone[i]) {
        !            49:                        free_block(inode->i_dev,inode->i_zone[i]);
        !            50:                        inode->i_zone[i]=0;
        !            51:                }
        !            52:        free_ind(inode->i_dev,inode->i_zone[7]);
        !            53:        free_dind(inode->i_dev,inode->i_zone[8]);
        !            54:        inode->i_zone[7] = inode->i_zone[8] = 0;
        !            55:        inode->i_size = 0;
        !            56:        inode->i_dirt = 1;
        !            57:        inode->i_mtime = inode->i_ctime = CURRENT_TIME;
        !            58: }
        !            59: 

unix.superglobalmegacorp.com

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