void kld_tag_getlog( void ) { struct kld_tag tg; char *start; tg.hdr.tag = KRTAG_GET_LOG; tg.hdr.size = sizeof( struct rktag_header ) + sizeof(struct krtag_get_log); kernel_getlog( &start, &tg.u.log.log[0].offset, &tg.u.log.log[0].total_len); kernel_getlog_start_length( &tg.u.log.log[0].offset, &tg.u.log.log[0].len); tg.u.log.log[0].ph_start = virt_to_phys( start ); android_main_getlog( &start, &tg.u.log.log[1].offset, &tg.u.log.log[1].total_len); android_main_getlog_start_length( &tg.u.log.log[1].offset, &tg.u.log.log[1].len); tg.u.log.log[1].ph_start = virt_to_phys( start ); tg.u.log.log[2].total_len = 0; kld_set_tag( &tg.hdr ); }
int rk28_write_file( char *filename ) { char *procmtd = "/proc/mtd"; struct file *filp = NULL; loff_t pos; long fd; ssize_t l=0; char pathname[64]; char buf[1024] ; mm_segment_t old_fs; struct rtc_time tm; ktime_t now; char *tmpbuf; int mtdidx=0; int mtdsize = 0x200000; // 2M char *log_buf; int log_len; debug_print("%s: filename=%s\n" , __func__ , filename ); old_fs = get_fs(); set_fs(KERNEL_DS); fd = sys_open( procmtd , O_RDONLY , 0 ); if( fd >= 0 ) { memset( buf , 0 , 1024 ); l = sys_read( fd , buf , 1024 ); // debug_print("/proc/mtd,total byte=%d\n" , l ); tmpbuf = strstr( buf , filename ); if( tmpbuf ) { tmpbuf[10] = 0; mtdsize = simple_strtoul(tmpbuf-19, NULL , 16); mtdidx = tmpbuf[-22]; //debug_print("size=%s\n,idx=%s\nmtdsize=%x , mtdidx=%d" , tmpbuf-19 , tmpbuf - 22 , // mtdsize , mtdidx ); mtdsize *= 512; mtdidx -= '0'; } sys_close( fd ); } else { debug_print("open %s failed\n" , procmtd ); } sprintf(pathname , "/dev/block/mtdblock%d" , mtdidx ); filp = filp_open(pathname, O_WRONLY , 0); if( IS_ERR(filp) ) { debug_print("open %s failed n" , pathname ); goto out_print; } if (!(filp->f_op->write || filp->f_op->aio_write)) { debug_print("can not write file %s \n" , pathname ); goto close_file; } now = ktime_get(); rtc_time_to_tm( now.tv.sec , &tm ); printk( "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" "++++++++++RECORD LOG AT %04d-%02d-%02d %02d:%02d:%02d++++++++++\n" "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n\n\n" , tm.tm_year+1900 , tm.tm_mon , tm.tm_mday , tm.tm_hour , tm.tm_min , tm.tm_sec ); /* 20090924,HSL,FTL only intial first 256M at loader , MUST write 32 sector one time */ //debug_print("write first pack , pos=%d\n" , pos ); /* pos = 2 ?? */ kernel_getlog(&log_buf , NULL , &log_len ); log_len = (log_len+(32*512-1)) / (32*512) * (32*512); pos = 0; l = vfs_write( filp , log_buf , log_len , &pos ); do_fsync(filp, 1); close_file: filp_close(filp , NULL); out_print: set_fs(old_fs); debug_print("\nlog len=%d,write=%d\n" ,log_len , l); return 0x2b; }