Latest revision |
Your text |
Line 1: |
Line 1: |
- | {{Mer}}
| |
- |
| |
| == Notes == | | == Notes == |
| *These directions are confirmed to work on Mer 0.12. | | *These directions are confirmed to work on Mer 0.12. |
Line 104: |
Line 102: |
| | | |
| === Step 6: Install libgps5300faker.so === | | === Step 6: Install libgps5300faker.so === |
- | First of all, install the necessary packages (they may be removed later, this may be an excessive list or an incomplete list. Basically keep installing stuff until it stops complaining):
| + | Put libgps5300faker.so in /usr/lib (Not posted anywhere yet): |
- | apt-get install build-essential m4 automake autoconf
| + | cp /path/to/libgps5300faker.so /usr/lib |
- | | + | |
- | Make the following files somewhere (they may be removed later):
| + | |
- | | + | |
- | preload_init.c
| + | |
- | /*
| + | |
- | * Copyright 2009 Luke Dashjr <luke_n8x0_gps5300driver@dashjr.org>
| + | |
- | * Licensed for redistribution as-is;
| + | |
- | * contact me if you want something more permissive
| + | |
- | */
| + | |
- |
| + | |
- | #define _GNU_SOURCE
| + | |
- |
| + | |
- | #include <dlfcn.h>
| + | |
- | #include <stdlib.h>
| + | |
- | #include <string.h>
| + | |
- | #include <sys/types.h>
| + | |
- | #include <sys/socket.h>
| + | |
- | #include <sys/un.h>
| + | |
- | #include <unistd.h>
| + | |
- |
| + | |
- | static struct sockaddr_un ctrl_sau = {
| + | |
- | AF_UNIX,
| + | |
- | "/var/lib/gps/gps_driver_ctrl\0",
| + | |
- | };
| + | |
- | #define CTRL_SCK_PATH ctrl_sau.sun_path
| + | |
- |
| + | |
- | static int ctrl_sck = -1;
| + | |
- |
| + | |
- | typedef int (*bind_t)(int, const struct sockaddr*, socklen_t);
| + | |
- |
| + | |
- | int
| + | |
- | bind(int sockfd, const struct sockaddr*addr, socklen_t addrlen) {
| + | |
- | static bind_t real = NULL;
| + | |
- | if (!real)
| + | |
- | real = dlsym(RTLD_NEXT, "bind");
| + | |
- |
| + | |
- | int rv = real(sockfd, addr, addrlen);
| + | |
- |
| + | |
- | if (
| + | |
- | addr &&
| + | |
- | addr->sa_family == AF_FILE &&
| + | |
- | !strcmp(CTRL_SCK_PATH,
| + | |
- | ((struct sockaddr_un*)addr)->sun_path
| + | |
- | ) &&
| + | |
- | getenv("GPS5300_SELFINIT") &&
| + | |
- | 1
| + | |
- | )
| + | |
- | ctrl_sck = sockfd;
| + | |
- |
| + | |
- | return rv;
| + | |
- | }
| + | |
- |
| + | |
- | typedef int (*listen_t)(int, int);
| + | |
- |
| + | |
- | int
| + | |
- | listen(int sockfd, int backlog) {
| + | |
- | static listen_t real = NULL;
| + | |
- | if (!real)
| + | |
- | real = dlsym(RTLD_NEXT, "listen");
| + | |
- |
| + | |
- | int rv = real(sockfd, backlog);
| + | |
- |
| + | |
- | if (sockfd == ctrl_sck && !fork())
| + | |
- | {
| + | |
- | // Child process :)
| + | |
- |
| + | |
- | int sck;
| + | |
- | char initcmd[] = "P 3\n";
| + | |
- |
| + | |
- | sck = socket(PF_FILE, SOCK_STREAM, 0);
| + | |
- | if (sck < 0)
| + | |
- | exit(1);
| + | |
- | if (connect(sck, &ctrl_sau, sizeof ctrl_sau))
| + | |
- | exit(1);
| + | |
- | write(sck, initcmd, sizeof initcmd);
| + | |
- | close(sck);
| + | |
- |
| + | |
- | exit(0);
| + | |
- | }
| + | |
- |
| + | |
- | return rv;
| + | |
- | }
| + | |
- | | + | |
- | preload.c:
| + | |
- | /*
| + | |
- | * Copyright 2009 Luke Dashjr <luke_n8x0_gps5300driver@dashjr.org>
| + | |
- | * Licensed for redistribution as-is;
| + | |
- | * contact me if you want something more permissive
| + | |
- | */
| + | |
- |
| + | |
- | #define _GNU_SOURCE
| + | |
- |
| + | |
- | #include <dlfcn.h>
| + | |
- | #include <pwd.h>
| + | |
- | #include <stdlib.h>
| + | |
- | #include <string.h>
| + | |
- | #include <sys/types.h>
| + | |
- |
| + | |
- | typedef struct passwd* (*getpwnam_t)(const char*);
| + | |
- |
| + | |
- | struct passwd *
| + | |
- | getpwnam(const char *name) {
| + | |
- | static getpwnam_t real = NULL;
| + | |
- | if (!real)
| + | |
- | real = dlsym(RTLD_NEXT, "getpwnam");
| + | |
- |
| + | |
- | if (!strcmp(name, "user"))
| + | |
- | {
| + | |
- | const char*username = getenv("GPS5300_USER");
| + | |
- | if (username)
| + | |
- | name = username;
| + | |
- | }
| + | |
- |
| + | |
- | return real(name);
| + | |
- | }
| + | |
- |
| + | |
- | | + | |
- | Compile them:
| + | |
- | cd /path/to/source/files/
| + | |
- | gcc -shared -fPIC -ldl preload.c preload_init.c -o libgps5300faker.so
| + | |
- | | + | |
- | Put libgps5300faker.so in /usr/lib (assuming you're still in the same directory): | + | |
- | cp libgps5300faker.so /usr/lib | + | |
| | | |
| === Step 7: Reboot === | | === Step 7: Reboot === |
Line 253: |
Line 128: |
| | | |
| You have a lock and are ready to use your GPS (I've also gotten other messages indicating the GPS is ready. Basically anything new/other than what it routinely spits out should be a good indicator). | | You have a lock and are ready to use your GPS (I've also gotten other messages indicating the GPS is ready. Basically anything new/other than what it routinely spits out should be a good indicator). |
- |
| |
- | [[Category:N8x0]]
| |
- | [[Category:GPS]]
| |