VirtualBox

source: kBuild/trunk/src/kash/shfile.h@ 1208

Last change on this file since 1208 was 1207, checked in by bird, 17 years ago

jobs and other stuff.

File size: 3.5 KB
Line 
1/* $Id: $ */
2/** @file
3 *
4 * File management.
5 *
6 * Copyright (c) 2007 knut st. osmundsen <[email protected]>
7 *
8 *
9 * This file is part of kBuild.
10 *
11 * kBuild is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * kBuild is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with kBuild; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27#ifndef ___shfile_h___
28#define ___shfile_h___
29
30#include "shtypes.h"
31#include <fcntl.h>
32#include <sys/stat.h>
33#ifndef _MSC_VER
34# include <sys/fcntl.h>
35# include <unistd.h>
36# ifndef O_BINARY
37# define O_BINARY 0
38# endif
39# ifndef O_TEXT
40# define O_TEXT 0
41# endif
42
43#else
44# include <io.h>
45# include <direct.h>
46
47# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
48# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
49# define S_ISLNK(m) 0
50# define S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
51# define S_IXUSR _S_IEXEC
52# define S_IWUSR _S_IWRITE
53# define S_IRUSR _S_IREAD
54# define S_IRWXG 0000070
55# define S_IRGRP 0000040
56# define S_IWGRP 0000020
57# define S_IXGRP 0000010
58# define S_IRWXO 0000007
59# define S_IROTH 0000004
60# define S_IWOTH 0000002
61# define S_IXOTH 0000001
62# define S_ISUID 0004000
63# define S_ISGID 0002000
64# define ALLPERMS 0000777
65
66# define F_DUPFD 0
67# define F_GETFD 1
68# define F_SETFD 2
69# define F_GETFL 3
70# define F_SETFL 4
71# define FD_CLOEXEC 1
72
73# define F_OK 0
74# define X_OK 1
75# define W_OK 2
76# define R_OK 4
77
78#endif
79
80
81/**
82 * One file.
83 */
84typedef struct shfile
85{
86 int fd; /**< The shell file descriptor number. */
87 int flags; /**< Open flags. */
88 intptr_t native; /**< The native file descriptor number. */
89} shfile;
90
91/**
92 * The file descriptor table for a shell.
93 */
94typedef struct shfdtab
95{
96 shmtx mtx; /**< Mutex protecting any operations on the table and it's handles. */
97 char *cwd; /**< The current directory for this shell instance. */
98 unsigned size; /**< The size of the table (number of entries). */
99 shfile *tab; /**< Pointer to the table. */
100} shfdtab;
101
102int shfile_open(shfdtab *, const char *, unsigned);
103int shfile_pipe(shfdtab *, int [2]);
104int shfile_close(shfdtab *, unsigned);
105long shfile_read(shfdtab *, int, void *, size_t);
106long shfile_write(shfdtab *, int, const void *, size_t);
107long shfile_lseek(shfdtab *, int, long, int);
108int shfile_fcntl(shfdtab *, int fd, int cmd, int arg);
109int shfile_dup(shfdtab *, int fd);
110
111int shfile_stat(shfdtab *, const char *, struct stat *);
112int shfile_lstat(shfdtab *, const char *, struct stat *);
113int shfile_chdir(shfdtab *, const char *);
114char *shfile_getcwd(shfdtab *, char *, int);
115int shfile_isatty(shfdtab *, int);
116int shfile_ioctl(shfdtab *, int, unsigned long, char *);
117int shfile_access(shfdtab *, const char *, int);
118
119#endif
120
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette