linux-lts-quantal-3.5.0/kernel/replay.c
/* Write out the list of memory regions used in this record group */
Write out the list of memory regions used in this record group
Write out the list of memory regions used in this record group
void write_mmap_log (struct record_group* prg)
{
	char filename[MAX_LOGDIR_STRLEN+20];
	int fd = 0;
	loff_t pos = 0;
	struct file* file = NULL;
	mm_segment_t old_fs;
	int copyed;
	ds_list_t* memory_list;
	ds_list_iter_t* iter;
	struct reserved_mapping* pmapping;
	MPRINT ("Pid %d write_mmap_log start\n", current->pid);
	if (!prg->rg_save_mmap_flag) return;
	sprintf (filename, "%s/mlog", prg->rg_logdir);
	old_fs = get_fs();
	set_fs(KERNEL_DS);
	fd = sys_open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644);
	if (fd < 0) {
		printk("Pid %d write_mmap_log: could not open file %s, %d\n", current->pid, filename, fd);
		return;
	}
	file = fget(fd);
	if (!file) {
		printk("Pid %d write_mmap_log, could not open file %s\n", current->pid, filename);
		return;
	}
	memory_list = prg->rg_reserved_mem_list;
	iter = ds_list_iter_create (memory_list);
	while ((pmapping = ds_list_iter_next (iter)) != NULL) {
		DPRINT ("Pid %d writing allocation [%lx, %lx)\n",
				current->pid, pmapping->m_begin, pmapping->m_end);
		copyed = vfs_write(file, (char *) pmapping, sizeof(struct reserved_mapping), &pos);
		if (copyed != sizeof(struct reserved_mapping)) {
			printk("[WARN] Pid %d write reserved_mapping, expected to write %d got %d\n", current->pid, sizeof(struct reserved_mapping), copyed);
		}
	}
	ds_list_iter_destroy (iter);
	term_log_write(file, fd);
	set_fs(old_fs);
	MPRINT ("Pid %d write mmap log done\n", current->pid);
}
void write_mmap_log ( struct record_group * prg ) { char filename [ MAX_LOGDIR_STRLEN + 20 ] ; int fd = 0 ; loff_t pos = 0 ; struct file * file = NULL ; mm_segment_t old_fs ; int copyed ; ds_list_t * memory_list ; ds_list_iter_t * iter ; struct reserved_mapping * pmapping ; MPRINT ( " \n " , current -> pid ) ; if ( ! prg -> rg_save_mmap_flag ) return ; sprintf ( filename , " " , prg -> rg_logdir ) ; old_fs = get_fs ( ) ; set_fs ( KERNEL_DS ) ; fd = sys_open ( filename , O_WRONLY | O_CREAT | O_TRUNC , 0644 ) ; if ( fd < 0 ) { printk ( " \n " , current -> pid , filename , fd ) ; return ; } file = fget ( fd ) ; if ( ! file ) { printk ( " \n " , current -> pid , filename ) ; return ; } memory_list = prg -> rg_reserved_mem_list ; iter = ds_list_iter_create ( memory_list ) ; while ( ( pmapping = ds_list_iter_next ( iter ) ) != NULL ) { DPRINT ( " \n " , current -> pid , pmapping -> m_begin , pmapping -> m_end ) ; copyed = vfs_write ( file , ( char * ) pmapping , sizeof ( struct reserved_mapping ) , & pos ) ; if ( copyed != sizeof ( struct reserved_mapping ) ) { printk ( " \n " , current -> pid , sizeof ( struct reserved_mapping ) , copyed ) ; } } ds_list_iter_destroy ( iter ) ; term_log_write ( file , fd ) ; set_fs ( old_fs ) ; MPRINT ( " \n " , current -> pid ) ; }
Write out the list of memory regions used in this record group
Write out the list of memory regions used in this record group
// one mlog per record group