int i;
if (strncmpz(id, "iface", idlen) == 0) {
- char *result;
- static char label_buf[20];
- safe_strncpy(label_buf, ifd->iface, sizeof(label_buf));
- result = strchr(label_buf, ':');
- if (result) {
- *result = '\0';
- }
+ static char *label_buf;
+ //char *result;
+
+ free(label_buf);
+ label_buf = xstrdup(ifd->iface);
+ // Remove virtual iface suffix - why?
+ // ubuntu's ifup doesn't do this
+ //result = strchrnul(label_buf, ':');
+ //*result = '\0';
return label_buf;
}
if (strncmpz(id, "label", idlen) == 0) {
enum { KEY_ID = 0x414e4547 }; /* "GENA" */
-static struct shbuf_ds {
+struct shbuf_ds {
int32_t size; // size of data - 1
int32_t tail; // end of message list
char data[1]; // messages
-} *shbuf;
-
-// Semaphore operation structures
-static struct sembuf SMrup[1] = {{0, -1, IPC_NOWAIT | SEM_UNDO}}; // set SMrup
-static struct sembuf SMrdn[2] = {{1, 0}, {0, +1, SEM_UNDO}}; // set SMrdn
-
+};
+
+static const struct sembuf init_sem[3] = {
+ {0, -1, IPC_NOWAIT | SEM_UNDO},
+ {1, 0}, {0, +1, SEM_UNDO}
+};
+
+struct globals {
+ struct sembuf SMrup[1]; // {0, -1, IPC_NOWAIT | SEM_UNDO},
+ struct sembuf SMrdn[2]; // {1, 0}, {0, +1, SEM_UNDO}
+ struct shbuf_ds *shbuf;
+};
+#define G (*(struct globals*)&bb_common_bufsiz1)
+#define SMrup (G.SMrup)
+#define SMrdn (G.SMrdn)
+#define shbuf (G.shbuf)
+#define INIT_G() \
+ do { \
+ memcpy(SMrup, init_sem, sizeof(init_sem)); \
+ } while (0)
static void error_exit(const char *str) ATTRIBUTE_NORETURN;
static void error_exit(const char *str)