/** * @brief Get the handle of a file, knowing its name and its parent dir * * @param p_context * @param p_parent_dir_handle * Handle of the parent directory * @param p_fsalname * Name of the object * @param p_infofs * Information about the file (taken from the filesystem) to be compared to information stored in database * @param p_object_handle * Handle of the file. * * @return * ERR_FSAL_NOERR, if no error * Anothere error code else. */ fsal_status_t fsal_internal_getInfoFromName(posixfsal_op_context_t * p_context, /* IN */ posixfsal_handle_t * p_parent_dir_handle, /* IN */ fsal_name_t * p_fsalname, /* IN */ fsal_posixdb_fileinfo_t * p_infofs, /* IN */ posixfsal_handle_t * p_object_handle) /* OUT */ { fsal_posixdb_status_t stdb; fsal_status_t st; stdb = fsal_posixdb_getInfoFromName(p_context->p_conn, p_parent_dir_handle, p_fsalname, NULL, p_object_handle); switch (stdb.major) { case ERR_FSAL_POSIXDB_NOERR: /* No error, the object is in the database */ /* check consistency */ if(fsal_posixdb_consistency_check(&(p_object_handle->data.info), p_infofs)) { /* Entry not consistent */ /* Delete the Handle entry, then add a new one (with a Parent entry) */ stdb = fsal_posixdb_deleteHandle(p_context->p_conn, p_object_handle); if(FSAL_POSIXDB_IS_ERROR(stdb) && FSAL_IS_ERROR(st = posixdb2fsal_error(stdb))) return st; /* don't break, add a new entry */ } else { break; } case ERR_FSAL_POSIXDB_NOENT: /* object not in the database, add a new entry */ st = fsal_internal_posixdb_add_entry(p_context->p_conn, p_fsalname, p_infofs, p_parent_dir_handle, p_object_handle); if(FSAL_IS_ERROR(st)) return st; break; default: /* error */ if(FSAL_IS_ERROR(st = posixdb2fsal_error(stdb))) return st; } ReturnCode(ERR_FSAL_NO_ERROR, 0); }
void find(fsal_posixdb_conn * p_conn) { posixfsal_handle_t handle_root; fsal_posixdb_status_t st; st = fsal_posixdb_getInfoFromName(p_conn, NULL, /* parent handle */ NULL, /* filename */ NULL, /* path */ &handle_root); if(FSAL_POSIXDB_IS_NOENT(st)) { fputs("Error : Root handle not found. Is the database empty ?", stderr); return; } else if(FSAL_POSIXDB_IS_ERROR(st)) { fprintf(stderr, "Error (%i/%i) while getting root handle\n", st.major, st.minor); return; } display_directory(p_conn, &handle_root, ""); return; }