static int __init chp_init(void) { struct chp_id chpid; int ret; ret = crw_register_handler(CRW_RSC_CPATH, chp_process_crw); if (ret) return ret; chp_wq = create_singlethread_workqueue("cio_chp"); if (!chp_wq) { crw_unregister_handler(CRW_RSC_CPATH); return -ENOMEM; } INIT_WORK(&cfg_work, cfg_func); init_waitqueue_head(&cfg_wait_queue); if (info_update()) return 0; /* Register available channel-paths. */ chp_id_for_each(&chpid) { if (chp_info_get_status(chpid) != CHP_STATUS_NOT_RECOGNIZED) chp_new(chpid); } return 0; }
bool Application::updating() { #ifdef _WIN32 CHandle mutex(::CreateSemaphore(NULL, 0, 1, updater_singlton_mutex_name.c_str())); if (ERROR_ALREADY_EXISTS == ::GetLastError()) return true; CRegKey key_software; if (ERROR_SUCCESS != key_software.Open(HKEY_CURRENT_USER, L"Software")) return false; CRegKey key_product; if (ERROR_SUCCESS != key_product.Create(key_software, (const wchar_t*) product_name.utf16())) return false; wchar_t version_buffer[1025]; unsigned long len = 1024; if (ERROR_SUCCESS != key_product.QueryStringValue(L"update_version", version_buffer, &len)) return false; QString version_update = QString::fromUtf16((const ushort*) version_buffer); core::tools::version_info info_current; core::tools::version_info info_update(version_update.toStdString()); if (info_current < info_update) { wchar_t this_module_name[1024]; if (!::GetModuleFileName(0, this_module_name, 1024)) return false; QDir dir = QFileInfo(QString::fromUtf16((const ushort*) this_module_name)).absoluteDir(); if (!dir.cdUp()) return false; QString update_folder = dir.absolutePath() + "/" + updates_folder_short + "/" + version_update; QDir update_dir(update_folder); if (update_dir.exists()) { QString setup_name = update_folder + "/" + installer_exe_name; QFileInfo setup_info(setup_name); if (!setup_info.exists()) return false; mutex.Close(); const auto command = QString("\"") + QDir::toNativeSeparators(setup_name) + "\"" + " " + update_final_command; QProcess::startDetached(command); return true; } } #endif //_WIN32 return false; }
/* Selection Callbacks */ void info_display_playlist_selected_cb(GtkPodApp *app, gpointer pl, gpointer data) { Playlist *playlist = pl; if (playlist && playlist->itdb) { space_set_ipod_itdb(playlist->itdb); } else { space_set_ipod_itdb(NULL); } info_update(); }
int main(int argc, char *argv[]){ //[0]./disklist [1]test.img [2]foo.txt [3]/sub_dir/foo2.txt int fd; char *p; FILE *disk; struct stat sf; char c; if(argc!=4){ printf("Usg: ./diskget test.img source.* /sub_dir/destination.*\n"); return 0; } //printf("%s\n", file_name); if ((fd=open(argv[1], O_RDONLY))) { fstat(fd, &sf); p = mmap(NULL,sf.st_size, PROT_READ, MAP_SHARED, fd, 0); disk = fopen(argv[1],"r+"); pointer = p; FDT_start = getSuperBlockinfo(p,22, 4); FDT_block =getSuperBlockinfo(p,26, 4); FAT_start = getSuperBlockinfo(p,14, 4); size = getSuperBlockinfo(p,8, 2); c = *argv[3]; if(c == '/'){ find_directory(p, disk, argv[3], argv[2]); }else{ disk_put(disk, argv[2]); info_update(disk, argv[3], 0x03, 0); } printf("\nSuccessfully copy the file to disk image.\n"); } else printf("Fail to open the image file.\n"); close(fd); return 0; }
/* Perform one configure/deconfigure request. Reschedule work function until * last request. */ static void cfg_func(struct work_struct *work) { struct chp_id chpid; enum cfg_task_t t; int rc; mutex_lock(&cfg_lock); t = cfg_none; chp_id_for_each(&chpid) { t = cfg_get_task(chpid); if (t != cfg_none) { cfg_set_task(chpid, cfg_none); break; } } mutex_unlock(&cfg_lock); switch (t) { case cfg_configure: rc = sclp_chp_configure(chpid); if (rc) CIO_MSG_EVENT(2, "chp: sclp_chp_configure(%x.%02x)=" "%d\n", chpid.cssid, chpid.id, rc); else { info_expire(); chsc_chp_online(chpid); } break; case cfg_deconfigure: rc = sclp_chp_deconfigure(chpid); if (rc) CIO_MSG_EVENT(2, "chp: sclp_chp_deconfigure(%x.%02x)=" "%d\n", chpid.cssid, chpid.id, rc); else { info_expire(); chsc_chp_offline(chpid); } break; case cfg_none: /* Get updated information after last change. */ info_update(); mutex_lock(&cfg_lock); cfg_busy = 0; mutex_unlock(&cfg_lock); wake_up_interruptible(&cfg_wait_queue); return; } queue_work(chp_wq, &cfg_work); }
static int __init chp_init(void) { struct chp_id chpid; chp_wq = create_singlethread_workqueue("cio_chp"); if (!chp_wq) return -ENOMEM; INIT_WORK(&cfg_work, cfg_func, NULL); init_waitqueue_head(&cfg_wait_queue); if (info_update()) return 0; /* Register available channel-paths. */ chp_id_for_each(&chpid) { if (chp_info_get_status(chpid) != CHP_STATUS_NOT_RECOGNIZED) chp_new(chpid); } return 0; }
/* Perform one configure/deconfigure request. Reschedule work function until * last request. */ static void cfg_func(void *data) { struct chp_id chpid; enum cfg_task_t t; mutex_lock(&cfg_lock); t = cfg_none; chp_id_for_each(&chpid) { t = cfg_get_task(chpid); if (t != cfg_none) { cfg_set_task(chpid, cfg_none); break; } } mutex_unlock(&cfg_lock); switch (t) { case cfg_configure: sclp_chp_configure(chpid); info_expire(); chsc_chp_online(chpid); break; case cfg_deconfigure: sclp_chp_deconfigure(chpid); info_expire(); chsc_chp_offline(chpid); break; case cfg_none: /* Get updated information after last change. */ info_update(); mutex_lock(&cfg_lock); cfg_busy = 0; mutex_unlock(&cfg_lock); wake_up_interruptible(&cfg_wait_queue); return; } queue_work(chp_wq, &cfg_work); }
/** * chp_info_get_status - retrieve configure status of a channel-path * @chpid: channel-path ID * * On success, return 0 for standby, 1 for configured, 2 for reserved, * 3 for not recognized. Return negative error code on error. */ int chp_info_get_status(struct chp_id chpid) { int rc; int bit; rc = info_update(); if (rc) return rc; bit = info_bit_num(chpid); mutex_lock(&info_lock); if (!chp_test_bit(chp_info.recognized, bit)) rc = CHP_STATUS_NOT_RECOGNIZED; else if (chp_test_bit(chp_info.configured, bit)) rc = CHP_STATUS_CONFIGURED; else if (chp_test_bit(chp_info.standby, bit)) rc = CHP_STATUS_STANDBY; else rc = CHP_STATUS_RESERVED; mutex_unlock(&info_lock); return rc; }
void info_display_track_removed_cb(GtkPodApp *app, gpointer tk, gint32 pos, gpointer data) { info_update(); }
void info_display_itdb_changed_cb(GtkPodApp *app, gpointer itdb, gpointer data) { info_update(); }
void info_display_track_updated_cb(GtkPodApp *app, gpointer tk, gpointer data) { info_update(); }
void info_display_playlist_removed_cb(GtkPodApp *app, gpointer pl, gpointer data) { info_update(); }
void info_display_playlist_added_cb(GtkPodApp *app, gpointer pl, gint32 pos, gpointer data) { info_update(); }
void find_directory(char *p, FILE *disk, char *filename, char *file_name) { char* dir = 0; char* file = 0; char* pch = strtok (filename, "/"); int i = size*FDT_start; int j = size*FAT_start; unsigned int dir_block = 0; unsigned long end = 0xFFFFFFFF; int dirSize; char *fileName; dir = pch; if (pch != NULL) { pch = strtok (NULL, "/"); file = pch; } while (i<size*(FDT_start+FDT_block)) { fileName = p+i+27; if(strncmp(fileName, dir, 31) == 0) { dir_block = getSuperBlockinfo(p,i+1,4); break; } else { i += 64; } } if(dir_block == 0) { disk_put(disk, file_name); while (getSuperBlockinfo(p, j, 4) != 0) { j += 4; } dir_block = (j-size*FAT_start)/4; fseek(disk, j, SEEK_SET); fwrite(&end, 1, 4, disk); info_update(disk, file, 0x03, dir_block); start = dir_block; block = 1; info_update(disk, dir, 0x05, 0); } else { disk_put(disk, file_name); info_update(disk, file, 0x03, dir_block); fseek(disk, i+9, SEEK_SET); dirSize = htonl(byte+64+getSuperBlockinfo(p, i+9, 4)); fwrite(&dirSize, 1, 4, disk); fseek(disk, i+20, SEEK_SET); time_t mt; time(&mt); struct tm *mtime; // Get modify time in local time mtime = localtime(&mt); unsigned int myear = (mtime->tm_year)+1900; unsigned int mmonth = (mtime->tm_mon) + 1; unsigned int mday = (mtime->tm_mday); unsigned int mhour = (mtime->tm_hour); unsigned int mmin = (mtime->tm_min); unsigned int msec = (mtime->tm_sec); unsigned int mmyear = (myear>>8) | (myear<<8); // fwrite modify time here fwrite(&mmyear, 1, 2, disk); fwrite(&mmonth, 1, 1, disk); fwrite(&mday, 1, 1, disk); fwrite(&mhour, 1, 1, disk); fwrite(&mmin, 1, 1, disk); fwrite(&msec, 1, 1, disk); } }
/* ** Reconstruct PDF file per the information in pageinfo. ** use_forms==0: Old-style reconstruction where the pages are not turned into XObject Forms. ** use_forms==1: New-style where pages are turned into XObject forms. */ int wmupdf_remake_pdf(char *infile,char *outfile,WPDFPAGEINFO *pageinfo,int use_forms,FILE *out) { pdf_document *xref; fz_context *ctx; fz_write_options fzopts; char *password=""; int status; int write_failed; fzopts.do_garbage=1; /* 2 and 3 don't work for this. */ fzopts.do_expand=0; fzopts.do_ascii=0; fzopts.do_linear=0; write_failed=0; wpdfpageinfo_sort(pageinfo); xref=NULL; /* New context */ ctx = fz_new_context(NULL,NULL,FZ_STORE_UNLIMITED); if (!ctx) { nprintf(out,"wmupdf_remake_pdf: Cannot initialize context.\n"); return(-1); } fz_try(ctx) { xref=pdf_open_document_no_run(ctx,infile); if (!xref) { fz_free_context(ctx); nprintf(out,"wmupdf_remake_pdf: Cannot open PDF file %s.\n",infile); return(-2); } if (pdf_needs_password(xref) && !pdf_authenticate_password(xref,password)) { pdf_close_document(xref); fz_free_context(ctx); nprintf(out,"wmupdf_remake_pdf: Cannot authenticate PDF file %s.\n",infile); return(-3); } status=wmupdf_pdfdoc_newpages(xref,ctx,pageinfo,use_forms,out); if (status<0) { pdf_close_document(xref); fz_free_context(ctx); nprintf(out,"wmupdf_remake_pdf: Error re-paginating PDF file %s.\n",infile); return(status); } info_update(ctx,xref,pageinfo->producer); /* Write output */ pdf_write_document(xref,outfile,&fzopts); } fz_always(ctx) { pdf_close_document(xref); } fz_catch(ctx) { write_failed=1; } fz_free_context(ctx); if (write_failed) { nprintf(out,"wmupdf_remake_pdf: Error writing output PDF file %s.\n",outfile); return(-10); } return(0); }