/* * Create timeshift directories (for a given instance) */ int timeshift_filemgr_makedirs ( int index, char *buf, size_t len ) { if (timeshift_filemgr_get_root(buf, len)) return 1; snprintf(buf+strlen(buf), len-strlen(buf), "/%d", index); return makedirs(buf, 0700, -1, -1); }
/* * Terminate */ void timeshift_filemgr_term ( void ) { char path[512]; /* Wait for thread */ pthread_mutex_lock(×hift_reaper_lock); timeshift_reaper_run = 0; pthread_cond_signal(×hift_reaper_cond); pthread_mutex_unlock(×hift_reaper_lock); pthread_join(timeshift_reaper_thread, NULL); /* Remove the lot */ timeshift_filemgr_get_root(path, sizeof(path)); rmtree(path); }
/* * Initialise global structures */ void timeshift_filemgr_init ( void ) { char path[512]; /* Try to remove any rubbish left from last run */ timeshift_filemgr_get_root(path, sizeof(path)); rmtree(path); /* Start the reaper thread */ timeshift_reaper_run = 1; pthread_mutex_init(×hift_reaper_lock, NULL); pthread_cond_init(×hift_reaper_cond, NULL); TAILQ_INIT(×hift_reaper_list); pthread_create(×hift_reaper_thread, NULL, timeshift_reaper_callback, NULL); }