Changeset 368ee04 in mainline for uspace/lib/c/include


Ignore:
Timestamp:
2017-04-05T18:10:39Z (9 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
93ad8166
Parents:
39f892a9 (diff), 2166728 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from lp:~jakub/helenos/vfs-2.5-cherrypick

This merge cherry-picks some of the changesets from Jiri Zarevucky's:

lp:~zarevucky-jiri/helenos/vfs-2.5

and then continues independently, yet sometime in a similar vein.

Roughly speaking, Jiri's branch is merged entirely up to its revision
1926 and then cherry-picked on and off until its revision 1965. Among
these changes are:

  • relativization of the API,
  • client-side roots,
  • server-side mounts,
  • inbox for passing arbitrary files from parent to child,
  • some streamlining and cleanup.

Additional changes include:

  • addressing issues introduced by the above changes,
  • client-side I/O cursors (file positions),
  • all HelenOS file system APIs begin with the vfs_ prefix and can be used after including vfs/vfs.h,
  • removal of some POSIX-ish headers and definitions,
  • additional cleanup.
Location:
uspace/lib/c/include
Files:
1 deleted
16 edited
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/dirent.h

    r39f892a9 r368ee04  
    3838#define NAME_MAX  256
    3939
     40#include <sys/types.h>
     41
    4042struct dirent {
    4143        char d_name[NAME_MAX + 1];
     
    4547        int fd;
    4648        struct dirent res;
     49        aoff64_t pos;
    4750} DIR;
    4851
  • uspace/lib/c/include/elf/elf_load.h

    r39f892a9 r368ee04  
    4545} elf_info_t;
    4646
    47 extern int elf_load(const char *, elf_info_t *);
     47extern int elf_load(int, elf_info_t *);
    4848extern void elf_set_pcb(elf_info_t *, pcb_t *);
    4949
  • uspace/lib/c/include/elf/elf_mod.h

    r39f892a9 r368ee04  
    108108
    109109extern const char *elf_error(unsigned int);
    110 extern int elf_load_file(const char *, size_t, eld_flags_t, elf_finfo_t *);
     110extern int elf_load_file(int, size_t, eld_flags_t, elf_finfo_t *);
     111extern int elf_load_file_name(const char *, size_t, eld_flags_t, elf_finfo_t *);
    111112
    112113#endif
  • uspace/lib/c/include/io/logctl.h

    r39f892a9 r368ee04  
    3838extern int logctl_set_default_level(log_level_t);
    3939extern int logctl_set_log_level(const char *, log_level_t);
     40extern int logctl_set_root(void);
    4041
    4142#endif
  • uspace/lib/c/include/ipc/loader.h

    r39f892a9 r368ee04  
    4242        LOADER_GET_TASKID,
    4343        LOADER_SET_CWD,
    44         LOADER_SET_PATHNAME,
     44        LOADER_SET_PROGRAM,
    4545        LOADER_SET_ARGS,
    46         LOADER_SET_FILES,
     46        LOADER_ADD_INBOX,
    4747        LOADER_LOAD,
    4848        LOADER_RUN
  • uspace/lib/c/include/ipc/logger.h

    r39f892a9 r368ee04  
    4949         * Followed by: string with full log name.
    5050         */
    51         LOGGER_CONTROL_SET_LOG_LEVEL
     51        LOGGER_CONTROL_SET_LOG_LEVEL,
     52        /** Set VFS root.
     53         *
     54         * Returns: error code
     55         * Followed by: vfs_pass_handle() request.
     56         */
     57        LOGGER_CONTROL_SET_ROOT
    5258} logger_control_request_t;
    5359
  • uspace/lib/c/include/ipc/vfs.h

    r39f892a9 r368ee04  
    4141
    4242#define FS_NAME_MAXLEN  20
    43 #define MAX_PATH_LEN    (64 * 1024)
     43#define MAX_PATH_LEN    (32 * 1024)
    4444#define MAX_MNTOPTS_LEN 256
    4545#define PLB_SIZE        (2 * MAX_PATH_LEN)
     
    6363
    6464typedef enum {
    65         VFS_IN_OPEN = IPC_FIRST_USER_METHOD,
     65        VFS_IN_CLONE = IPC_FIRST_USER_METHOD,
     66        VFS_IN_MOUNT,
     67        VFS_IN_OPEN,
     68        VFS_IN_PUT,
    6669        VFS_IN_READ,
     70        VFS_IN_REGISTER,
     71        VFS_IN_RENAME,
     72        VFS_IN_RESIZE,
     73        VFS_IN_STAT,
     74        VFS_IN_STATFS,
     75        VFS_IN_SYNC,
     76        VFS_IN_UNLINK,
     77        VFS_IN_UNMOUNT,
     78        VFS_IN_WAIT_HANDLE,
     79        VFS_IN_WALK,
    6780        VFS_IN_WRITE,
    68         VFS_IN_SEEK,
    69         VFS_IN_TRUNCATE,
    70         VFS_IN_FSTAT,
    71         VFS_IN_CLOSE,
    72         VFS_IN_PING,
    73         VFS_IN_MOUNT,
    74         VFS_IN_UNMOUNT,
    75         VFS_IN_SYNC,
    76         VFS_IN_REGISTER,
    77         VFS_IN_MKDIR,
    78         VFS_IN_UNLINK,
    79         VFS_IN_RENAME,
    80         VFS_IN_STAT,
    81         VFS_IN_DUP,
    82         VFS_IN_WAIT_HANDLE,
    83         VFS_IN_MTAB_GET,
    84         VFS_IN_STATFS
    8581} vfs_in_request_t;
    8682
    8783typedef enum {
    88         VFS_OUT_OPEN_NODE = IPC_FIRST_USER_METHOD,
     84        VFS_OUT_CLOSE = IPC_FIRST_USER_METHOD,
     85        VFS_OUT_DESTROY,
     86        VFS_OUT_IS_EMPTY,
     87        VFS_OUT_LINK,
     88        VFS_OUT_LOOKUP,
     89        VFS_OUT_MOUNTED,
     90        VFS_OUT_OPEN_NODE,
    8991        VFS_OUT_READ,
     92        VFS_OUT_STAT,
     93        VFS_OUT_STATFS,
     94        VFS_OUT_SYNC,
     95        VFS_OUT_TRUNCATE,
     96        VFS_OUT_UNMOUNTED,
    9097        VFS_OUT_WRITE,
    91         VFS_OUT_TRUNCATE,
    92         VFS_OUT_CLOSE,
    93         VFS_OUT_MOUNT,
    94         VFS_OUT_MOUNTED,
    95         VFS_OUT_UNMOUNT,
    96         VFS_OUT_UNMOUNTED,
    97         VFS_OUT_SYNC,
    98         VFS_OUT_STAT,
    99         VFS_OUT_LOOKUP,
    100         VFS_OUT_DESTROY,
    101         VFS_OUT_STATFS,
    10298        VFS_OUT_LAST
    10399} vfs_out_request_t;
     
    127123
    128124/**
    129  * Lookup will succeed only if the object is a root directory. The flag is
    130  * mutually exclusive with L_FILE and L_MP.
     125 * Lookup will not cross any mount points.
     126 * If the lookup would have to cross a mount point, it returns EXDEV instead.
    131127 */
    132 #define L_ROOT                  4
     128#define L_DISABLE_MOUNTS        4
    133129
    134130/**
    135131 * Lookup will succeed only if the object is a mount point. The flag is mutually
    136  * exclusive with L_FILE and L_ROOT.
     132 * exclusive with L_FILE.
    137133 */
    138134#define L_MP                    8
     
    151147
    152148/**
    153  * L_LINK is used for linking to an already existing nodes.
    154  */
    155 #define L_LINK                  64
    156 
    157 /**
    158149 * L_UNLINK is used to remove leaves from the file system namespace. This flag
    159150 * cannot be passed directly by the client, but will be set by VFS during
    160151 * VFS_UNLINK.
    161152 */
    162 #define L_UNLINK                128
     153#define L_UNLINK                64
    163154
    164 /**
    165  * L_OPEN is used to indicate that the lookup operation is a part of VFS_IN_OPEN
    166  * call from the client. This means that the server might allocate some
    167  * resources for the opened file. This flag cannot be passed directly by the
    168  * client.
     155/*
     156 * Walk flags.
    169157 */
    170 #define L_OPEN                  256
     158enum {
     159        WALK_MAY_CREATE = (1 << 0),
     160        WALK_MUST_CREATE = (1 << 1),
     161       
     162        WALK_REGULAR = (1 << 2),
     163        WALK_DIRECTORY = (1 << 3),
     164        WALK_MOUNT_POINT = (1 << 4),
     165       
     166        WALK_ALL_FLAGS = WALK_MAY_CREATE | WALK_MUST_CREATE | WALK_REGULAR |
     167            WALK_DIRECTORY | WALK_MOUNT_POINT,
     168};
     169
     170enum {
     171        VFS_MOUNT_BLOCKING = 1,
     172        VFS_MOUNT_CONNECT_ONLY = 2,
     173        VFS_MOUNT_NO_REF = 4,
     174};
     175
     176enum {
     177        MODE_READ = 1,
     178        MODE_WRITE = 2,
     179        MODE_APPEND = 4,
     180};
    171181
    172182#endif
  • uspace/lib/c/include/loader/loader.h

    r39f892a9 r368ee04  
    4747extern int loader_get_task_id(loader_t *, task_id_t *);
    4848extern int loader_set_cwd(loader_t *);
    49 extern int loader_set_pathname(loader_t *, const char *);
     49extern int loader_set_program(loader_t *, const char *, int);
     50extern int loader_set_program_path(loader_t *, const char *);
    5051extern int loader_set_args(loader_t *, const char *const[]);
    51 extern int loader_set_files(loader_t *, int *const[]);
     52extern int loader_add_inbox(loader_t *, const char *, int);
    5253extern int loader_load_program(loader_t *);
    5354extern int loader_run(loader_t *);
  • uspace/lib/c/include/loader/pcb.h

    r39f892a9 r368ee04  
    4141typedef void (*entry_point_t)(void);
    4242
     43struct pcb_inbox_entry {
     44        char *name;
     45        int file;
     46};
     47
    4348/** Program Control Block.
    4449 *
     
    6065        char **argv;
    6166       
    62         /** Number of preset files. */
    63         unsigned int filc;
     67        /** List of inbox files. */
     68        struct pcb_inbox_entry *inbox;
     69        int inbox_entries;
    6470       
    6571        /*
  • uspace/lib/c/include/stdio.h

    r39f892a9 r368ee04  
    4444#define EOF  (-1)
    4545
    46 /** Default size for stream I/O buffers */
    47 #define BUFSIZ  4096
    48 
    49 #define DEBUG(fmt, ...) \
    50         { \
    51                 char _buf[256]; \
    52                 int _n = snprintf(_buf, sizeof(_buf), fmt, ##__VA_ARGS__); \
    53                 if (_n > 0) \
    54                         (void) __SYSCALL3(SYS_KIO, KIO_WRITE, (sysarg_t) _buf, str_size(_buf)); \
    55         }
    56 
    5746#ifndef SEEK_SET
    5847        #define SEEK_SET  0
     
    6655        #define SEEK_END  2
    6756#endif
     57
     58/** Default size for stream I/O buffers */
     59#define BUFSIZ  4096
     60
     61#define DEBUG(fmt, ...) \
     62        { \
     63                char _buf[256]; \
     64                int _n = snprintf(_buf, sizeof(_buf), fmt, ##__VA_ARGS__); \
     65                if (_n > 0) \
     66                        (void) __SYSCALL3(SYS_KIO, KIO_WRITE, (sysarg_t) _buf, str_size(_buf)); \
     67        }
    6868
    6969enum _buffer_type {
     
    153153extern void setbuf(FILE *, void *);
    154154
    155 /* Misc file functions */
    156 extern int rename(const char *, const char *);
    157 extern int remove(const char *);
    158 
    159155#endif
    160156
  • uspace/lib/c/include/stdlib.h

    r39f892a9 r368ee04  
    4949
    5050extern void abort(void) __attribute__((noreturn));
     51extern void exit(int) __attribute__((noreturn));
    5152
    5253#endif
  • uspace/lib/c/include/sys/types.h

    r39f892a9 r368ee04  
    3838#include <libarch/types.h>
    3939
    40 typedef unsigned int mode_t;
    41 
    4240/** Relative offset */
    4341typedef int64_t off64_t;
  • uspace/lib/c/include/task.h

    r39f892a9 r368ee04  
    5757    const char *const []);
    5858extern int task_spawnvf(task_id_t *, task_wait_t *, const char *path,
    59     const char *const [], int *const []);
     59    const char *const [], int, int, int);
    6060extern int task_spawn(task_id_t *, task_wait_t *, const char *path, int,
    6161    va_list ap);
  • uspace/lib/c/include/unistd.h

    r39f892a9 r368ee04  
    4444#endif
    4545
    46 #ifndef SEEK_SET
    47         #define SEEK_SET  0
    48 #endif
    49 
    50 #ifndef SEEK_CUR
    51         #define SEEK_CUR  1
    52 #endif
    53 
    54 #ifndef SEEK_END
    55         #define SEEK_END  2
    56 #endif
    57 
    5846#define getpagesize()  (PAGE_SIZE)
    5947
    60 extern int dup2(int, int);
    61 
    62 extern ssize_t write(int, const void *, size_t);
    63 extern ssize_t read(int, void *, size_t);
    64 
    65 extern off64_t lseek(int, off64_t, int);
    66 extern int ftruncate(int, aoff64_t);
    67 
    68 extern int close(int);
    69 extern int fsync(int);
    70 extern int unlink(const char *);
    71 
    72 extern char *getcwd(char *, size_t);
    73 extern int rmdir(const char *);
    74 extern int chdir(const char *);
    75 
    76 extern void exit(int) __attribute__((noreturn));
    7748extern int usleep(useconds_t);
    7849extern unsigned int sleep(unsigned int);
  • uspace/lib/c/include/vfs/inbox.h

    r39f892a9 r368ee04  
    11/*
    2  * Copyright (c) 2007 Jakub Jermar
     2 * Copyright (c) 2013 Jiri Zarevucky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libc
     29/** @addtogroup libc 
    3030 * @{
    31  */
    32 /** @file
     31 */
     32
     33/**
     34 * @file
     35 * @brief
    3336 */
    3437
    35 #ifndef LIBC_FCNTL_H_
    36 #define LIBC_FCNTL_H_
     38#ifndef LIBC_VFS_INBOX_H_
     39#define LIBC_VFS_INBOX_H_
    3740
    38 #define O_CREAT   1
    39 #define O_EXCL    2
    40 #define O_TRUNC   4
    41 #define O_APPEND  8
    42 #define O_RDONLY  16
    43 #define O_RDWR    32
    44 #define O_WRONLY  64
    45 #define O_DESC    128
     41enum {
     42        INBOX_MAX_ENTRIES = 256,
     43};
    4644
    47 extern int open(const char *, int, ...);
     45extern int inbox_set(const char *name, int file);
     46extern int inbox_get(const char *name);
     47
     48extern int inbox_list(const char **names, int capacity);
    4849
    4950#endif
    5051
    51 /** @}
     52/**
     53 * @}
    5254 */
  • uspace/lib/c/include/vfs/vfs.h

    r39f892a9 r368ee04  
    4242#include <stdio.h>
    4343#include <async.h>
    44 #include "vfs_mtab.h"
    4544
     45#define MAX_OPEN_FILES  128
    4646
    4747enum vfs_change_state_type {
     
    4949};
    5050
     51typedef enum {
     52        KIND_FILE,
     53        KIND_DIRECTORY,
     54} vfs_file_kind_t;
    5155
    52 extern char *vfs_absolutize(const char *, size_t *);
    5356
    54 extern int vfs_mount(const char *, const char *, const char *, const char *,
    55     unsigned int, unsigned int);
    56 extern int vfs_unmount(const char *);
     57struct stat {
     58        fs_handle_t fs_handle;
     59        service_id_t service_id;
     60        fs_index_t index;
     61        unsigned int lnkcnt;
     62        bool is_file;
     63        bool is_directory;
     64        aoff64_t size;
     65        service_id_t service;
     66};
     67
     68struct statfs {
     69        char fs_name[FS_NAME_MAXLEN + 1];
     70        uint32_t f_bsize;    /* fundamental file system block size */
     71        uint64_t f_blocks;   /* total data blocks in file system */
     72        uint64_t f_bfree;    /* free blocks in fs */
     73};
    5774
    5875extern int vfs_fhandle(FILE *, int *);
    5976
    60 extern int vfs_fd_wait(void);
    61 extern int vfs_get_mtab_list(list_t *mtab_list);
    62 
     77extern char *vfs_absolutize(const char *, size_t *);
     78extern int vfs_clone(int, int, bool);
     79extern int vfs_cwd_get(char *path, size_t);
     80extern int vfs_cwd_set(const char *path);
    6381extern async_exch_t *vfs_exchange_begin(void);
    6482extern void vfs_exchange_end(async_exch_t *);
     83extern int vfs_link(int, const char *, vfs_file_kind_t, int *);
     84extern int vfs_link_path(const char *, vfs_file_kind_t, int *);
     85extern int vfs_lookup(const char *, int);
     86extern int vfs_lookup_open(const char *, int, int);
     87extern int vfs_mount_path(const char *, const char *, const char *,
     88    const char *, unsigned int, unsigned int);
     89extern int vfs_mount(int, const char *, service_id_t, const char *, unsigned,
     90    unsigned, int *);
     91extern int vfs_open(int, int);
     92extern int vfs_pass_handle(async_exch_t *, int, async_exch_t *);
     93extern int vfs_put(int);
     94extern ssize_t vfs_read(int, aoff64_t *, void *, size_t);
     95extern int vfs_read_short(int, aoff64_t, void *, size_t, ssize_t *);
     96extern int vfs_receive_handle(bool);
     97extern int vfs_rename_path(const char *, const char *);
     98extern int vfs_resize(int, aoff64_t);
     99extern int vfs_root(void);
     100extern void vfs_root_set(int);
     101extern int vfs_stat(int, struct stat *);
     102extern int vfs_stat_path(const char *, struct stat *);
     103extern int vfs_statfs(int, struct statfs *);
     104extern int vfs_statfs_path(const char *, struct statfs *);
     105extern int vfs_sync(int);
     106extern int vfs_unlink(int, const char *, int);
     107extern int vfs_unlink_path(const char *);
     108extern int vfs_unmount(int);
     109extern int vfs_unmount_path(const char *);
     110extern int vfs_walk(int, const char *, int);
     111extern ssize_t vfs_write(int, aoff64_t *, const void *, size_t);
     112extern int vfs_write_short(int, aoff64_t, const void *, size_t, ssize_t *);
    65113
    66114#endif
  • uspace/lib/c/include/vfs/vfs_mtab.h

    r39f892a9 r368ee04  
    4343        link_t link;
    4444        char mp[MAX_PATH_LEN];
    45         char opts[MAX_MNTOPTS_LEN];
    4645        char fs_name[FS_NAME_MAXLEN];
    47         unsigned int instance;
    4846        service_id_t service_id;
    4947} mtab_ent_t;
     48
     49extern int vfs_get_mtab_list(list_t *);
    5050
    5151#endif
Note: See TracChangeset for help on using the changeset viewer.