Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
6
66
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eric Vidal
66
Commits
205194e3
Commit
205194e3
authored
5 years ago
by
Eric Vidal
Browse files
Options
Downloads
Patches
Plain Diff
it build
parent
c31c3aea
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/66/66-boot.c
+33
-26
33 additions, 26 deletions
src/66/66-boot.c
src/66/66-scandir.c
+5
-15
5 additions, 15 deletions
src/66/66-scandir.c
src/include/66/constants.h
+1
-1
1 addition, 1 deletion
src/include/66/constants.h
with
39 additions
and
42 deletions
src/66/66-boot.c
+
33
−
26
View file @
205194e3
...
...
@@ -40,19 +40,18 @@ unsigned int VERBOSITY = 1 ;
static
mode_t
mask
=
SS_BOOT_UMASK
;
static
unsigned
int
rescan
=
SS_BOOT_RESCAN
;
static
char
const
*
skel
=
SS_DATA_SYSDIR
;
static
char
const
*
live
=
SS_LIVE
;
static
char
*
live
=
SS_LIVE
;
static
char
const
*
path
=
SS_BOOT_PATH
;
static
char
const
*
tree
=
SS_BOOT_TREE
;
static
char
const
*
rcinit
=
SS_DATA_SYSDIR
SS_BOOT_RCINIT
;
static
char
const
*
rcshut
=
SS_DATA_SYSDIR
SS_BOOT_RCSHUTDOWN
;
static
char
const
*
banner
=
"
\n
[Starts boot process ...]"
;
static
char
const
*
slashdev
=
0
;
static
char
const
*
envdir
=
0
;
static
char
const
*
fifo
=
0
;
static
char
const
*
log
=
0
;
static
char
const
*
cver
=
0
;
static
char
tpath
[
MAXENV
+
1
]
;
static
char
trcinit
[
MAXENV
+
1
]
;
static
char
trcshut
[
MAXENV
+
1
]
;
static
char
tlive
[
MAXENV
+
1
]
;
static
char
ttree
[
MAXENV
+
1
]
;
static
char
confile
[
MAXENV
+
1
]
;
...
...
@@ -60,6 +59,20 @@ static int fdin ;
#define USAGE "66-boot [ -h ] [ -m ] [ -s skel ] [ -l log_user ] [ -e environment ] [ -d dev ] [ -b banner ]"
static
void
sulogin
(
char
const
*
msg
,
char
const
*
arg
)
{
static
char
const
*
const
newarg
[
2
]
=
{
SS_EXTBINPREFIX
"sulogin"
,
0
}
;
fd_close
(
0
)
;
fd_close
(
1
)
;
fd_close
(
2
)
;
dup2
(
fdin
,
0
)
;
fd_close
(
fdin
)
;
open
(
"/dev/console"
,
O_WRONLY
)
;
fd_copy
(
2
,
1
)
;
if
(
*
msg
)
strerr_warnwu2sys
(
msg
,
arg
)
;
xpathexec
(
newarg
)
;
}
static
inline
void
info_help
(
void
)
{
static
char
const
*
help
=
...
...
@@ -78,20 +91,6 @@ static inline void info_help (void)
if
(
buffer_putsflush
(
buffer_1
,
help
)
<
0
)
sulogin
(
""
,
""
)
;
}
static
void
sulogin
(
char
const
*
msg
,
char
const
*
arg
)
{
static
char
const
*
const
newarg
[
2
]
=
{
SS_EXTBINPREFIX
"sulogin"
,
0
}
;
fd_close
(
0
)
;
fd_close
(
1
)
;
fd_close
(
2
)
;
dup2
(
fdin
,
0
)
;
fd_close
(
fdin
)
;
open
(
"/dev/console"
,
O_WRONLY
)
;
fd_copy
(
2
,
1
)
;
if
(
*
msg
)
strerr_warnwu2sys
(
msg
,
arg
)
;
xpathexec
(
newarg
)
;
}
static
void
parse_conf
(
void
)
{
static
char
const
*
valid
[]
=
...
...
@@ -105,7 +104,7 @@ static void parse_conf(void)
size_t
skelen
=
strlen
(
skel
)
;
memcpy
(
confile
,
skel
,
skelen
)
;
confile
[
skelen
]
=
'/'
;
mem
p
cy
(
confile
+
skelen
+
1
,
SS_BOOT_CONF
,
SS_BOOT_CONF_LEN
)
;
memc
p
y
(
confile
+
skelen
+
1
,
SS_BOOT_CONF
,
SS_BOOT_CONF_LEN
)
;
confile
[
skelen
+
1
+
SS_BOOT_CONF_LEN
]
=
0
;
size_t
filesize
=
file_get_size
(
confile
)
;
r
=
openreadfileclose
(
confile
,
&
src
,
filesize
)
;
...
...
@@ -187,13 +186,14 @@ static inline void run_cmdline(char const *const *newargv, char const *const *en
if
(
wstat
)
sulogin
(
msg
,
arg
)
;
}
static
inline
void
make_cmdline
(
char
const
*
prog
,
char
const
**
add
,
int
len
,
char
const
*
msg
,
char
const
*
arg
)
static
inline
void
make_cmdline
(
char
const
*
prog
,
char
const
**
add
,
int
len
,
char
const
*
msg
,
char
const
*
arg
,
char
const
*
const
*
envp
)
{
int
m
=
6
+
len
,
i
=
0
,
n
=
0
;
char
const
*
newargv
[
m
]
;
newargv
[
n
++
]
=
prog
;
newargv
[
n
++
]
=
"-v"
;
newargv
[
n
++
]
=
ver
bo
;
newargv
[
n
++
]
=
c
ver
;
newargv
[
n
++
]
=
"-l"
;
newargv
[
n
++
]
=
live
;
for
(;
i
<
len
;
i
++
)
...
...
@@ -208,6 +208,7 @@ int main(int argc, char const *const *argv,char const *const *envp)
size_t
bannerlen
,
livelen
;
pid_t
pid
;
char
verbo
[
UINT_FMT
]
;
cver
=
verbo
;
stralloc
envmodifs
=
STRALLOC_ZERO
;
fdin
=
dup
(
0
)
;
PROG
=
"66-boot"
;
...
...
@@ -280,17 +281,16 @@ int main(int argc, char const *const *argv,char const *const *envp)
}
/** create scandir */
{
int
m
=
log
?
4
:
2
;
if
(
log
)
char
const
*
t
[]
=
{
"-b"
,
"-c"
,
"-L"
,
log
}
;
else
char
const
*
t
[]
=
{
"-b"
,
"-c"
}
;
int
m
=
log
?
6
:
4
;
char
const
*
t
[]
=
{
"-b"
,
"-c"
,
"-s"
,
skel
,
log
?
"-L"
:
0
,
log
?
log
:
0
}
;
strerr_warni2x
(
"Create live scandir at: "
,
live
)
;
make_cmdline
(
SS_EXTBINPREFIX
"66-scandir"
,
t
,
m
,
"create live scandir at: "
,
live
)
;
make_cmdline
(
SS_EXTBINPREFIX
"66-scandir"
,
t
,
m
,
"create live scandir at: "
,
live
,
envp
)
;
}
/** initiate earlier service */
{
char
const
*
t
[]
=
{
"-t"
,
tree
,
"classic"
}
;
strerr_warni2x
(
"Initiate earlier service of tree: "
,
tree
)
;
make_cmdline
(
SS_EXTBINPREFIX
"66-init"
,
t
,
3
,
"initiate earlier service of tree: "
,
tree
)
;
make_cmdline
(
SS_EXTBINPREFIX
"66-init"
,
t
,
3
,
"initiate earlier service of tree: "
,
tree
,
envp
)
;
}
if
(
envdir
)
...
...
@@ -306,7 +306,14 @@ int main(int argc, char const *const *argv,char const *const *envp)
}
/** fork and starts scandir */
{
static
char
*
const
newargv
[
7
]
=
{
SS_EXTBINPREFIX
"66-scandir"
,
"-v"
,
verbo
,
"-l"
,
live
,
"-u"
,
0
}
;
static
char
const
*
newargv
[
7
]
;
newargv
[
0
]
=
SS_EXTBINPREFIX
"66-scandir"
;
newargv
[
1
]
=
"-v"
;
newargv
[
2
]
=
verbo
;
newargv
[
3
]
=
"-l"
;
newargv
[
4
]
=
live
;
newargv
[
5
]
=
"-u"
;
newargv
[
6
]
=
0
;
char
const
*
newenvp
[
2
]
=
{
0
,
0
}
;
size_t
pathlen
=
strlen
(
path
)
;
char
pathvar
[
6
+
pathlen
]
;
...
...
This diff is collapsed.
Click to expand it.
src/66/66-scandir.c
+
5
−
15
View file @
205194e3
...
...
@@ -60,8 +60,7 @@ static char OWNERSTR[UID_FMT] ;
static
gid_t
GIDOWNER
;
static
char
GIDSTR
[
GID_FMT
]
;
static
char
TMPENV
[
MAXENV
+
1
]
;
static
char
tskelfile
[
MAXENV
+
1
]
;
static
char
const
*
rcshut
=
SS_DATA_SYSDIR
;
static
char
const
*
skel
=
SS_DATA_SYSDIR
;
static
char
const
*
log_user
=
"root"
;
static
unsigned
int
BOOT
=
0
;
unsigned
int
VERBOSITY
=
1
;
...
...
@@ -206,7 +205,7 @@ void write_shutdownd(char const *live, char const *scandir)
SS_BINPREFIX
"66-shutdownd -l "
)
;
auto_stralloc
(
&
run
,
live
)
;
auto_stralloc
(
&
run
,
" -s "
)
;
auto_stralloc
(
&
run
,
rcshut
)
;
auto_stralloc
(
&
run
,
skel
)
;
auto_stralloc
(
&
run
,
" -g 3000
\n
"
)
;
shut
[
scandirlen
+
1
+
SS_BOOT_SHUTDOWND_LEN
]
=
0
;
auto_file
(
shut
,
"run"
,
run
.
s
,
run
.
len
)
;
...
...
@@ -482,7 +481,7 @@ int main(int argc, char const *const *argv, char const *const *envp)
if
(
!
stralloc_0
(
&
live
))
retstralloc
(
111
,
"main"
)
;
break
;
case
't'
:
if
(
!
uint0_scan
(
l
.
arg
,
&
rescan
))
break
;
case
's'
:
rcshut
=
l
.
arg
;
break
;
case
's'
:
skel
=
l
.
arg
;
break
;
case
'e'
:
if
(
!
stralloc_cats
(
&
envdir
,
l
.
arg
))
retstralloc
(
111
,
"main"
)
;
if
(
!
stralloc_0
(
&
envdir
))
retstralloc
(
111
,
"main"
)
;
break
;
...
...
@@ -517,17 +516,8 @@ int main(int argc, char const *const *argv, char const *const *envp)
if
(
r
<
0
)
strerr_dief3x
(
110
,
"scandir: "
,
scandir
.
s
,
" must be an absolute path"
)
;
if
(
!
r
)
strerr_diefu1sys
(
111
,
"set scandir directory"
)
;
if
(
BOOT
)
{
if
(
rcshut
[
0
]
!=
'/'
)
strerr_dief3x
(
110
,
"rc.shutdown: "
,
rcshut
,
" must be an absolute path"
)
;
size_t
shutlen
=
strlen
(
rcshut
)
;
memcpy
(
tskelfile
,
rcshut
,
shutlen
)
;
tskelfile
[
shutlen
]
=
'/'
;
memcpy
(
tskelfile
+
shutlen
+
1
,
SS_BOOT_RCSHUTDOWN
,
SS_BOOT_RCSHUTDOWN_LEN
)
;
tskelfile
[
shutlen
+
1
+
SS_BOOT_RCSHUTDOWN_LEN
]
=
0
;
rcshut
=
tskelfile
;
}
if
(
BOOT
&&
skel
[
0
]
!=
'/'
)
strerr_dief3x
(
110
,
"rc.shutdown: "
,
skel
,
" must be an absolute path"
)
;
if
(
envdir
.
len
)
{
...
...
This diff is collapsed.
Click to expand it.
src/include/66/constants.h
+
1
−
1
View file @
205194e3
...
...
@@ -82,7 +82,7 @@
/** boot */
#define SS_BOOT_CONF "init.conf"
#define SS_BOOT_CONF_LEN (sizeof SS_BOOTCONF - 1)
#define SS_BOOT_CONF_LEN (sizeof SS_BOOT
_
CONF - 1)
#define SS_BOOT_PATH "/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/bin"
#define SS_BOOT_PATH_LEN (sizeof SS_BOOT_PATH - 1)
#define SS_BOOT_TREE "init"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment