need to check that status is OK before we start dereferencing the 'export' pointers or else we will segv.
this could happen if trying to pull the list of exports from a host that does not have mountd running, or if we can not connect at all to the host.
struct statvfs svfs;
exports export, tmp;
- printf("exports on server %s\n", SERVER);
export = mount_getexports(SERVER);
- tmp = export;
- while (tmp != NULL) {
- printf("Export: %s\n", tmp->ex_dir);
- tmp = tmp->ex_next;
- }
- mount_free_export_list(export);
-
+ if (export != NULL) {
+ printf("exports on server %s\n", SERVER);
+ tmp = export;
+ while (tmp != NULL) {
+ printf("Export: %s\n", tmp->ex_dir);
+ tmp = tmp->ex_next;
+ }
+
+ mount_free_export_list(export);
+ } else {
+ printf("no exports on server %s\n", SERVER);
+ }
nfs = nfs_init_context();
if (nfs == NULL) {
return cb_data.status;
}
-void mount_getexports_cb(struct rpc_context *mount_context _U_, int status, void *data, void *private_data)
+void mount_getexports_cb(struct rpc_context *mount_context, int status, void *data, void *private_data)
{
struct sync_cb_data *cb_data = private_data;
exports export = *(exports *)data;
cb_data->status = status;
cb_data->return_data = NULL;
+ if (status != 0) {
+ rpc_set_error(mount_context, "mount/export call failed with \"%s\"", (char *)data);
+ return;
+ }
+
while (export != NULL) {
exports new_export;