diff options
Diffstat (limited to 'accel-pppd/backup')
-rw-r--r-- | accel-pppd/backup/backup.c | 10 | ||||
-rw-r--r-- | accel-pppd/backup/backup.h | 10 | ||||
-rw-r--r-- | accel-pppd/backup/backup_file.c | 22 |
3 files changed, 21 insertions, 21 deletions
diff --git a/accel-pppd/backup/backup.c b/accel-pppd/backup/backup.c index 16349fc7..18e9332f 100644 --- a/accel-pppd/backup/backup.c +++ b/accel-pppd/backup/backup.c @@ -15,7 +15,7 @@ static LIST_HEAD(module_list); struct backup_tag __export *backup_add_tag(struct backup_mod *m, uint8_t id, int internal, const void *data, size_t size) { struct backup_tag *t; - + t = m->data->storage->alloc_tag(m->data, size); if (!t) return NULL; @@ -39,7 +39,7 @@ void backup_add_fd(struct backup_mod *m, int fd) struct backup_mod __export *backup_find_mod(struct backup_data *d, uint8_t mod_id) { struct backup_mod *m; - + list_for_each_entry(m, &d->mod_list, entry) { if (m->id == mod_id) return m; @@ -232,19 +232,19 @@ void __export backup_register_storage(struct backup_storage *s) void backup_restore_fd() { - + } void backup_restore(int internal) { struct backup_storage *storage; struct backup_module *module; - + list_for_each_entry(storage, &storage_list, entry) { if (storage->restore) storage->restore(internal); } - + list_for_each_entry(module, &module_list, entry) { if (module->restore_complete) module->restore_complete(); diff --git a/accel-pppd/backup/backup.h b/accel-pppd/backup/backup.h index 0037596a..3d3d77ec 100644 --- a/accel-pppd/backup/backup.h +++ b/accel-pppd/backup/backup.h @@ -41,7 +41,7 @@ struct backup_data struct list_head mod_list; int internal:1; }; - + struct backup_module { struct list_head entry; @@ -49,7 +49,7 @@ struct backup_module int (*save)(struct ap_session *, struct backup_mod *); int (*restore)(struct ap_session *, struct backup_mod *); - + struct ap_session *(*ctrl_restore)(struct backup_mod *); void (*ctrl_start)(struct ap_session *ses); void (*restore_complete)(void); @@ -61,18 +61,18 @@ struct backup_storage /*int (*check_integrity)(void); int (*restore)(int internal);*/ - + void (*restore)(int internal); struct backup_data *(*create)(struct ap_session *); int (*commit)(struct backup_data *); void (*free)(struct backup_data *); - + struct backup_mod *(*alloc_mod)(struct backup_data *); void (*free_mod)(struct backup_mod *); void (*add_fd)(struct backup_data *, int fd); - + struct backup_tag *(*alloc_tag)(struct backup_data *, int size); void (*free_tag)(struct backup_data *, struct backup_tag *); }; diff --git a/accel-pppd/backup/backup_file.c b/accel-pppd/backup/backup_file.c index b9d26466..06dc02d4 100644 --- a/accel-pppd/backup/backup_file.c +++ b/accel-pppd/backup/backup_file.c @@ -78,7 +78,7 @@ static int fs_commit(struct backup_data *d) MD5_Init(&md5); MD5_Update(&md5, &version, 1); - + iov[0].iov_base = &version; iov[0].iov_len = 1; i = 1; @@ -145,7 +145,7 @@ static int fs_commit(struct backup_data *d) } return 0; - + out_err: close(fd); unlink(fname); @@ -159,10 +159,10 @@ static void fs_free(struct backup_data *d) if (fsd->map_addr) munmap(fsd->map_addr, fsd->map_len); - + if (fsd->fd != -1) close(fsd->fd); - + sprintf(fname, "%s/%s", conf_path, d->ses->sessionid); unlink(fname); @@ -190,10 +190,10 @@ static void fs_free_mod(struct backup_mod *mod) static struct backup_tag *fs_alloc_tag(struct backup_data *d, int size) { struct backup_tag *t = _malloc(sizeof(struct backup_tag) + 4 + size); - + if (!t) return NULL; - + memset(t, 0, sizeof(*t)); t->data = (uint8_t *)(t + 1) + 4; @@ -240,7 +240,7 @@ static void restore_session(const char *fn, int internal) close(fd); return; } - + if (*ptr != VERSION) goto out; @@ -250,11 +250,11 @@ static void restore_session(const char *fn, int internal) if (memcmp(md5_buf, ptr + st.st_size - 16, 16)) goto out; - + d = fs_create(NULL); if (!d) goto out; - + d->internal = internal; fsd = container_of(d, typeof(*fsd), data); @@ -304,10 +304,10 @@ static void fs_restore(int internal) { DIR *dirp; struct dirent ent, *res; - + if (!conf_path) return; - + dirp = opendir(conf_path); if (!dirp) { log_emerg("backup_file: opendir: %s\n", strerror(errno)); |