File: isofs.h

package info (click to toggle)
fuseiso 20070708-3+deb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,828 kB
  • sloc: sh: 9,081; ansic: 2,182; makefile: 14
file content (164 lines) | stat: -rw-r--r-- 5,519 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/***************************************************************************
 *   Copyright (C) 2005, 2006 by Dmitry Morozhnikov   *
 *   dmiceman@mail.ru   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef _ISOFS_H
#define _ISOFS_H

#include <sys/stat.h>
#include <linux/iso_fs.h>
#include <linux/rock.h>

typedef int (*isofs_dir_fill_t) (void *buf, const char *name,
    const struct stat *stat, off_t off);

typedef struct _isofs_context {
    char *imagefile;
    int fd;
    int pd_have_rr; // 1 if primary descriptor have hierarchy with rrip extension
    struct iso_primary_descriptor pd;
    int supplementary; // 1 if supplementary descriptor found and in effect
    struct iso_supplementary_descriptor sd;
    struct iso_directory_record *root;
    int file_offset; // offset to begin of useful data (for .nrg files)
    int id_offset; // offset to CD001 inside file
    off_t block_size; // raw block size
    off_t block_offset; // offset from block start to data
    off_t data_size; // data size inside block 
    int susp; // parse susp entries
    int susp_skip; // skip bytes from susp SP entry
    int joliet_level; // joliet extension level (1, 2 or 3)
    ino_t last_ino;
} isofs_context;

typedef struct _isofs_inode {
    struct iso_directory_record *record;
    struct stat st;
    ino_t st_ino;
    time_t ctime; // cached value from record->date
    char *sl;
    size_t sl_len;
    char *nm;
    size_t nm_len;
    int cl_block;
    int pl_block;
    size_t zf_size;
    size_t real_size;
    char zf_algorithm[2];
    size_t zf_header_size;
    int zf_block_shift;
    int zf_nblocks;
    int *zf_blockptr;
    int PX; // 1 if PX entry found, st in effect
    int SL; // 1 if SL entry found, sl in effect
    int NM; // 1 if NM entry found, nm in effect
    int CL; // 1 if CL found, cl_block in effect
    int PL; // 1 if PL found, pl_block in effect
    int RE;
    int TF; // 1 if TF entry found, st in effect
    int ZF; // 1 if ZF entry found
} isofs_inode;

// borrowed from zisofs-tools
typedef struct _zf_file_header {
  char magic[8];
  char uncompressed_len[4];
  unsigned char header_size;
  unsigned char block_size;
  char reserved[2];
} zf_file_header;

// macros for iso_directory_record->flags
#define ISO_FLAGS_HIDDEN(x) (*((unsigned char *) x) & 1)
#define ISO_FLAGS_DIR(x) (*((unsigned char *) x) & (1 << 1))

// borrowed from linux kernel rock ridge code

#define SIG(A,B) ((A) | ((B) << 8)) /* isonum_721() */

// borrowed from linux kernel isofs code

/* Number conversion inlines, named after the section in ISO 9660
   they correspond to. */

#include <byteswap.h>

static inline int isonum_711(unsigned char *p)
{
    return *(unsigned char *)p;
}
// static inline int isonum_712(char *p)
// {
//     return *(s8 *)p;
// }
static inline unsigned int isonum_721(char *p)
{
#if defined(WORDS_BIGENDIAN)
    return *(unsigned short *)p;
#else
    return bswap_16(*(unsigned short *)p);
#endif
}
// static inline unsigned int isonum_722(char *p)
// {
//     return be16_to_cpu(get_unaligned((__le16 *)p));
// }
static inline unsigned int isonum_723(char *p)
{
    /* Ignore bigendian datum due to broken mastering programs */
#if defined(WORDS_BIGENDIAN)
    return bswap_16(*(unsigned short *)p);
#else
    return *(unsigned short *)p;
#endif
}
static inline unsigned int isonum_731(char *p)
{
#if defined(WORDS_BIGENDIAN)
    return bswap_32(*(unsigned int *)p);
#else
    return *(unsigned int *)p;
#endif
}
// static inline unsigned int isonum_732(char *p)
// {
//     return be32_to_cpu(get_unaligned((__le32 *)p));
// }
static inline unsigned int isonum_733(char *p)
{
    /* Ignore bigendian datum due to broken mastering programs */
#if defined(WORDS_BIGENDIAN)
    return bswap_32(*(unsigned int *)p);
#else
    return *(unsigned int *)p;
#endif
}

int isofs_real_preinit(char* imagefile, int fd);
void* isofs_real_init();

int isofs_real_opendir(const char *path);
int isofs_real_readdir(const char *path, void *filler_buf, isofs_dir_fill_t filler);
int isofs_real_getattr(const char *path, struct stat *stbuf);
int isofs_real_readlink(const char *path, char *target, size_t size);
int isofs_real_open(const char *path);
int isofs_real_read(const char *path, char *out_buf, size_t size, off_t offset);
int isofs_real_statfs(struct statfs *stbuf);

#endif // _ISOFS_H