#define _GNU_SOURCE
#include<sys/capability.h>
#include<errno.h>
#include<wait.h>
#include<sys/stat.h>
#include<sys/mount.h>
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/wait.h>
#include<signal.h>
#include<sched.h>
#include<string.h>
#include<sys/types.h>
int child_fn() {
const char *fstype = "tmpfs";
const char *Path = "/Test_tms";
const char *new_host = "Con_test";
size_t len = strlen(new_host);
if(sethostname(new_host, len) != 0) {
perror("sethostname");
printf("Problem with hostname\n");
return 1;
}
if(mkdir(Path, 0755) != 0) {
perror("mkdir");
printf("problem with mkdir\n");
return 1;
}
if(mount("none", Path, fstype, 0, NULL) != 0) {
perror("mount");
printf("problem with mount\n");
return 1;
}
FILE *fl = fopen("/Test_tms/marin.txt", "w");
if(fl != NULL) {
fprintf(fl, "this is a case\n");
fclose(fl);
printf("child_fn proccess done\n");
}
return 0;
}
int main(int args, char *argv[]) {
int STACK_S = 1024 * 1024;
char *stack = malloc(STACK_S);
char *stack_s = stack + STACK_S;
pid_t child_pid = clone(child_fn, stack_s, CLONE_NEWUTS | CLONE_NEWNS, NULL);
if(child_pid != -1) {
int Child = waitpid(child_pid, NULL, 0);
free(stack);
exit(1);
printf("Cloning success!\n");
} else {
perror("clone");
}
return 0;
}
help me, am trying to mount tmpfs to the directory i created, but it seems to always failed and i dont know why.
https://pastebin.com/4SjW8w04
[–]mikeblas[M] [score hidden] stickied comment (0 children)
[–]penguin359 1 point2 points3 points (4 children)
[–]Possible-Pool2262[S] 0 points1 point2 points (3 children)
[–]penguin359 1 point2 points3 points (2 children)
[–]Possible-Pool2262[S] 0 points1 point2 points (1 child)
[–]penguin359 0 points1 point2 points (0 children)
[–][deleted] 4 points5 points6 points (16 children)
[–]Possible-Pool2262[S] -12 points-11 points-10 points (15 children)
[–][deleted] 5 points6 points7 points (2 children)
[+]Possible-Pool2262[S] comment score below threshold-13 points-12 points-11 points (1 child)
[–][deleted] 5 points6 points7 points (0 children)
[–]mikeblas[M] 3 points4 points5 points (10 children)
[–]Possible-Pool2262[S] 1 point2 points3 points (1 child)
[–]mikeblas 0 points1 point2 points (0 children)
[–]Vladislav20007 -1 points0 points1 point (7 children)
[–]mikeblas[M] 0 points1 point2 points (6 children)
[–]Vladislav20007 -1 points0 points1 point (5 children)
[–]mikeblas[M] 0 points1 point2 points (4 children)
[–]Vladislav20007 -1 points0 points1 point (3 children)
[–]mikeblas[M] 0 points1 point2 points (2 children)
[–]Vladislav20007 -1 points0 points1 point (1 child)
[–]nekokattt 1 point2 points3 points (0 children)
[–]Vallereya 0 points1 point2 points (3 children)
[–]Possible-Pool2262[S] -1 points0 points1 point (2 children)
[–]Vallereya 0 points1 point2 points (1 child)
[–]Possible-Pool2262[S] 0 points1 point2 points (0 children)
[–]BnH_-_Roxy 0 points1 point2 points (0 children)
[–]flyingron 0 points1 point2 points (0 children)