Add sethostname(2).
Not very useful, but helps building stuff like toybox out of the box. Change-Id: I110e39030452bd093a84278e019c5752d293718d
This commit is contained in:
parent
2ed9ee1e93
commit
b86a4c7f65
|
@ -313,6 +313,8 @@ int __set_tid_address:set_tid_address(int*) all
|
||||||
int setfsgid(gid_t) all
|
int setfsgid(gid_t) all
|
||||||
int setfsuid(uid_t) all
|
int setfsuid(uid_t) all
|
||||||
|
|
||||||
|
int sethostname(const char*, size_t) all
|
||||||
|
|
||||||
pid_t wait4(pid_t, int*, int, struct rusage*) all
|
pid_t wait4(pid_t, int*, int, struct rusage*) all
|
||||||
int __waitid:waitid(int, pid_t, struct siginfo_t*, int, void*) all
|
int __waitid:waitid(int, pid_t, struct siginfo_t*, int, void*) all
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
/* Generated by gensyscalls.py. Do not edit. */
|
||||||
|
|
||||||
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
|
ENTRY(sethostname)
|
||||||
|
mov ip, r7
|
||||||
|
ldr r7, =__NR_sethostname
|
||||||
|
swi #0
|
||||||
|
mov r7, ip
|
||||||
|
cmn r0, #(MAX_ERRNO + 1)
|
||||||
|
bxls lr
|
||||||
|
neg r0, r0
|
||||||
|
b __set_errno_internal
|
||||||
|
END(sethostname)
|
|
@ -0,0 +1,14 @@
|
||||||
|
/* Generated by gensyscalls.py. Do not edit. */
|
||||||
|
|
||||||
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
|
ENTRY(sethostname)
|
||||||
|
mov x8, __NR_sethostname
|
||||||
|
svc #0
|
||||||
|
|
||||||
|
cmn x0, #(MAX_ERRNO + 1)
|
||||||
|
cneg x0, x0, hi
|
||||||
|
b.hi __set_errno_internal
|
||||||
|
|
||||||
|
ret
|
||||||
|
END(sethostname)
|
|
@ -0,0 +1,19 @@
|
||||||
|
/* Generated by gensyscalls.py. Do not edit. */
|
||||||
|
|
||||||
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
|
ENTRY(sethostname)
|
||||||
|
.set noreorder
|
||||||
|
.cpload t9
|
||||||
|
li v0, __NR_sethostname
|
||||||
|
syscall
|
||||||
|
bnez a3, 1f
|
||||||
|
move a0, v0
|
||||||
|
j ra
|
||||||
|
nop
|
||||||
|
1:
|
||||||
|
la t9,__set_errno_internal
|
||||||
|
j t9
|
||||||
|
nop
|
||||||
|
.set reorder
|
||||||
|
END(sethostname)
|
|
@ -0,0 +1,25 @@
|
||||||
|
/* Generated by gensyscalls.py. Do not edit. */
|
||||||
|
|
||||||
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
|
ENTRY(sethostname)
|
||||||
|
.set push
|
||||||
|
.set noreorder
|
||||||
|
li v0, __NR_sethostname
|
||||||
|
syscall
|
||||||
|
bnez a3, 1f
|
||||||
|
move a0, v0
|
||||||
|
j ra
|
||||||
|
nop
|
||||||
|
1:
|
||||||
|
move t0, ra
|
||||||
|
bal 2f
|
||||||
|
nop
|
||||||
|
2:
|
||||||
|
.cpsetup ra, t1, 2b
|
||||||
|
LA t9,__set_errno_internal
|
||||||
|
.cpreturn
|
||||||
|
j t9
|
||||||
|
move ra, t0
|
||||||
|
.set pop
|
||||||
|
END(sethostname)
|
|
@ -0,0 +1,26 @@
|
||||||
|
/* Generated by gensyscalls.py. Do not edit. */
|
||||||
|
|
||||||
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
|
ENTRY(sethostname)
|
||||||
|
pushl %ebx
|
||||||
|
.cfi_def_cfa_offset 8
|
||||||
|
.cfi_rel_offset ebx, 0
|
||||||
|
pushl %ecx
|
||||||
|
.cfi_adjust_cfa_offset 4
|
||||||
|
.cfi_rel_offset ecx, 0
|
||||||
|
mov 12(%esp), %ebx
|
||||||
|
mov 16(%esp), %ecx
|
||||||
|
movl $__NR_sethostname, %eax
|
||||||
|
int $0x80
|
||||||
|
cmpl $-MAX_ERRNO, %eax
|
||||||
|
jb 1f
|
||||||
|
negl %eax
|
||||||
|
pushl %eax
|
||||||
|
call __set_errno_internal
|
||||||
|
addl $4, %esp
|
||||||
|
1:
|
||||||
|
popl %ecx
|
||||||
|
popl %ebx
|
||||||
|
ret
|
||||||
|
END(sethostname)
|
|
@ -0,0 +1,15 @@
|
||||||
|
/* Generated by gensyscalls.py. Do not edit. */
|
||||||
|
|
||||||
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
|
ENTRY(sethostname)
|
||||||
|
movl $__NR_sethostname, %eax
|
||||||
|
syscall
|
||||||
|
cmpq $-MAX_ERRNO, %rax
|
||||||
|
jb 1f
|
||||||
|
negl %eax
|
||||||
|
movl %eax, %edi
|
||||||
|
call __set_errno_internal
|
||||||
|
1:
|
||||||
|
ret
|
||||||
|
END(sethostname)
|
|
@ -183,7 +183,8 @@ extern unsigned int alarm(unsigned int);
|
||||||
extern unsigned int sleep(unsigned int);
|
extern unsigned int sleep(unsigned int);
|
||||||
extern int usleep(useconds_t);
|
extern int usleep(useconds_t);
|
||||||
|
|
||||||
extern int gethostname(char *, size_t);
|
int gethostname(char*, size_t);
|
||||||
|
int sethostname(const char*, size_t);
|
||||||
|
|
||||||
extern void *__brk(void *);
|
extern void *__brk(void *);
|
||||||
extern int brk(void *);
|
extern int brk(void *);
|
||||||
|
|
|
@ -470,3 +470,11 @@ class unistd_DeathTest : public BionicDeathTest {};
|
||||||
TEST_F(unistd_DeathTest, abort) {
|
TEST_F(unistd_DeathTest, abort) {
|
||||||
ASSERT_EXIT(abort(), testing::KilledBySignal(SIGABRT), "");
|
ASSERT_EXIT(abort(), testing::KilledBySignal(SIGABRT), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(unistd, sethostname) {
|
||||||
|
// The permissions check happens before the argument check, so this will
|
||||||
|
// fail for a different reason if you're running as root than if you're
|
||||||
|
// not, but it'll fail either way. Checking that we have the symbol is about
|
||||||
|
// all we can do for sethostname(2).
|
||||||
|
ASSERT_EQ(-1, sethostname("", -1));
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue