Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
53 theseven 1
/***************************************************************************
2
 *             __________               __   ___.
3
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
4
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
5
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
6
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
7
 *                     \/            \/     \/    \/            \/
8
 * $Id: file.h 25856 2010-05-06 22:17:34Z kugel $
9
 *
10
 * Copyright (C) 2002 by Björn Stenberg
11
 *
12
 * This program is free software; you can redistribute it and/or
13
 * modify it under the terms of the GNU General Public License
14
 * as published by the Free Software Foundation; either version 2
15
 * of the License, or (at your option) any later version.
16
 *
17
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18
 * KIND, either express or implied.
19
 *
20
 ****************************************************************************/
21
 
22
#ifndef _FILE_H_
23
#define _FILE_H_
24
 
25
#define MAX_PATH 260
26
 
58 theseven 27
#include "global.h"
111 theseven 28
#include "libc/include/_ansi.h"
58 theseven 29
#include "thread.h"
53 theseven 30
 
59 theseven 31
#ifndef MAX_OPEN_FILES
32
#define MAX_OPEN_FILES 32
33
#endif
53 theseven 34
 
35
#ifndef SEEK_SET
36
#define SEEK_SET 0
37
#endif
38
#ifndef SEEK_CUR
39
#define SEEK_CUR 1
40
#endif
41
#ifndef SEEK_END
42
#define SEEK_END 2
43
#endif
44
 
45
#ifndef O_RDONLY
46
#define O_RDONLY 0
47
#define O_WRONLY 1
48
#define O_RDWR   2
49
#define O_CREAT  4
50
#define O_APPEND 8
51
#define O_TRUNC  0x10
52
#endif
53
 
54
typedef int (*open_func)(const char* pathname, int flags, ...);
55
typedef ssize_t (*read_func)(int fd, void *buf, size_t count);
56
typedef int (*creat_func)(const char *pathname, mode_t mode);
57
typedef ssize_t (*write_func)(int fd, const void *buf, size_t count);
58
typedef void (*qsort_func)(void *base, size_t nmemb,  size_t size,
59
                           int(*_compar)(const void *, const void *));
60
 
61
extern int file_open(const char* pathname, int flags);
62
extern int close(int fd);
58 theseven 63
extern int close_all_of_process(struct scheduler_thread* process);
53 theseven 64
extern int fsync(int fd);
65
extern ssize_t read(int fd, void *buf, size_t count);
66
extern off_t lseek(int fildes, off_t offset, int whence);
67
extern int file_creat(const char *pathname);
68
 
69
/* posix compatibility function */
70
static inline int creat(const char *pathname, mode_t mode)
71
{
72
    (void)mode;
73
    return file_creat(pathname);
74
}
75
 
76
#define open(x, y, ...) file_open(x,y)
77
 
78
extern ssize_t write(int fd, const void *buf, size_t count);
79
extern int remove(const char* pathname);
80
extern int rename(const char* path, const char* newname);
81
extern int ftruncate(int fd, off_t length);
82
extern off_t filesize(int fd);
83
extern int release_files(int volume);
84
int fdprintf (int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
85
#endif