<commit_before>/*
 * nschroot - chroot into a fresh Linux namespace
 * Copyright 2011, <NAME> <<EMAIL>>
 * https://github.com/tobert/nslite
 * 
 * This is free software; you can redistribute it and/or modify it under the
 * terms of the Artistic License 2.0.  See the file LICENSE for details.
 */

#include "nsfork.h"
#include <err.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>

static void usage(char *program)
{
    printf("%s: chroot into a new Linux namespace.\n\n", program);
    printf("Usage:\n");
    printf("  %s <chroot path> <executable> [executable args]\n", program);
    exit(1);
}

int main(int argc, char *argv[])
{
    struct stat sb;
    pid_t child;
    int i, status;
    char *program, *newroot, *command;
    char *newenv[] = { NULL };
    char **newargv;

    if (argc < 3)
        usage(argv[0]);

    program = argv[0];
    newroot = argv[1];
    command = argv[2];

    if (stat(newroot, &sb) == -1)
        err(1, "'%s'", newroot);

    if ((sb.st_mode & S_IFMT) != S_IFDIR)
        errx(1, "stat(): '%s' is not a directory\n", newroot);
    
    newargv = malloc(sizeof(argv));
    for (i=2; i<=argc; i++) {
        newargv[i-2] = argv[i];
    }
    newargv[i] = "\0";

    child = nsfork(0);<commit_msg>Adjust headers, adjust for c99.<commit_after>/*
 * nschroot - chroot into a fresh Linux namespace
 * Copyright 2011, <NAME> <<EMAIL>>
 * https://github.com/tobert/nslite
 * 
 * This is free software; you can redistribute it and/or modify it under the
 * terms of the Artistic License 2.0.  See the file LICENSE for details.
 */

#include "config.h"

#include <err.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>

#include "nsfork.h"

static void usage(char *program)
{
    printf("%s: chroot into a new Linux namespace.\n\n", program);
    printf("Usage:\n");
    printf("  %s <chroot path> <executable> [executable args]\n", program);
    exit(1);
}

int main(int argc, char *argv[])
{
    struct stat sb;
    pid_t child;
    int i, status;
    char *program, *newroot, *command;
    char *newenv[] = { NULL };
    char **newargv;

    if (argc < 3)
        usage(argv[0]);

    program = argv[0];
    newroot = argv[1];
    command = argv[2];

    if (stat(newroot, &sb) == -1)
        err(1, "'%s'", newroot);

    if (S_ISDIR(sb.st_mode))
        errx(1, "stat(): '%s' is not a directory\n", newroot);
    
    newargv = malloc(sizeof(argv));
    for (i=2; i<=argc; i++) {
        newargv[i-2] = argv[i];
    }
    newargv[i] = "\0";

    child = nsfork(0);
{'fraction_non_alphanumeric': 0.1741256111320045, 'fraction_numerical': 0.01504324934185784, 'mean_word_length': 2.906020558002937, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 27, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '700658', 'n_tokens_mistral': 1008, 'n_tokens_neox': 978, 'n_words': 281}