L4Re/departure

Annotated libe2access/host/session.c

635:18f77ccd5ea8
8 months ago Paul Boddie Updated dataspace size type usage.
paul@278 1
/*
paul@278 2
 * Session utilities.
paul@278 3
 *
paul@278 4
 * Copyright (C) 2022 Paul Boddie <paul@boddie.org.uk>
paul@278 5
 *
paul@278 6
 * This program is free software; you can redistribute it and/or
paul@278 7
 * modify it under the terms of the GNU General Public License as
paul@278 8
 * published by the Free Software Foundation; either version 2 of
paul@278 9
 * the License, or (at your option) any later version.
paul@278 10
 *
paul@278 11
 * This program is distributed in the hope that it will be useful,
paul@278 12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
paul@278 13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
paul@278 14
 * GNU General Public License for more details.
paul@278 15
 *
paul@278 16
 * You should have received a copy of the GNU General Public License
paul@278 17
 * along with this program; if not, write to the Free Software
paul@278 18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
paul@278 19
 * Boston, MA  02110-1301, USA
paul@278 20
 */
paul@278 21
paul@278 22
#include <stdio.h>
paul@278 23
#include <stdlib.h>
paul@278 24
#include <string.h>
paul@278 25
#include <unistd.h>
paul@278 26
paul@278 27
#include "session.h"
paul@278 28
paul@278 29
paul@278 30
paul@278 31
/* Alternative metadata set by options. */
paul@278 32
paul@278 33
struct metadata md;
paul@278 34
paul@278 35
paul@278 36
paul@278 37
/* Parse program options. */
paul@278 38
paul@278 39
int parse_options(int argc, char *argv[])
paul@278 40
{
paul@278 41
    int opt;
paul@278 42
paul@278 43
    md.have_uid = 0;
paul@278 44
    md.have_gid = 0;
paul@278 45
    md.mask = 0000;
paul@278 46
paul@278 47
    while ((opt = getopt(argc, argv, "g:m:u:")) != -1)
paul@278 48
    {
paul@278 49
        switch (opt)
paul@278 50
        {
paul@278 51
            case 'g':
paul@278 52
            md.gid = atoi(optarg);
paul@278 53
            md.have_gid = 1;
paul@278 54
            break;
paul@278 55
paul@278 56
            case 'm':
paul@278 57
            md.mask = strtol(optarg, NULL, 0);
paul@278 58
            break;
paul@278 59
paul@278 60
            case 'u':
paul@278 61
            md.uid = atoi(optarg);
paul@278 62
            md.have_uid = 1;
paul@278 63
            break;
paul@278 64
paul@278 65
            default:
paul@278 66
            fprintf(stderr, "Option not recognised: %s\n", argv[optind]);
paul@278 67
            return -1;
paul@278 68
        }
paul@278 69
    }
paul@278 70
paul@278 71
    return 0;
paul@278 72
}
paul@278 73
paul@278 74
/* vim: tabstop=4 expandtab shiftwidth=4
paul@278 75
*/