Compare commits

...
Sign in to create a new pull request.

22 commits

Author SHA1 Message Date
Karel Zak
c5b89a12ac mountsh: remove unused mfd,update help
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-05 13:06:50 +01:00
Karel Zak
94b4f90018 mountsh: differentiate between flags and attributes
* use '|' for flags (e.g. CLOEXEC|CLONE|RECURSIVE)
* use ',' for attributes (e.g. noexec,nosuid,nodev)

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-05 12:54:29 +01:00
Karel Zak
5e028ed26b mountsh: add open_tree
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-05 12:41:21 +01:00
Karel Zak
da168ed89b mountsh: add openpath
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-05 11:58:40 +01:00
Karel Zak
858fc55d20 lib/procutils: remove proc_next_fd() stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-03 14:00:11 +01:00
Karel Zak
b399f87c7b mountsh: don't use procutils to read fds
It's seems struct proc_fds is useless for another use-cases (utils).
Let's keep it without extra abstraction.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-03 13:51:55 +01:00
Karel Zak
12ce07a558 lib/strutils: return string from strrem() and strrep()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-03 13:51:21 +01:00
Karel Zak
4e70cf070e mountsh: fix named FD allocation
... nice brown-paper-bag bug.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-03 10:56:15 +01:00
Karel Zak
0b529eaf0a mountsh: fix segmentation fault
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-02 13:12:13 +01:00
Karel Zak
7048ff3a3e mountsh: add command move_mount
- add two version
	- simple: move_mount <from-fd> <to-path> [<flags>]
	- full: move_mount <from-fd> <from-path>|"" <to-fd>|AT_FDCWD <to-path>|"" [<flags>]

- cleanup help output
- cleanup atrributes

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-02 12:45:03 +01:00
Karel Zak
1e40bcdd9c mountsh: don't use default for close command
* be explicit with 'close'
* consolidate get_user_reply()

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-29 13:27:26 +01:00
Karel Zak
df798805c0 mountsh: support named file descriptors
Let's make it more readable:

	>>> # abc = fsopen ext4
	>>> # fsconfig $abc flag ro
	>>> # fsconfig $abc string source /dev/sdc1
	>>> # fsconfig $abc create
	>>> # mnt = fsmount $abc ro,noexec
	>>> # fds
	 3 : fscontext [$abc]
	 4 : path [$mnt]

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-29 13:02:51 +01:00
Karel Zak
457bd3e133 mountsh: make masks parsing more generic
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-28 12:55:12 +01:00
Karel Zak
372195b111 mountsh: return mount fd
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-28 12:43:13 +01:00
Karel Zak
789db6a95a mountsh: add fsmount command
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-28 12:32:18 +01:00
Karel Zak
70b20258dc mountsh: consolidate FD use
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-28 11:32:02 +01:00
Karel Zak
3ae6779e31 mountsh: add command fsconfig
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-28 11:04:58 +01:00
Karel Zak
fea47ed0c9 mountsh:add command close
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-27 13:06:26 +01:00
Karel Zak
aaab497afd mountsh: make prompt more visiable
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-27 12:52:55 +01:00
Karel Zak
c4714fb5ec mountsh: add command fds
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-27 12:37:30 +01:00
Karel Zak
29fe66e9cd lib/procutils: add funcs to read /proc/#/fd
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-27 12:37:07 +01:00
Karel Zak
445973ab71 mountsh: add new command
This is new command for low-level work with new Linux mount API. The
idea is to have something to test and debug the API.

 mountsh # fsopen ext4
 new context [3] created
 mountsh # fsconfig 3 set source /dev/sda1
 mountsh # fsconfig 3 set flag ro
 mountsh # fsconfig 3 create
 mountsh # fsmount 3 MS_NODEV
 new mount [4] created
 mountsh # move_mount 4 /mnt

Note that this commit implements almost nothing from this idea :-)

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-26 13:39:54 +01:00
6 changed files with 1069 additions and 6 deletions

1
.gitignore vendored
View file

@ -129,6 +129,7 @@ ylwrap
/more
/mount
/mountpoint
/mountsh
/namei
/newgrp
/nologin

View file

@ -1390,6 +1390,20 @@ AS_IF([test "x$build_fallocate" = xyes], [
])
AC_ARG_ENABLE([mountsh],
AS_HELP_STRING([--disable-mountsh], [do not build mountsh]),
[], [UL_DEFAULT_ENABLE([mountsh], [check])]
)
UL_BUILD_INIT([mountsh])
UL_REQUIRES_LINUX([mountsh])
UL_REQUIRES_SYSCALL_CHECK([mountsh], [UL_CHECK_SYSCALL([fsopen])], [fsopen])
UL_REQUIRES_SYSCALL_CHECK([mountsh], [UL_CHECK_SYSCALL([fsmount])], [fsmount])
UL_REQUIRES_SYSCALL_CHECK([mountsh], [UL_CHECK_SYSCALL([fsconfig])], [fsconfig])
UL_REQUIRES_SYSCALL_CHECK([mountsh], [UL_CHECK_SYSCALL([move_mount])], [move_mount])
UL_REQUIRES_SYSCALL_CHECK([mountsh], [UL_CHECK_SYSCALL([open_tree])], [open_tree])
AM_CONDITIONAL([BUILD_MOUNTSH], [test "x$build_mountsh" = xyes])
AC_ARG_ENABLE([unshare],
AS_HELP_STRING([--disable-unshare], [do not build unshare]),
[], [UL_DEFAULT_ENABLE([unshare], [check])]

View file

@ -311,23 +311,28 @@ static inline size_t ltrim_whitespace(unsigned char *str)
return len;
}
static inline void strrep(char *s, int find, int replace)
static inline char *strrep(char *s, int find, int replace)
{
char *re = s;
while (s && *s && (s = strchr(s, find)) != NULL)
*s++ = replace;
return re;
}
static inline void strrem(char *s, int rem)
static inline char *strrem(char *s, int rem)
{
char *p;
char *p, *re = s;
if (!s)
return;
return NULL;
for (p = s; *s; s++) {
if (*s != rem)
*p++ = *s;
}
*p = '\0';
return re;
}
extern char *strnappend(const char *s, const char *suffix, size_t b);

View file

@ -105,8 +105,8 @@ AC_DEFUN([UL_CHECK_SYSCALL], [
[syscall=SYS_$1],
[dnl Our libc failed use, so see if we can get the kernel
dnl headers to play ball ...
_UL_SYSCALL_CHECK_DECL([_NR_$1],
[syscall=_NR_$1],
_UL_SYSCALL_CHECK_DECL([__NR_$1],
[syscall=__NR_$1],
[
syscall=no
if test "x$linux_os" = xyes; then

View file

@ -322,6 +322,14 @@ INSTALL_EXEC_HOOKS += install-exec-hook-mount
endif # BUILD_MOUNT
###if BUILD_MOUNTSH
bin_PROGRAMS += mountsh
mountsh_SOURCES = sys-utils/mountsh.c
mountsh_LDADD = $(LDADD) libcommon.la $(READLINE_LIBS)
mountsh_CFLAGS = $(AM_CFLAGS)
###endif # BUILD_MOUNTSH
if BUILD_SWAPON
sbin_PROGRAMS += swapon swapoff
dist_man_MANS += \

1035
sys-utils/mountsh.c Normal file

File diff suppressed because it is too large Load diff