blob: 95e7a914b375c83b899e7d2f2a13ff04e2c189a8 [file] [log] [blame]
William Juul0e8cc8b2007-11-15 11:13:05 +01001/*
Wolfgang Denk4b070802008-08-14 14:41:06 +02002 * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
William Juul0e8cc8b2007-11-15 11:13:05 +01003 *
4 * Copyright (C) 2002-2007 Aleph One Ltd.
5 * for Toby Churchill Ltd and Brightstar Engineering
6 *
7 * Created by Charles Manning <charles@aleph1.co.uk>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License version 2.1 as
11 * published by the Free Software Foundation.
12 *
13 * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
14 */
15
16/*
17 * Header file for using yaffs in an application via
18 * a direct interface.
19 */
20
21
22#ifndef __YAFFSFS_H__
23#define __YAFFSFS_H__
24
25#include "yaffscfg.h"
26#include "yportenv.h"
27
28
29//typedef long off_t;
30//typedef long dev_t;
31//typedef unsigned long mode_t;
32
33
34#ifndef NAME_MAX
35#define NAME_MAX 256
36#endif
37
38#ifndef O_RDONLY
39#define O_RDONLY 00
40#endif
41
42#ifndef O_WRONLY
43#define O_WRONLY 01
44#endif
45
46#ifndef O_RDWR
47#define O_RDWR 02
48#endif
49
Wolfgang Denk4b070802008-08-14 14:41:06 +020050#ifndef O_CREAT
William Juul0e8cc8b2007-11-15 11:13:05 +010051#define O_CREAT 0100
52#endif
53
54#ifndef O_EXCL
55#define O_EXCL 0200
56#endif
57
58#ifndef O_TRUNC
59#define O_TRUNC 01000
60#endif
61
62#ifndef O_APPEND
63#define O_APPEND 02000
64#endif
65
66#ifndef SEEK_SET
67#define SEEK_SET 0
68#endif
69
70#ifndef SEEK_CUR
71#define SEEK_CUR 1
72#endif
73
74#ifndef SEEK_END
75#define SEEK_END 2
76#endif
77
78#ifndef EBUSY
79#define EBUSY 16
80#endif
81
82#ifndef ENODEV
83#define ENODEV 19
84#endif
85
86#ifndef EINVAL
87#define EINVAL 22
88#endif
89
90#ifndef EBADF
91#define EBADF 9
92#endif
93
94#ifndef EACCESS
95#define EACCESS 13
96#endif
97
Wolfgang Denk4b070802008-08-14 14:41:06 +020098#ifndef EXDEV
William Juul0e8cc8b2007-11-15 11:13:05 +010099#define EXDEV 18
100#endif
101
102#ifndef ENOENT
103#define ENOENT 2
104#endif
105
106#ifndef ENOSPC
107#define ENOSPC 28
108#endif
109
110#ifndef ENOTEMPTY
111#define ENOTEMPTY 39
112#endif
113
114#ifndef ENOMEM
115#define ENOMEM 12
116#endif
117
118#ifndef EEXIST
119#define EEXIST 17
120#endif
121
122#ifndef ENOTDIR
123#define ENOTDIR 20
124#endif
125
126#ifndef EISDIR
127#define EISDIR 21
128#endif
129
130
131// Mode flags
132
133#ifndef S_IFMT
134#define S_IFMT 0170000
135#endif
136
137#ifndef S_IFLNK
138#define S_IFLNK 0120000
139#endif
140
141#ifndef S_IFDIR
142#define S_IFDIR 0040000
143#endif
144
145#ifndef S_IFREG
146#define S_IFREG 0100000
147#endif
148
Wolfgang Denk4b070802008-08-14 14:41:06 +0200149#ifndef S_IREAD
William Juul0e8cc8b2007-11-15 11:13:05 +0100150#define S_IREAD 0000400
151#endif
152
153#ifndef S_IWRITE
154#define S_IWRITE 0000200
155#endif
156
157
158
159
160struct yaffs_dirent{
161 long d_ino; /* inode number */
162 off_t d_off; /* offset to this dirent */
163 unsigned short d_reclen; /* length of this d_name */
164 char d_name [NAME_MAX+1]; /* file name (null-terminated) */
165 unsigned d_dont_use; /* debug pointer, not for public consumption */
166};
167
168typedef struct yaffs_dirent yaffs_dirent;
169
170
171typedef struct __opaque yaffs_DIR;
172
173
174
175struct yaffs_stat{
176 int st_dev; /* device */
177 int st_ino; /* inode */
178 mode_t st_mode; /* protection */
179 int st_nlink; /* number of hard links */
180 int st_uid; /* user ID of owner */
181 int st_gid; /* group ID of owner */
182 unsigned st_rdev; /* device type (if inode device) */
183 off_t st_size; /* total size, in bytes */
184 unsigned long st_blksize; /* blocksize for filesystem I/O */
185 unsigned long st_blocks; /* number of blocks allocated */
186 unsigned long yst_atime; /* time of last access */
187 unsigned long yst_mtime; /* time of last modification */
188 unsigned long yst_ctime; /* time of last change */
189};
190
191int yaffs_open(const char *path, int oflag, int mode) ;
192int yaffs_read(int fd, void *buf, unsigned int nbyte) ;
193int yaffs_write(int fd, const void *buf, unsigned int nbyte) ;
194int yaffs_close(int fd) ;
195off_t yaffs_lseek(int fd, off_t offset, int whence) ;
196int yaffs_truncate(int fd, off_t newSize);
197
198int yaffs_unlink(const char *path) ;
199int yaffs_rename(const char *oldPath, const char *newPath) ;
200
201int yaffs_stat(const char *path, struct yaffs_stat *buf) ;
202int yaffs_lstat(const char *path, struct yaffs_stat *buf) ;
203int yaffs_fstat(int fd, struct yaffs_stat *buf) ;
204
Wolfgang Denk4b070802008-08-14 14:41:06 +0200205int yaffs_chmod(const char *path, mode_t mode);
206int yaffs_fchmod(int fd, mode_t mode);
William Juul0e8cc8b2007-11-15 11:13:05 +0100207
208int yaffs_mkdir(const char *path, mode_t mode) ;
209int yaffs_rmdir(const char *path) ;
210
211yaffs_DIR *yaffs_opendir(const char *dirname) ;
212struct yaffs_dirent *yaffs_readdir(yaffs_DIR *dirp) ;
213void yaffs_rewinddir(yaffs_DIR *dirp) ;
214int yaffs_closedir(yaffs_DIR *dirp) ;
215
216int yaffs_mount(const char *path) ;
217int yaffs_unmount(const char *path) ;
218
Wolfgang Denk4b070802008-08-14 14:41:06 +0200219int yaffs_symlink(const char *oldpath, const char *newpath);
220int yaffs_readlink(const char *path, char *buf, int bufsiz);
William Juul0e8cc8b2007-11-15 11:13:05 +0100221
Wolfgang Denk4b070802008-08-14 14:41:06 +0200222int yaffs_link(const char *oldpath, const char *newpath);
William Juul0e8cc8b2007-11-15 11:13:05 +0100223int yaffs_mknod(const char *pathname, mode_t mode, dev_t dev);
224
225loff_t yaffs_freespace(const char *path);
226
227void yaffs_initialise(yaffsfs_DeviceConfiguration *configList);
228
229int yaffs_StartUp(void);
230
231#endif