VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxFsDxe/test/fsw_posix.h

Last change on this file was 69612, checked in by vboxsync, 7 years ago

Touched up test code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
1/**
2 * \file fsw_posix.h
3 * POSIX user space host environment header.
4 */
5
6/*-
7 * Copyright (c) 2006 Christoph Pfisterer
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are
11 * met:
12 *
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the
19 * distribution.
20 *
21 * * Neither the name of Christoph Pfisterer nor the names of the
22 * contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef _FSW_POSIX_H_
39#define _FSW_POSIX_H_
40
41#include "fsw_core.h"
42
43#include <fcntl.h>
44#include <sys/types.h>
45
46
47/**
48 * POSIX Host: Private per-volume structure.
49 */
50
51struct fsw_posix_volume {
52 struct fsw_volume *vol; //!< FSW volume structure
53
54 int fd; //!< System file descriptor for data access
55
56};
57
58/**
59 * POSIX Host: Private structure for an open file.
60 */
61
62struct fsw_posix_file {
63 struct fsw_posix_volume *pvol; //!< POSIX host volume structure
64
65 struct fsw_shandle shand; //!< FSW handle for this file
66
67};
68
69/**
70 * POSIX Host: Private structure for an open directory.
71 */
72
73struct fsw_posix_dir {
74 struct fsw_posix_volume *pvol; //!< POSIX host volume structure
75
76 struct fsw_shandle shand; //!< FSW handle for this file
77
78};
79
80
81#define NAME_MAX 4096
82
83#define DT_UNKNOWN 'u'
84#define DT_REG 'r'
85#define DT_DIR 'd'
86#define DT_LNK 'l'
87
88
89/**
90 * POSIX Host: Private structure for an open directory.
91 */
92
93struct fsw_posix_dirent {
94 char d_attr; /* file's attribute */
95 unsigned d_type;
96 unsigned short int d_time; /* file's time */
97 unsigned short int d_date; /* file's date */
98 long d_size; /* file's size */
99 char d_name[NAME_MAX+1]; /* file's name */
100 unsigned d_fileno; /* file number/inode */
101};
102typedef struct fsw_posix_dirent DIR;
103
104/* functions */
105
106struct fsw_posix_volume * fsw_posix_mount(const char *path, struct fsw_fstype_table *fstype_table);
107int fsw_posix_unmount(struct fsw_posix_volume *pvol);
108
109struct fsw_posix_file * fsw_posix_open(struct fsw_posix_volume *pvol, const char *path, int flags, mode_t mode);
110ssize_t fsw_posix_read(struct fsw_posix_file *file, void *buf, size_t nbytes);
111off_t fsw_posix_lseek(struct fsw_posix_file *file, off_t offset, int whence);
112int fsw_posix_close(struct fsw_posix_file *file);
113
114struct fsw_posix_dir * fsw_posix_opendir(struct fsw_posix_volume *pvol, const char *path);
115struct fsw_posix_dirent * fsw_posix_readdir(struct fsw_posix_dir *dir);
116void fsw_posix_rewinddir(struct fsw_posix_dir *dir);
117int fsw_posix_closedir(struct fsw_posix_dir *dir);
118
119
120#endif
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use