Exemplo n.º 1
0
/**
 *  initialize the dot(.) and dotdot(..) dir entries for new directory
 * @param inode                inode for itself
 * @return             return 0 on success, EIO on failure
 *
 * inode must have start cluster of itself and start cluster of parent dir
 */
int init_new_dir(struct inode *inode)
{
       struct buffer_head *bh = NULL;
               struct rfs_dir_entry *dot_ep = NULL;
               struct rfs_dir_entry *dotdot_ep = NULL;
       unsigned char dummy = 0;
       int err = 0;

       /* initialize .(itself) and ..(parent) */
       dot_ep = get_entry(inode, 0, &bh);
       if (IS_ERR(dot_ep)) {
               brelse(bh);
               return -EIO;
       }

       dotdot_ep = (struct rfs_dir_entry *) (bh->b_data + DENTRY_SIZE);

       init_dir_entry(inode, dot_ep, TYPE_DIR, 
                       RFS_I(inode)->start_clu, DOT, &dummy);
       init_dir_entry(inode, dotdot_ep, TYPE_DIR, 
                       RFS_I(inode)->p_start_clu, DOTDOT, &dummy);

       rfs_mark_buffer_dirty(bh, inode->i_sb);
       brelse(bh);

       return err;
}
Exemplo n.º 2
0
/**
 *  block commit write 
 * @param inode        inode    
 * @param page page pointer
 * @param from start offset within page        
 * @param to   last offset within page  
 * @return     return 0 on success, errno on failure
 */
int rfs_block_commit_write(struct inode *inode, struct page *page,
               unsigned from, unsigned to)
{
       unsigned block_start, block_end;
       unsigned blocksize;
       struct buffer_head *bh, *head;

       blocksize = 1 << inode->i_blkbits;

       for(bh = head = page->buffers, block_start = 0;
           bh != head || !block_start;
           block_start=block_end + 1, bh = bh->b_this_page) {
               block_end = block_start + blocksize - 1;
               if (block_end < from)
                       continue;
               else if (block_start > to) 
                       break;
               else {
                       set_bit(BH_Uptodate, &bh->b_state);
                       __mark_buffer_dirty(bh);
                       down(&RFS_I(inode)->data_mutex);
                       buffer_insert_inode_data_queue(bh, inode);
                       up(&RFS_I(inode)->data_mutex);
               }
       }

       return 0;
}