Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FUSE subtype #21

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 33 additions & 6 deletions src/runtime/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,25 @@ extern int sqfs_opt_proc(void* data, const char* arg, int key, struct fuse_args*
#include <fnmatch.h>
#include <sys/mman.h>
#include <stdint.h>
#include <stdarg.h>

__attribute__((format(printf, 1, 2)))
static char* x_asprintf(const char* fmt, ...)
{
char* result = NULL;

va_list args;
va_start(args, fmt);

if (vasprintf(&result, fmt, args) == -1) {
fprintf(stderr, "vasprintf(&, \"%s\", ...) failed", fmt);
exit(EXIT_FAILURE);
}

va_end(args);

return result;
}

typedef struct {
uint32_t lo;
Expand Down Expand Up @@ -904,8 +923,6 @@ int fusefs_main(int argc, char* argv[], void (* mounted)(void)) {
struct fuse_opt fuse_opts[] = {
{"offset=%zu", offsetof(sqfs_opts, offset), 0},
{"timeout=%u", offsetof(sqfs_opts, idle_timeout_secs), 0},
{"fsname=%s", "squashfuse", 0},
{"subtype=%s", "squashfuse", 0},
FUSE_OPT_END
};

Expand Down Expand Up @@ -1558,7 +1575,7 @@ int main(int argc, char* argv[]) {
appimage_print_binary(appimage_path, offset, length);
exit(0);
}

portable_option(arg, appimage_path, "home");
portable_option(arg, appimage_path, "config");

Expand Down Expand Up @@ -1609,8 +1626,15 @@ int main(int argc, char* argv[]) {

char* dir = realpath(appimage_path, NULL);

char options[100];
sprintf(options, "ro,offset=%zu", fs_offset);
/* If "subtype" is not given, libfuse will set it to the program name,
* but we want "squashfuse" instead. We also need to explicitly set
* "fsname" to the program name, otherwise it will be set to the value
* of "subtype" ("squashfuse").
*/
char* options = x_asprintf(
"ro,fsname=%s,subtype=squashfuse,offset=%zu",
basename(dir),
fs_offset);

child_argv[0] = dir;
child_argv[1] = "-o";
Expand All @@ -1628,7 +1652,10 @@ int main(int argc, char* argv[]) {
"for more information";
printf("\n%s\n", title);
printf("%s\n", body);
};
}

free(dir);
free(options);
} else {
/* in parent, child is $pid */
int c;
Expand Down