Skip to content

Commit bc3fa3a

Browse files
committed
Remove bloat. Support multiple mounts
1 parent 405574a commit bc3fa3a

File tree

6 files changed

+56
-202
lines changed

6 files changed

+56
-202
lines changed

Makefile.am

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ AM_CPPFLAGS = -Wall -Wextra
33
pkglibexec_PROGRAMS = tiny_initramfs
44

55
tiny_initramfs_SOURCES = tiny_initramfs.c io.c mount.c log.c devices.c util.c
6-
if ENABLE_NFS4
7-
tiny_initramfs_SOURCES += nfs.c
8-
endif
96
tiny_initramfs_CFLAGS = -fno-inline-small-functions -fno-caller-saves
107
tiny_initramfs_LDFLAGS = -static
118

configure.ac

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ AC_CONFIG_HEADERS([config.h])
1212
AC_CONFIG_FILES([
1313
Makefile
1414
])
15-
AC_ARG_ENABLE([uuid], [AS_HELP_STRING([--disable-uuid], [Enable support for searching for devices via their UUID (default is yes)])])
16-
AS_IF([test x"$enable_uuid" != x"no"], [AC_DEFINE([ENABLE_UUID], [1], [Define if UUID support is enabled])])
17-
AC_ARG_ENABLE([nfs4], [AS_HELP_STRING([--enable-nfs4], [Enable support for mounting NFSv4 shares (default is no)])])
18-
AS_IF([test x"$enable_nfs4" = x"yes"], [AC_DEFINE([ENABLE_NFS4], [1], [Define if NFS4 support is enabled])])
19-
AM_CONDITIONAL([ENABLE_NFS4], [test x"$enable_nfs4" = x"yes"])
2015
AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], [Enable support for printing debug messages])])
2116
AS_IF([test x"$enable_debug" = x"yes"], [AC_DEFINE([ENABLE_DEBUG], [1], [Define if debug messages are enabled])])
2217
AC_ARG_ENABLE([modules], [AS_HELP_STRING([--enable-modules], [Enable support for loading modules (default is no)])])

devices.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include <stdint.h>
3333
#include <sys/sysmacros.h>
3434

35-
#ifdef ENABLE_UUID
3635
#include <dirent.h>
3736
#include <sys/ioctl.h>
3837
#include <sys/stat.h>
@@ -91,7 +90,6 @@ int parse_uuid(char *uuid_buf /* 16 bytes */, const char *string_representation)
9190

9291
return 0;
9392
}
94-
#endif /* defined(ENABLE_UUID) */
9593

9694
void wait_for_device(char *real_device_name, int *timeout, const char *device, int delay)
9795
{
@@ -117,12 +115,9 @@ void wait_for_device(char *real_device_name, int *timeout, const char *device, i
117115
/* Our timeout starts *after* the rootdelay. */
118116
start = time(NULL);
119117

120-
#ifdef ENABLE_UUID
121118
if (type != WANT_NAME) {
122119
have_device = scan_devices(real_device_name, type, major, minor, uuid, serial);
123-
} else
124-
#endif
125-
{
120+
} else {
126121
set_buf(real_device_name, MAX_PATH_LEN, device, NULL);
127122
have_device = access(device, F_OK) != 0;
128123
}
@@ -143,11 +138,9 @@ void wait_for_device(char *real_device_name, int *timeout, const char *device, i
143138
struct timespec rem;
144139
(void)nanosleep(&req, &rem);
145140

146-
#ifdef ENABLE_UUID
147141
if (type != WANT_NAME)
148142
have_device = scan_devices(real_device_name, type, major, minor, uuid, serial);
149143
else
150-
#endif
151144
have_device = access(device, F_OK) != 0;
152145
}
153146

@@ -163,18 +156,11 @@ void wait_for_device(char *real_device_name, int *timeout, const char *device, i
163156

164157
int is_valid_device_name(const char *device_name, int *type, unsigned int* major, unsigned int *minor, char *uuid, char *serial)
165158
{
166-
#ifdef ENABLE_UUID
167159
int r;
168160
char *endptr;
169161
char uuid_buf[32 + 4 + 1] = { 0 };
170162
char uuid_temp[16];
171163
unsigned long x;
172-
#else
173-
(void)major;
174-
(void)minor;
175-
(void)uuid;
176-
(void)serial;
177-
#endif
178164

179165
if (!device_name)
180166
return 0;
@@ -201,7 +187,6 @@ int is_valid_device_name(const char *device_name, int *type, unsigned int* major
201187
return 1;
202188
}
203189

204-
#ifdef ENABLE_UUID
205190
/* 0x803 or so for 8:3 */
206191
if (device_name[0] == '0' && device_name[1] == 'x') {
207192
x = strtoul(device_name + 2, &endptr, 16);
@@ -240,12 +225,10 @@ int is_valid_device_name(const char *device_name, int *type, unsigned int* major
240225
*type = WANT_UUID;
241226
return r;
242227
}
243-
#endif
244228

245229
return 0;
246230
}
247231

248-
#ifdef ENABLE_UUID
249232
/* Which data types for this structure is available is wildly
250233
* incompatible between libc implementations, so we just use the
251234
* stdint.h types. */
@@ -501,5 +484,3 @@ int is_fs_with_serial(const char *device_name, const char *serial)
501484

502485
return strncmp(serial, device_serial, VIRTIO_BLK_ID_BYTES) == 0;
503486
}
504-
505-
#endif /* defined(ENABLE_UUID) */

mount.c

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ static void determine_supported_filesystems();
4747
static int process_proc_filesystems(void *data, const char *line, int line_is_incomplete);
4848

4949
int mount_filesystem(const char *source, const char *target,
50-
const char *type, const char *flags,
51-
int override_flags_add, int override_flags_subtract)
50+
const char *type, const char *flags)
5251
{
5352
int options;
5453
char data[MAX_LINE_LEN];
@@ -59,32 +58,12 @@ int mount_filesystem(const char *source, const char *target,
5958
warn("mount_filesystem(\"", source, "\", \"", target, "\", \"", type ? type : "(null)", "\", \"", flags, "\", ...): begin", NULL);
6059
#endif
6160

62-
#ifdef ENABLE_NFS4
63-
if (type && (!strcmp(type, "nfs") || !strcmp(type, "nfs4")))
64-
nfsver = !strcmp(type, "nfs4") ? 4 : 0;
65-
#endif
6661
options = parse_mount_options(data, MAX_LINE_LEN, flags, nfsver != -1 ? &nfsver : NULL);
6762

6863
#ifdef ENABLE_DEBUG
6964
warn("mount_filesystem: parsing mount options (done), unparsed options: ", data, NULL);
7065
#endif
7166

72-
options |= override_flags_add;
73-
options &= ~override_flags_subtract;
74-
75-
#ifdef ENABLE_NFS4
76-
if (type && !strcmp(type, "nfs4") && nfsver != 4)
77-
panic(0, "Cannot combine [nfs]vers=2/3 option with filesystem type nfs4.", NULL);
78-
if (type && (!strcmp(type, "nfs") || !strcmp(type, "nfs4"))) {
79-
if (nfsver != 4 && nfsver != 0)
80-
panic(0, "Sorry, only NFSv4 is currently supported.", NULL);
81-
/* Note that nfsver == 0 means we have type == nfs and no vers= parameter
82-
* at this point - which means that in principle we should try first NFSv4
83-
* and then NFSv3/2. But until we support NFSv3, we'll just do NFSv4. */
84-
return mount_nfs4(source, target, options, data);
85-
}
86-
#endif
87-
8867
#ifdef ENABLE_DEBUG
8968
warn("mount_filesystem: not NFS", NULL);
9069
#endif

0 commit comments

Comments
 (0)