udftools

- Main Page
- Classes
- Files

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
wrudf.h
Go to the documentation of this file.
1 /* wrudf.h
2 *
3 * PURPOSE
4 * The header file for wrudf.c and related source files.
5 *
6 * COPYRIGHT
7 * This file is distributed under the terms of the GNU General Public
8 * License (GPL). Copies of the GPL can be obtained from:
9 * ftp://prep.ai.mit.edu/pub/gnu/GPL
10 * Each contributing author retains all rights to their own work.
11 *
12 * (C) 2001 Enno Fennema <e.fennema@dataweb.nl>
13 *
14 * HISTORY
15 * 16 Aug 01 ef created.
16 */
17
18
19 #include <sys/time.h>
20 #include <time.h>
21 #include <stdint.h>
22 #include <string.h>
23
24 #include "ecma_167.h"
25 #include "osta_udf.h"
26 #include "libudffs.h"
27
28 struct generic_desc
29 {
30 tag descTag;
31 uint32_t volDescSeqNum;
32 };
33
34 extern char* hdWorkingDir;
35 extern int ignoreReadError;
36 extern int device;
37 extern int devicetype;
38 #define DISK_IMAGE 0xAA
39
40 enum MEDIUM { CDR = 1, CDRW };
41
42 extern enum MEDIUM medium;
43
44 // #define CDR 'R'
45 // #define CDRW 'W'
46
47 extern uint32_t trackSize;
48
49 #ifdef _GNU_SOURCE
50 /* I appear not to have readline.h */
51 char* readline(char* prompt);
52 extern char *line;
53 #else
54 extern char line[256];
55 #endif
56
57 extern regid entityWRUDF;
58 extern timestamp timeStamp;
59
60 enum RV { CMND_OK, CMND_FAILED, WRONG_NO_ARGS, CMND_ARG_INVALID, NOT_IN_RW_PARTITION,
61 DIR_INVALID, EXISTING_DIR, EXISTING_FILE, DELETED_DIR, DELETED_FILE, DOES_NOT_EXIST,
62 DIR_NOT_EMPTY, PERMISSION_DENIED, IS_DIRECTORY };
63
64 enum CMND { CMND_CP = 50, CMND_RM, CMND_MKDIR, CMND_RMDIR, CMND_LSC, CMND_LSH, CMND_CDC, CMND_CDH, CMND_QUIT };
65
66 extern int cmndc;
67 extern char** cmndv;
68
69 extern uint32_t options;
70 #define OPT_DUMMY 0x01
71 #define OPT_FORCE 0x02
72 #define OPT_RECURSIVE 0x04
73
74 extern int spaceMapDirty, usdDirty, sparingTableDirty;
75
76 extern struct logicalVolDesc *lvd;
77 extern struct partitionDesc *pd; /* The (re)writable partition descriptor */
78 extern uint16_t virtualPartitionNum;
79 extern uint32_t *vat;
80 extern struct unallocSpaceDesc *usd;
81 extern struct spaceBitmapDesc *spaceMap;
82 extern struct logicalVolIntegrityDesc *lvid;
83 extern struct fileSetDesc *fsd;
84 extern unsigned int usedSparingEntries;
85 extern struct sparingTable *st;
86
87 typedef struct _dir_ {
88 struct _dir_ *parent, *child;
89 uint32_t dataSize;
90 char *data;
91 long_ad icb; /* icb of this directory itself */
92 char *name;
93 uint32_t dirDirty;
94 struct fileEntry fe;
95 uint8_t spacer[2048-sizeof(struct fileEntry)];
96 } Directory;
97
98 extern Directory *rootDir, *curDir;
99
100
101 /*wrudf.c */
102 char* readLine(char *prompt);
103
104 /* wrudf-cmnd.c */
105 int updateDirectory(Directory* dir);
106 Directory *readDirectory(Directory *parentDir, long_ad *icb, char* name);
107
108 int cpCommand(void);
109 int rmCommand(void);
110 int mkdirCommand(void);
111 int rmdirCommand(void);
112 int cdcCommand(void);
113 int cdhCommand(void);
114 int lscCommand(void);
115 int lshCommand(void);
116
117 /* wrudf-desc.c */
118 struct fileIdentDesc* makeFileIdentDesc(char* name);
119 struct fileIdentDesc* findFileIdentDesc(Directory *dir, char* name);
120 int deleteFID(Directory *dir, struct fileIdentDesc *fid);
121 int removeFID(Directory *dir, struct fileIdentDesc *fid);
122 int insertFileIdentDesc(Directory *dir, struct fileIdentDesc* fid);
123 struct fileEntry* makeFileEntry();
124
125
126 /* wrudf-cdrw.c */
127 enum markAction { FREE, ALLOC };
128 void markBlock(enum markAction action, uint32_t blkno);
129
130 extern int lastTrack;
131 extern int sectortype;
132 extern struct cdrom_trackinfo ti;
133
134 int getExtents(uint32_t requestedLength, short_ad *extents);
135 int freeShortExtents(short_ad* extent);
136 int freeLongExtents(long_ad* extent);
137
138 void getUnallocSpaceExtent(uint32_t requestLength, uint32_t requestAfter, extent_ad *alloc);
139
140 void setChecksum(void *descriptor);
141 void updateTimestamp(time_t t, uint32_t ut); /* current time if t = 0 */
142 void setStrictRead(int yes);
143 uint32_t getPhysical(uint32_t lbn, uint16_t part);
144 void updateSparingTable();
145
146 #define ABSOLUTE 0xFFFF /* ignore partition, process physical blocknumber */
147 /* actually 0xFFFF is a perfectly valid partition number
148 * could make part a uint32_t and use 0xFFFFFFFF
149 * or have write absolute block routine
150 */
151
152 #define INVALID 0xFFFFFFFF
153
154 void* readBlock(uint32_t lbn, uint16_t part);
155 void freeBlock(uint32_t lbn, uint16_t part);
156 void dirtyBlock(uint32_t lbn, uint16_t part);
157 void writeBlock(uint32_t lbn, uint16_t part, void* src);
158 void* readSingleBlock(uint32_t pbn);
159 void* readTaggedBlock(uint32_t lbn, uint16_t part);
160 int readExtents(char* dest, int usesShort, void* extents);
161 int writeExtents(char* src, int usesShort, void* extents);
162
163 int initIO(char *filename);
164 int closeIO();
165
166 /* wrudf-cdr.c */
167 uint32_t newVATentry();
168 uint32_t getNWA();
169 uint32_t getMaxVarPktSize();
170 uint32_t writeCDR(void* src);
171 void syncCDR();
172 void writeHDlink();
173 unsigned char* readCDR(uint32_t lbn, uint16_t partition);
174 int verifyCDR(struct fileEntry *fe);
175 void readVATtable();
176 void writeVATtable();
177
178 /* ide-pc.h */
179 void fail(char* fmt, ...);
removeFID
int removeFID(Directory *dir, struct fileIdentDesc *fid)
Definition: wrudf-desc.c:31
fsd
struct fileSetDesc * fsd
Definition: wrudf.c:72
NOT_IN_RW_PARTITION
Definition: wrudf.h:60
ti
struct cdrom_trackinfo ti
Definition: wrudf-cdrw.c:50
usedSparingEntries
unsigned int usedSparingEntries
Definition: wrudf.c:73
lvid
struct logicalVolIntegrityDesc * lvid
Definition: wrudf.c:71
lscCommand
int lscCommand(void)
Definition: wrudf-cmnd.c:964
entityWRUDF
regid entityWRUDF
Definition: wrudf.c:50
vat
uint32_t * vat
Definition: wrudf.c:64
timeStamp
timestamp timeStamp
Definition: wrudf.c:49
closeIO
int closeIO()
Definition: wrudf-cdrw.c:927
spaceMapDirty
int spaceMapDirty
Definition: wrudf.c:76
getMaxVarPktSize
uint32_t getMaxVarPktSize()
Definition: wrudf-cdr.c:48
DOES_NOT_EXIST
Definition: wrudf.h:61
_dir_::dataSize
uint32_t dataSize
Definition: wrudf.h:89
insertFileIdentDesc
int insertFileIdentDesc(Directory *dir, struct fileIdentDesc *fid)
Definition: wrudf-desc.c:211
usdDirty
int usdDirty
Definition: wrudf.c:76
trackSize
uint32_t trackSize
Definition: wrudf-cdrw.c:62
sparingTable
Definition: osta_udf.h:192
_dir_::parent
struct _dir_ * parent
Definition: wrudf.h:88
sectortype
int sectortype
Definition: wrudf-cdrw.c:63
ecma_167.h
getPhysical
uint32_t getPhysical(uint32_t lbn, uint16_t part)
Definition: wrudf-cdrw.c:290
DELETED_DIR
Definition: wrudf.h:61
writeExtents
int writeExtents(char *src, int usesShort, void *extents)
Definition: wrudf-cdrw.c:733
st
struct sparingTable * st
Definition: wrudf.c:74
_dir_::name
char * name
Definition: wrudf.h:92
prompt
int prompt(const char *format,...)
Simple prompt printing out message and accepting y/Y/n/N. Anything else restarts prompt.
Definition: utils.c:184
cmndv
char ** cmndv
Definition: wrudf.c:34
initIO
int initIO(char *filename)
Definition: wrudf-cdrw.c:779
writeBlock
void writeBlock(uint32_t lbn, uint16_t part, void *src)
Definition: wrudf-cdrw.c:625
cdhCommand
int cdhCommand(void)
Definition: wrudf-cmnd.c:1022
icb
long_ad icb
Definition: ecma_167.h:68
CMND_LSC
Definition: wrudf.h:64
freeLongExtents
int freeLongExtents(long_ad *extent)
Definition: wrudf-cdrw.c:176
generic_desc
Definition: wrudf.h:28
CMND
CMND
Definition: wrudf.h:64
mkdirCommand
int mkdirCommand(void)
Definition: wrudf-cmnd.c:891
_dir_::child
struct _dir_ * child
Definition: wrudf.h:88
getNWA
uint32_t getNWA()
Definition: wrudf-cdr.c:35
MEDIUM
MEDIUM
Definition: wrudf.h:40
getExtents
int getExtents(uint32_t requestedLength, short_ad *extents)
Definition: wrudf-cdrw.c:98
lastTrack
int lastTrack
Definition: wrudf-cdrw.c:49
CDRW
Definition: wrudf.h:40
cdcCommand
int cdcCommand(void)
Definition: wrudf-cmnd.c:948
readLine
char * readLine(char *prompt)
Definition: wrudf.c:79
lshCommand
int lshCommand(void)
Definition: wrudf-cmnd.c:1039
_dir_::spacer
uint8_t spacer[2048-sizeof(struct fileEntry)]
Definition: wrudf.h:95
RV
RV
Definition: wrudf.h:60
deleteFID
int deleteFID(Directory *dir, struct fileIdentDesc *fid)
Definition: wrudf-desc.c:49
rmdirCommand
int rmdirCommand(void)
Definition: wrudf-cmnd.c:924
readVATtable
void readVATtable()
Definition: wrudf-cdr.c:283
readExtents
int readExtents(char *dest, int usesShort, void *extents)
Definition: wrudf-cdrw.c:684
spaceMap
struct spaceBitmapDesc * spaceMap
Definition: wrudf.c:70
updateTimestamp
void updateTimestamp(time_t t, uint32_t ut)
Definition: wrudf-cdrw.c:243
getUnallocSpaceExtent
void getUnallocSpaceExtent(uint32_t requestLength, uint32_t requestAfter, extent_ad *alloc)
Definition: wrudf-cdrw.c:198
device
int device
Definition: wrudf.c:18
writeCDR
uint32_t writeCDR(void *src)
Definition: wrudf-cdr.c:121
logicalVolDesc
Definition: ecma_167.h:296
CMND_CDC
Definition: wrudf.h:64
EXISTING_DIR
Definition: wrudf.h:61
updateDirectory
int updateDirectory(Directory *dir)
Definition: wrudf-cmnd.c:453
readCDR
unsigned char * readCDR(uint32_t lbn, uint16_t partition)
Definition: wrudf-cdr.c:59
updateSparingTable
void updateSparingTable()
Definition: wrudf-cdrw.c:371
verifyCDR
int verifyCDR(struct fileEntry *fe)
Definition: wrudf-cdr.c:200
CMND_FAILED
Definition: wrudf.h:60
makeFileEntry
struct fileEntry * makeFileEntry()
Definition: wrudf-desc.c:158
freeBlock
void freeBlock(uint32_t lbn, uint16_t part)
Definition: wrudf-cdrw.c:592
generic_desc::descTag
tag descTag
Definition: wrudf.h:30
WRONG_NO_ARGS
Definition: wrudf.h:60
line
char line[256]
Definition: wrudf.c:27
_dir_::fe
struct fileEntry fe
Definition: wrudf.h:94
rootDir
Directory * rootDir
Definition: wrudf.c:48
cpCommand
int cpCommand(void)
Definition: wrudf-cmnd.c:763
EXISTING_FILE
Definition: wrudf.h:61
CDR
Definition: wrudf.h:40
pd
struct partitionDesc * pd
Definition: wrudf.c:62
sparingTableDirty
int sparingTableDirty
Definition: wrudf.c:76
fileEntry
Definition: ecma_167.h:558
fileSetDesc
Definition: ecma_167.h:425
DIR_NOT_EMPTY
Definition: wrudf.h:62
Directory
struct _dir_ Directory
DELETED_FILE
Definition: wrudf.h:61
markBlock
void markBlock(enum markAction action, uint32_t blkno)
Definition: wrudf-cdrw.c:74
readTaggedBlock
void * readTaggedBlock(uint32_t lbn, uint16_t part)
Definition: wrudf-cdrw.c:639
_dir_::dirDirty
uint32_t dirDirty
Definition: wrudf.h:93
medium
enum MEDIUM medium
Definition: wrudf.c:20
_dir_
Definition: wrudf.h:87
PERMISSION_DENIED
Definition: wrudf.h:62
CMND_OK
Definition: wrudf.h:60
findFileIdentDesc
struct fileIdentDesc * findFileIdentDesc(Directory *dir, char *name)
Definition: wrudf-desc.c:113
DIR_INVALID
Definition: wrudf.h:61
options
uint32_t options
Definition: wrudf.c:45
devicetype
int devicetype
Definition: wrudf.c:19
setStrictRead
void setStrictRead(int yes)
Definition: wrudf-cdrw.c:270
lvd
struct logicalVolDesc * lvd
Definition: wrudf.c:68
CMND_ARG_INVALID
Definition: wrudf.h:60
logicalVolIntegrityDesc
Definition: ecma_167.h:360
cmndc
int cmndc
Definition: wrudf.c:32
readDirectory
Directory * readDirectory(Directory *parentDir, long_ad *icb, char *name)
Definition: wrudf-cmnd.c:383
newVATentry
uint32_t newVATentry()
Definition: wrudf-cdr.c:22
CMND_RMDIR
Definition: wrudf.h:64
CMND_CP
Definition: wrudf.h:64
CMND_RM
Definition: wrudf.h:64
generic_desc::volDescSeqNum
uint32_t volDescSeqNum
Definition: wrudf.h:31
curDir
Directory * curDir
Definition: wrudf.c:48
writeVATtable
void writeVATtable()
Definition: wrudf-cdr.c:309
_dir_::icb
long_ad icb
Definition: wrudf.h:91
usd
struct unallocSpaceDesc * usd
Definition: wrudf.c:69
virtualPartitionNum
uint16_t virtualPartitionNum
Definition: wrudf.c:63
CMND_CDH
Definition: wrudf.h:64
fail
void fail(char *fmt,...)
Definition: ide-pc.c:43
CMND_MKDIR
Definition: wrudf.h:64
hdWorkingDir
char * hdWorkingDir
Definition: wrudf-cmnd.c:37
libudffs.h
setChecksum
void setChecksum(void *descriptor)
Definition: wrudf-cdrw.c:229
IS_DIRECTORY
Definition: wrudf.h:62
CMND_LSH
Definition: wrudf.h:64
markAction
markAction
Definition: wrudf.h:127
writeHDlink
void writeHDlink()
Definition: wrudf-cdr.c:107
FREE
Definition: wrudf.h:127
freeShortExtents
int freeShortExtents(short_ad *extent)
Definition: wrudf-cdrw.c:159
dirtyBlock
void dirtyBlock(uint32_t lbn, uint16_t part)
Definition: wrudf-cdrw.c:610
_dir_::data
char * data
Definition: wrudf.h:90
readBlock
void * readBlock(uint32_t lbn, uint16_t part)
Definition: wrudf-cdrw.c:543
rmCommand
int rmCommand(void)
Definition: wrudf-cmnd.c:859
unallocSpaceDesc
Definition: ecma_167.h:344
CMND_QUIT
Definition: wrudf.h:64
fileIdentDesc
Definition: ecma_167.h:460
partitionDesc
Definition: ecma_167.h:260
cdrom_trackinfo
Definition: ide-pc.h:95
spaceBitmapDesc
Definition: ecma_167.h:749
makeFileIdentDesc
struct fileIdentDesc * makeFileIdentDesc(char *name)
Definition: wrudf-desc.c:187
ignoreReadError
int ignoreReadError
Definition: wrudf.c:21
readSingleBlock
void * readSingleBlock(uint32_t pbn)
Definition: wrudf-cdrw.c:564
ALLOC
Definition: wrudf.h:127
syncCDR
void syncCDR()
Definition: wrudf-cdr.c:96
osta_udf.h