void * get_rootdirfile_blk(device_t * devp) { void * retptr = NULL; rfsdir_t * rtdir = get_rootdir(devp); if(!rtdir) { printfk("get_rootdir failed\n\r"); return NULL; } void * buf = new_buf(FSYS_ALCBLKSZ); if(!buf) { printfk("new_buf failed\n\r"); retptr = NULL; goto err2; } hal_memset(buf, FSYS_ALCBLKSZ, 0); if(read_rfsdevblk(devp, buf, rtdir->rdr_blknr) == DFCERRSTUS) { printfk("read_rfsdevblk failed\n\r"); retptr = NULL; goto err1; } retptr = buf; goto err2; err1: del_buf(buf, FSYS_ALCBLKSZ); err2: del_rootdir(devp, rtdir); return retptr; }
void test_dir(device_t * devp) { rfsdir_t * dr = get_rootdir(devp); void * buf = new_buf(FSYS_ALCBLKSZ); if(buf == NULL) { hal_sysdie("testdir1 err\n\r"); } hal_memset(buf, FSYS_ALCBLKSZ, 0); if(read_rfsdevblk(devp, buf, dr->rdr_blknr) == DFCERRSTUS) { hal_sysdie("testdir1 err\n\r"); } fimgrhd_t * fmp = (fimgrhd_t *)buf; printfk("fmp->fmd_type : %x fmd_filesz : %x fmd_fileifstbkoff : %x fmd_fileiendbkoff : %x\n\r", fmp->fmd_type, fmp->fmd_filesz, fmp->fmd_fileifstbkoff, fmp->fmd_fileiendbkoff); printfk("fmd_fleblk : %x : %x\n\r", fmp->fmd_fleblk[0].fb_blkstart, fmp->fmd_fleblk[0].fb_blknr); del_buf(buf, FSYS_ALCBLKSZ); del_rootdir(devp, dr); return; }
/* * Function: _setup_install_log * Description: Copy the install_log file from /tmp to the target * filesystem and add a timestamp to the name. * Set up a symlink to this new file from either * install_log or upgrade_log in hte same directory. * If the log is open for writing, close & reopen * at the new location. * This function was moved here from libspmisvc so * it could use some knowledge about the log file. * * Until after 2.6, set up a symbolic link from * var/sadm/install_data for backwards compatibility * as stated in PSARC/1994/331. * Scope: publice * Parameters: none * Return: Pointer to new logfile on success * NULL on failure */ char * _setup_install_log(void) { int reopen = 0; char *dated_path, *new_logpath; char *old_logpath = "/var/sadm/install_data/upgrade_log"; FILE *tmpf; static char new_path[MAXPATHLEN] = ""; if (get_install_type() == CMNUpgrade) { (void) sprintf(new_path, "%s%s/upgrade_log", get_rootdir(), "/var/sadm/system/logs"); new_logpath = new_path + strlen(get_rootdir()); /* * If there is a symbolic link in the old location, * remove it. If there is a file, not a sym link, * move it to the new location in the dated form. * Remove ths after 2.6 */ (void) rm_link_mv_file(old_logpath, new_logpath); /* * Remove an existing symlink, or rename the log file * to a dated form. */ (void) rm_link_mv_file(new_logpath, new_logpath); /* * Create a new dated log file & symlink */ if ((tmpf = fopen(new_path, "w")) == NULL) { return (NULL); } (void) fclose(tmpf); if ((dated_path = (char *)rm_link_mv_file(new_logpath, new_logpath)) == NULL) { return (NULL); } (void) chmod(dated_path, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); (void) symlink(basename(dated_path), new_path); /* * Remove this after 2.6 */ { char tmppath[MAXPATHLEN]; (void) sprintf(tmppath, "%s/%s", get_rootdir(), old_logpath); (void) symlink("../system/logs/upgrade_log", tmppath); } } else { /* * Initial install */ (void) sprintf(new_path, "%s%s/install_log", get_rootdir(), "/var/sadm/system/logs"); new_logpath = new_path + strlen(get_rootdir()); /* * Remove this after 2.6 */ { char tmppath[MAXPATHLEN]; (void) sprintf(tmppath, "%s/var/sadm/install_data/install_log", get_rootdir()); (void) symlink("../system/logs/install_log", tmppath); } } /* * If we've started writing a log file, copy it to the * permanent location. */ if (access(TMPLOGFILE, F_OK) == 0) { if (_log_file != NULL) { reopen = 1; (void) fclose(_log_file); _log_file = NULL; } if (_copy_file(new_path, TMPLOGFILE) == ERROR) { return (NULL); } if (reopen != 0) { if ((_log_file = fopen(new_path, "a")) == NULL) { /* * Punt */ return (NULL); } } } return (new_path); }