static int pakfire_mount(struct pakfire* pakfire, const char* source, const char* target,
const char* fstype, unsigned long mflags, const void* data) {
const char* options = (const char*)data;
- int r;
-
- char error[1024];
// Check for some basic inputs
if (!source || !target) {
return 1;
}
- DEBUG(pakfire, "Mounting %s from %s (%s - %s)\n",
- target, source, fstype, options);
-
-#ifdef PAKFIRE_DEBUG
- // Enable debugging for libmount
- mnt_init_debug(0xffff);
-#endif
-
- // Allocate a new mount context
- struct libmnt_context* ctx = mnt_new_context();
- if (!ctx)
- return 1;
+ DEBUG(pakfire, "Mounting %s from %s (%s - %s)\n", target, source, fstype, options);
- // Set source
- r = mnt_context_set_source(ctx, source);
+ // Perform mount()
+ int r = mount(source, target, fstype, mflags, data);
if (r) {
- ERROR(pakfire, "Could not set source: %m\n");
- goto ERROR;
+ ERROR(pakfire, "Could not mount %s: %m\n", target);
}
- // Set target
- r = mnt_context_set_target(ctx, target);
- if (r) {
- ERROR(pakfire, "Could not set target: %m\n");
- goto ERROR;
- }
-
- // Set filesystem type
- if (fstype) {
- r = mnt_context_set_fstype(ctx, fstype);
- if (r) {
- ERROR(pakfire, "Could not set filesystem type: %m\n");
- goto ERROR;
- }
- }
-
- // Set mount flags
- if (mflags) {
- r = mnt_context_set_mflags(ctx, mflags);
- if (r) {
- ERROR(pakfire, "Could not set mount flags: %m\n");
- goto ERROR;
- }
- }
-
- // Set options
- if (options) {
- r = mnt_context_set_options(ctx, options);
- if (r) {
- ERROR(pakfire, "Could not set mount options: %m\n");
- goto ERROR;
- }
- }
-
- // Perform mount operation
- r = mnt_context_mount(ctx);
- if (r) {
- // Fetch the error message
- mnt_context_get_excode(ctx, r, error, sizeof(error));
-
- ERROR(pakfire, "Mount unsuccessful: %s\n", error);
- goto ERROR;
- }
-
-ERROR:
- if (ctx)
- mnt_free_context(ctx);
-
return r;
}
goto RETRY;
}
- ERROR(pakfire, "Could not mount /%s: %m\n", mp->target);
return r;
}
}