Lines Matching +full:entry +full:- +full:name

1 /*-
2 * Copyright (c) 2005-2006 The FreeBSD Project
5 * Author: Victor Cruceru <soc-victor@freebsd.org>
65 * This structure is used to hold a SNMP table entry
66 * for HOST-RESOURCES-MIB's hrFSTable
85 * Next structure is used to keep o list of mappings from a specific name
86 * (a_name) to an entry in the hrFSTblEntry. We are trying to keep the same
87 * index for a specific name at least for the duration of one SNMP agent run.
94 struct fs_entry *entry; member
147 * Create an entry into the FS table and an entry in the map (if needed).
150 fs_entry_create(const char *name) in fs_entry_create() argument
152 struct fs_entry *entry; in fs_entry_create() local
155 assert(name != NULL); in fs_entry_create()
156 assert(strlen(name) > 0); in fs_entry_create()
159 if (strcmp(map->a_name, name) == 0) in fs_entry_create()
165 /* new object - get a new index */ in fs_entry_create()
167 /* Unrecoverable error - die clean and quicly*/ in fs_entry_create()
177 mount_point_len = strlen(name) + 1; in fs_entry_create()
181 if ((map->a_name = malloc(mount_point_len)) == NULL) { in fs_entry_create()
187 strlcpy(map->a_name, name, mount_point_len); in fs_entry_create()
189 map->hrIndex = next_fs_index++; in fs_entry_create()
190 map->entry = NULL; in fs_entry_create()
193 HRDBG("%s added into hrFSMap at index=%d", name, map->hrIndex); in fs_entry_create()
195 HRDBG("%s exists in hrFSMap index=%d", name, map->hrIndex); in fs_entry_create()
198 if ((entry = malloc(sizeof(*entry))) == NULL) { in fs_entry_create()
203 if ((entry->mountPoint = strdup(name)) == NULL) { in fs_entry_create()
205 free(entry); in fs_entry_create()
209 entry->index = map->hrIndex; in fs_entry_create()
210 map->entry = entry; in fs_entry_create()
212 INSERT_OBJECT_INT(entry, &fs_tbl); in fs_entry_create()
213 return (entry); in fs_entry_create()
217 * Delete an entry in the FS table.
220 fs_entry_delete(struct fs_entry* entry) in fs_entry_delete() argument
224 assert(entry != NULL); in fs_entry_delete()
226 TAILQ_REMOVE(&fs_tbl, entry, link); in fs_entry_delete()
228 if (map->entry == entry) { in fs_entry_delete()
229 map->entry = NULL; in fs_entry_delete()
232 free(entry->mountPoint); in fs_entry_delete()
233 free(entry->remoteMountPoint); in fs_entry_delete()
234 free(entry); in fs_entry_delete()
238 * Find a table entry by its name
241 fs_find_by_name(const char *name) in fs_find_by_name() argument
243 struct fs_entry *entry; in fs_find_by_name() local
245 TAILQ_FOREACH(entry, &fs_tbl, link) in fs_find_by_name()
246 if (strcmp(entry->mountPoint, name) == 0) in fs_find_by_name()
247 return (entry); in fs_find_by_name()
262 if (n1->entry != NULL) { in fini_fs_tbl()
263 TAILQ_REMOVE(&fs_tbl, n1->entry, link); in fini_fs_tbl()
264 free(n1->entry->mountPoint); in fini_fs_tbl()
265 free(n1->entry->remoteMountPoint); in fini_fs_tbl()
266 free(n1->entry); in fini_fs_tbl()
268 free(n1->a_name); in fini_fs_tbl()
280 struct fs_entry *entry; in fs_tbl_pre_refresh() local
282 /* mark each entry as missisng */ in fs_tbl_pre_refresh()
283 TAILQ_FOREACH(entry, &fs_tbl, link) in fs_tbl_pre_refresh()
284 entry->flags &= ~HR_FS_FOUND; in fs_tbl_pre_refresh()
293 struct fs_entry *entry, *entry_tmp; in fs_tbl_post_refresh() local
298 TAILQ_FOREACH_SAFE(entry, &fs_tbl, link, entry_tmp) in fs_tbl_post_refresh()
299 if (!(entry->flags & HR_FS_FOUND)) in fs_tbl_post_refresh()
300 fs_entry_delete(entry); in fs_tbl_post_refresh()
312 if (fs_tick == 0 || this_tick - fs_tick >= fs_tbl_refresh) { in refresh_fs_tbl()
329 if (strcmp(fs_type_map[t].str, fs_p->f_fstypename) == 0) in fs_get_type()
336 * Given information returned from statfs(2) either create a new entry into
337 * the fs_tbl or refresh the entry if it is already there.
342 struct fs_entry *entry; in fs_tbl_process_statfs_entry() local
351 if ((entry = fs_find_by_name(fs_p->f_mntonname)) != NULL || in fs_tbl_process_statfs_entry()
352 (entry = fs_entry_create(fs_p->f_mntonname)) != NULL) { in fs_tbl_process_statfs_entry()
353 entry->flags |= HR_FS_FOUND; in fs_tbl_process_statfs_entry()
355 if (!(fs_p->f_flags & MNT_LOCAL)) { in fs_tbl_process_statfs_entry()
357 entry->remoteMountPoint = strdup(fs_p->f_mntfromname); in fs_tbl_process_statfs_entry()
361 entry->remoteMountPoint = strdup(""); in fs_tbl_process_statfs_entry()
365 entry->type = fs_get_type(fs_p); in fs_tbl_process_statfs_entry()
367 if ((fs_p->f_flags & MNT_RDONLY) == MNT_RDONLY) in fs_tbl_process_statfs_entry()
368 entry->access = FS_READ_ONLY; in fs_tbl_process_statfs_entry()
370 entry->access = FS_READ_WRITE; in fs_tbl_process_statfs_entry()
372 /* FIXME - bootable fs ?! */ in fs_tbl_process_statfs_entry()
373 entry->bootable = TRUTH_MK((fs_p->f_flags & MNT_ROOTFS) in fs_tbl_process_statfs_entry()
376 entry->storageIndex = storage_idx; in fs_tbl_process_statfs_entry()
379 memset(entry->lastFullBackupDate, 0, in fs_tbl_process_statfs_entry()
380 sizeof(entry->lastFullBackupDate)); in fs_tbl_process_statfs_entry()
383 memset(entry->lastPartialBackupDate, 0, in fs_tbl_process_statfs_entry()
384 sizeof(entry->lastPartialBackupDate)); in fs_tbl_process_statfs_entry()
386 handle_partition_fs_index(fs_p->f_mntfromname, entry->index); in fs_tbl_process_statfs_entry()
399 struct fs_entry *entry; in op_hrFSTable() local
406 if ((entry = NEXT_OBJECT_INT(&fs_tbl, in op_hrFSTable()
407 &value->var, sub)) == NULL) in op_hrFSTable()
409 value->var.len = sub + 1; in op_hrFSTable()
410 value->var.subs[sub] = entry->index; in op_hrFSTable()
414 if ((entry = FIND_OBJECT_INT(&fs_tbl, in op_hrFSTable()
415 &value->var, sub)) == NULL) in op_hrFSTable()
420 if ((entry = FIND_OBJECT_INT(&fs_tbl, in op_hrFSTable()
421 &value->var, sub)) == NULL) in op_hrFSTable()
431 switch (value->var.subs[sub - 1]) { in op_hrFSTable()
434 value->v.integer = entry->index; in op_hrFSTable()
438 return (string_get(value, entry->mountPoint, -1)); in op_hrFSTable()
441 if (entry->remoteMountPoint == NULL) in op_hrFSTable()
442 return (string_get(value, "", -1)); in op_hrFSTable()
444 return (string_get(value, entry->remoteMountPoint, -1)); in op_hrFSTable()
448 assert(entry->type != NULL); in op_hrFSTable()
449 value->v.oid = *(entry->type); in op_hrFSTable()
453 value->v.integer = entry->access; in op_hrFSTable()
457 value->v.integer = entry->bootable; in op_hrFSTable()
461 value->v.integer = entry->storageIndex; in op_hrFSTable()
465 return (string_get(value, entry->lastFullBackupDate, 8)); in op_hrFSTable()
468 return (string_get(value, entry->lastPartialBackupDate, 8)); in op_hrFSTable()