/*===========================================================================* * fs_statvfs * *===========================================================================*/ int fs_statvfs() { struct statvfs st; struct super_block *sp; int r, scale; u32_t used; sp = get_super(fs_dev); scale = sp->s_log_zone_size; blockstats((u32_t *) &st.f_blocks, (u32_t *) &st.f_bfree, &used); st.f_bavail = st.f_bfree; st.f_bsize = sp->s_block_size << scale; st.f_frsize = sp->s_block_size; st.f_files = sp->s_ninodes; st.f_ffree = count_free_bits(sp, IMAP); st.f_favail = st.f_ffree; st.f_fsid = fs_dev; st.f_flag = (sp->s_rd_only == 1 ? ST_RDONLY : 0); st.f_namemax = MFS_DIRSIZ; /* Copy the struct to user space. */ r = sys_safecopyto(fs_m_in.m_source, fs_m_in.REQ_GRANT, 0, (vir_bytes) &st, (phys_bytes) sizeof(st)); return(r); }
//Checks if number must be resized at the end with high bytes and performs it. void BitShiftsAlgorithms::expand_number_at_highest_bytes_end( BigNumber& shifted_number, const BigNumberIterator& highest_byte, uint8_t shift_value) { //Free bits in highest block int32_t free_bits = (*highest_byte.get_block_iterator()).trailing_zeros * BITS_PER_ELEMENT; //Free bits in element with highest byte free_bits += count_free_bits(*highest_byte); //Decrease by a growth of the number caused by shift. free_bits -= shift_value; //Reserve elements near high bytes end if required. if(free_bits < 0 ) { shifted_number.reserve_space_for_elements_back(ceil(-free_bits / (double)BITS_PER_ELEMENT)); } }
void BitShiftsAlgorithms::shift_left_number( BigNumber& shifted_number, BigNumberIterator highest_byte, BigNumberIterator lowest_byte, uint8_t shift_value) { if(shift_value == 0) { return; } if(highest_byte == lowest_byte) { *highest_byte <<= shift_value; return; } BigNumberIterator current = highest_byte, previous = highest_byte, destination = highest_byte; --previous; if(shift_value > count_free_bits(*highest_byte)) { ++current; ++previous; ++destination; } Block* last_updated_block = NULL; do { *destination = bitwise_shift(*current, *previous, shift_value, Left); if(*destination != 0 && (last_updated_block != &*destination.get_block_iterator())) { last_updated_block = &*destination.get_block_iterator(); last_updated_block->trailing_zeros = last_updated_block->get_size() - destination.get_offset() - 1; } --destination; --current; --previous; } while(current != lowest_byte); *destination = bitwise_shift(*current, 0, shift_value, Left); }
/*===========================================================================* * fs_statvfs * *===========================================================================*/ int fs_statvfs(struct statvfs *st) { struct super_block *sp; int scale; u64_t used; sp = get_super(fs_dev); scale = sp->s_log_zone_size; fs_blockstats(&st->f_blocks, &st->f_bfree, &used); st->f_bavail = st->f_bfree; st->f_bsize = sp->s_block_size << scale; st->f_frsize = sp->s_block_size; st->f_iosize = st->f_frsize; st->f_files = sp->s_ninodes; st->f_ffree = count_free_bits(sp, IMAP); st->f_favail = st->f_ffree; st->f_namemax = MFS_DIRSIZ; return(OK); }
/*===========================================================================* * fs_statvfs * *===========================================================================*/ int fs_statvfs(struct statvfs *st) { struct super_block *sp; int scale; sp = &superblock; scale = sp->s_log_zone_size; st->f_blocks = sp->s_zones; st->f_bfree = sp->s_zones - used_zones; st->f_bavail = st->f_bfree; st->f_bsize = sp->s_block_size << scale; st->f_frsize = sp->s_block_size; st->f_iosize = st->f_frsize; st->f_files = sp->s_ninodes; st->f_ffree = count_free_bits(sp, IMAP); st->f_favail = st->f_ffree; st->f_namemax = MFS_DIRSIZ; return(OK); }