Skip to content

Commit d713468

Browse files
committed
Replace mount by nmount, use GNU Make, Fixup print problem
1 parent 07627c1 commit d713468

File tree

4 files changed

+50
-22
lines changed

4 files changed

+50
-22
lines changed

Make.defines.freebsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
UELD_OS := freebsd
1+
UELD_OS := freebsd
22
UELD_OS_CFLAGS := -DBSD
33

44
CC := cc

Makefile

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
UELD_OS := unkown
22
include version
33

4-
#ifeq "$(PLATFORM)" ""
5-
# PLATFORM !=./systype.sh
6-
#endif
4+
ifeq "$(PLATFORM)" ""
5+
PLATFORM = $(shell ./systype.sh)
6+
endif
77
include Make.defines.$(PLATFORM)
88

99

@@ -13,9 +13,9 @@ ETCDIR := $(PREFIX)/etc/ueld
1313

1414
OBJS := main.o minit.o fileio.o reboot.o tools.o respawn.o os/$(UELD_OS)/pw.o os/$(UELD_OS)/chvt.o os/$(UELD_OS)/ctrlaltdel.o os/$(UELD_OS)/proc.o os/$(UELD_OS)/mnt.o
1515
CROSS :=
16-
#ifeq "$(CC)" ""
17-
# CC := gcc
18-
#endif
16+
ifeq "$(CC)" ""
17+
CC := gcc
18+
endif
1919
STRIP := strip
2020

2121
CFLAG := -Wall -O2 -std=c99 $(UELD_OS_CFLAGS)
@@ -29,8 +29,7 @@ ueld : $(OBJS)
2929
@echo " STRIP $@"
3030
@$(CROSS)$(STRIP) -s $@
3131

32-
.c.o:
33-
#%.o : %.c config.h
32+
%.o : %.c config.h
3433
@echo " CC $@"
3534
@$(CROSS)$(CC) -c -o $@ $(CFLAG) $<
3635

@@ -54,18 +53,18 @@ install_generic_etc_file:
5453
chmod 755 $(ETCDIR)/*.sh
5554

5655
install_no_initramfs:
57-
make install_ueld_executable
56+
$(MAKE) install_ueld_executable
5857

5958
mkdir -p $(ETCDIR)
6059
cp -n etcfiles/no_initramfs/* $(ETCDIR)/
6160
touch $(ETCDIR)/*
6261
chmod 755 $(ETCDIR)/*.sh
6362

64-
make install_generic_etc_file
63+
$(MAKE) install_generic_etc_file
6564

6665
install:
67-
make install_ueld_executable
68-
make install_generic_etc_file
66+
$(MAKE) install_ueld_executable
67+
$(MAKE) install_generic_etc_file
6968

7069
test:
7170
@echo "FIXME: Need a test target"

os/freebsd/mnt.c

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@
99

1010
#include <sys/param.h>
1111
#include <sys/mount.h>
12+
#include <sys/uio.h>
13+
14+
#define OPT_FSTYPE "fstype"
15+
#define OPT_FSPATH "fspath"
16+
#define OPT_FROM "from"
1217

1318
static int _ueld_umount(struct statfs* fs)
1419
{
15-
char *dir, *type;
20+
char *dir;
21+
struct iovec iov[6];
1622

1723
dir = fs->f_mntonname;
1824

@@ -21,16 +27,39 @@ static int _ueld_umount(struct statfs* fs)
2127
if (unmount(dir, 0) == 0)
2228
return 0;
2329

24-
type = fs->f_fstypename;
30+
iov[0].iov_base = OPT_FSTYPE;
31+
iov[0].iov_len = sizeof(OPT_FSTYPE);
32+
iov[1].iov_base = fs->f_fstypename;
33+
iov[1].iov_len = strlen(fs->f_fstypename);
2534

26-
if (mount(type, dir, MNT_RDONLY | MNT_UPDATE, NULL) < 0) {
35+
iov[2].iov_base = OPT_FSPATH;
36+
iov[2].iov_len = sizeof(OPT_FSPATH);
37+
iov[3].iov_base = dir;
38+
iov[3].iov_len = strlen(dir);
39+
40+
iov[4].iov_base = OPT_FROM;
41+
iov[4].iov_len = sizeof(OPT_FROM);
42+
iov[5].iov_base = fs->f_mntfromname;
43+
iov[5].iov_len = strlen(fs->f_mntfromname);
44+
45+
if (nmount(iov, 6, MNT_RDONLY | MNT_UPDATE) < 0) {
2746
ueld_print("Re-mount %s failed (%s), system will"
2847
" not poweroff or poweroff unsafely if"
2948
" the problem can not be fixup later.\n",
3049
dir, strerror(errno));
3150
return -1;
3251
}
3352

53+
/*
54+
if (mount(type, dir, MNT_RDONLY | MNT_UPDATE, NULL) < 0) {
55+
ueld_print("Re-mount %s failed (%s), system will"
56+
" not poweroff or poweroff unsafely if"
57+
" the problem can not be fixup later.\n",
58+
dir, strerror(errno));
59+
return -1;
60+
}
61+
*/
62+
3463
return 0;
3564
}
3665

tools.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,19 @@ void ueld_print(char* fmt, ...)
7070
* See main.c, for Linux Sysrq SAK problem
7171
* And it cause a window that is not 'SAK safe'
7272
*/
73-
#ifdef LINUX
73+
//#ifdef LINUX
7474
if ((fd = open("/dev/console", O_NOCTTY | O_WRONLY)) < 0)
7575
return;
76-
#else
77-
fd = STDOUT_FILENO;
78-
#endif // LINUX
76+
//#else
77+
// fd = STDOUT_FILENO;
78+
//#endif // LINUX
7979

8080
write(fd, "[ueld] ", 7);
8181
write(fd, buff, strlen(buff));
8282

83-
#ifdef LINUX
83+
//#ifdef LINUX
8484
close(fd);
85-
#endif // LINUX
85+
//#endif // LINUX
8686

8787
va_end(ap);
8888
}

0 commit comments

Comments
 (0)