ReactOS 0.4.15-dev-7918-g2a2556c
inode.c File Reference
#include <schily/mconfig.h>
#include "mkisofs.h"
#include <schily/schily.h>
Include dependency graph for inode.c:

Go to the source code of this file.

Functions

EXPORT void do_inode __PR ((struct directory *dpnt))
 
LOCAL void update_inode __PR ((struct directory_entry *s_entry, int value))
 
EXPORT void do_inode (struct directory *dpnt)
 
EXPORT void do_dir_nlink (struct directory *dpnt)
 
LOCAL void assign_inodes (struct directory *dpnt)
 
LOCAL void compute_linkcount (struct directory *dpnt)
 
LOCAL void assign_linkcount (struct directory *dpnt)
 
LOCAL void update_inode (struct directory_entry *s_entry, int value)
 
LOCAL void update_nlink (struct directory_entry *s_entry, int value)
 
LOCAL int update_dir_nlink (struct directory *dpnt)
 

Variables

static UConst char sccsid []
 
LOCAL UInt32_t null_ino_high
 

Function Documentation

◆ __PR() [1/2]

EXPORT void do_inode __PR ( (struct directory *dpnt)  )

◆ __PR() [2/2]

◆ assign_inodes()

LOCAL void assign_inodes ( struct directory dpnt)

Definition at line 113 of file inode.c.

115{
116 struct directory_entry *s_entry;
117 struct file_hash *s_hash;
118
119 while (dpnt) {
120 s_entry = dpnt->contents;
121 for (s_entry = dpnt->contents; s_entry; s_entry = s_entry->next) {
122 if (s_entry->starting_block == 0) {
123 s_hash = find_hash(s_entry);
124 /* find_directory_hash() ? */
125 if (s_hash)
126 s_entry->starting_block = s_hash->starting_block;
127 }
128 if (s_entry->starting_block == 0 && s_entry->size != 0) {
129 unsigned int e = get_733((char *)s_entry->isorec.extent);
130
131 if (e != 0) {
133 _("Implementation botch, fetching extend %d for %s from dir entry.\n"),
134 e, s_entry->whole_name);
135 }
136 }
137 if (use_RockRidge && s_entry->starting_block > 0)
138 update_inode(s_entry, s_entry->starting_block);
139
140 /*
141 * Be careful: UDF Symlinks have size != 0, then
142 * s_hash->starting_block is a valid inode number.
143 */
144 if (s_entry->size != 0)
145 continue;
146#ifdef UDF
147 if ((s_entry->de_flags & IS_SYMLINK) != 0 &&
149 continue;
150#else
151 if ((s_entry->de_flags & IS_SYMLINK) != 0)
152 continue;
153#endif
154
155 if (s_entry->isorec.flags[0] & ISO_DIRECTORY)
156 continue;
157
158 /*
159 * Assign inodes to symbolic links.
160 */
161 if (s_entry->dev == UNCACHED_DEVICE && s_entry->inode == UNCACHED_INODE) {
162 s_entry->dev = PREV_SESS_DEV;
163 s_entry->inode = null_inodes;
164 }
165 s_hash = find_hash(s_entry);
166 if (s_hash) {
167 /*
168 * Paranoia: Check for hashed files without proper inode #.
169 */
170 if (s_hash->starting_block <= last_extent)
172 _("Implementation botch: Hashed file '%s' has illegal inode %u.\n"),
173 s_entry->whole_name ?
174 s_entry->whole_name : s_entry->name,
175 s_hash->starting_block);
176 set_733((char *)s_entry->isorec.extent, s_hash->starting_block);
177 s_entry->starting_block = s_hash->starting_block;
178 } else {
179 s_entry->starting_block = null_inodes--;
180 set_733((char *)s_entry->isorec.extent, s_entry->starting_block);
181 add_hash(s_entry);
182 }
183 if (use_RockRidge)
184 update_inode(s_entry, s_entry->starting_block);
185 }
186 if (dpnt->subdir) {
187 assign_inodes(dpnt->subdir);
188 }
189
190 dpnt = dpnt->next;
191 }
192}
void add_hash(struct hash_table *table, unsigned char *name, int len, unsigned char *pointer)
Definition: hash.c:82
EXPORT void comerrno(int err, char *msg, va_alist)
Definition: comerr.c:137
EXPORT int errmsgno(int err, char *msg, va_alist)
Definition: comerr.c:219
#define _(X)
Definition: i386-dis.c:35
LOCAL void assign_inodes(struct directory *dpnt)
Definition: inode.c:113
LOCAL void update_inode(struct directory_entry *s_entry, int value)
Definition: inode.c:329
#define ISO_DIRECTORY
Definition: iso9660.h:265
EXPORT UInt32_t get_733(void *vp)
Definition: isonum.c:219
EXPORT void set_733(void *vp, UInt32_t i)
Definition: isonum.c:125
#define e
Definition: ke_i.h:82
UInt32_t null_inodes
Definition: mkisofs.c:323
int use_RockRidge
Definition: mkisofs.c:110
UInt32_t last_extent
Definition: mkisofs.c:76
int create_udfsymlinks
#define PREV_SESS_DEV
Definition: mkisofs.h:762
#define IS_SYMLINK
Definition: mkisofs.h:807
#define UNCACHED_DEVICE
Definition: mkisofs.h:765
#define UNCACHED_INODE
Definition: mkisofs.h:764
EXPORT struct file_hash * find_hash(struct directory_entry *spnt)
Definition: hash.c:192
#define EX_BAD
Definition: standard.h:62
Definition: mkisofs.h:107
char * whole_name
Definition: mkisofs.h:118
dev_t dev
Definition: mkisofs.h:133
unsigned int starting_block
Definition: mkisofs.h:111
off_t size
Definition: mkisofs.h:112
struct directory_entry * next
Definition: mkisofs.h:108
char * name
Definition: mkisofs.h:116
unsigned int de_flags
Definition: mkisofs.h:122
struct iso_directory_record isorec
Definition: mkisofs.h:110
ino_t inode
Definition: mkisofs.h:132
struct directory * subdir
Definition: mkisofs.h:268
struct directory * next
Definition: mkisofs.h:267
struct directory_entry * contents
Definition: mkisofs.h:270
unsigned int starting_block
Definition: mkisofs.h:161

Referenced by assign_inodes(), and do_inode().

◆ assign_linkcount()

LOCAL void assign_linkcount ( struct directory dpnt)

Definition at line 284 of file inode.c.

286{
287 struct directory_entry *s_entry;
288 struct file_hash *s_hash;
289
290 while (dpnt) {
291 s_entry = dpnt->contents;
292 for (s_entry = dpnt->contents; s_entry; s_entry = s_entry->next) {
293 if (s_entry->isorec.flags[0] & ISO_DIRECTORY)
294 continue;
295 if (s_entry->de_flags & RELOCATED_DIRECTORY)
296 continue;
297 /*
298 * skip resource files or file stream files
299 */
300 if (s_entry->de_flags & RESOURCE_FORK)
301 continue;
302
303 s_hash = find_hash(s_entry);
304 if (s_hash) {
305 update_nlink(s_entry, s_hash->nlink);
306 } else {
307 if (s_entry->dev == UNCACHED_DEVICE &&
308 s_entry->inode == TABLE_INODE) {
309 continue;
310 }
312 _("Implementation botch: File '%s' not hashed.\n"),
313 s_entry->whole_name ?
314 s_entry->whole_name : s_entry->name);
315 }
316 }
317 if (dpnt->subdir) {
319 }
320
321 dpnt = dpnt->next;
322 }
323}
LOCAL void update_nlink(struct directory_entry *s_entry, int value)
Definition: inode.c:369
LOCAL void assign_linkcount(struct directory *dpnt)
Definition: inode.c:284
#define TABLE_INODE
Definition: mkisofs.h:763
#define RESOURCE_FORK
Definition: mkisofs.h:806
#define RELOCATED_DIRECTORY
Definition: mkisofs.h:801
nlink_t nlink
Definition: mkisofs.h:160

Referenced by assign_linkcount(), and do_inode().

◆ compute_linkcount()

LOCAL void compute_linkcount ( struct directory dpnt)

Definition at line 198 of file inode.c.

200{
201 struct directory_entry *s_entry;
202 struct file_hash *s_hash;
203
204 while (dpnt) {
205 s_entry = dpnt->contents;
206 for (s_entry = dpnt->contents; s_entry; s_entry = s_entry->next) {
207 /*
208 * Skip directories.
209 */
210 if (s_entry->isorec.flags[0] & ISO_DIRECTORY)
211 continue;
212 if (s_entry->de_flags & RELOCATED_DIRECTORY)
213 continue;
214
215 /*
216 * skip resource files or file stream files
217 * XXX should we assign a standard link count == 1 instead?
218 */
219 if (s_entry->de_flags & RESOURCE_FORK)
220 continue;
221
222 /*
223 * Assign inodes to symbolic links.
224 * We never come here in case that we create correct inodes,
225 * except with UDF symlinks.
226 */
227 if (s_entry->dev == UNCACHED_DEVICE && s_entry->inode == UNCACHED_INODE) {
228 s_entry->dev = PREV_SESS_DEV;
229
230 /*
231 * With UDF symlinks, the starting_block is a
232 * valid inode number.
233 */
234#ifdef UDF
235 if ((s_entry->de_flags & IS_SYMLINK) != 0 &&
237#else
238 if ((s_entry->de_flags & IS_SYMLINK) != 0) {
239#endif
240 s_entry->inode = s_entry->starting_block;
241 } else {
242 s_entry->inode = null_inodes--; /* Only used for caching */
243 if (correct_inodes)
245 _("Implementation botch: Unhashed file '%s'.\n"),
246 s_entry->whole_name ?
247 s_entry->whole_name : s_entry->name);
248 }
249 }
250 s_hash = find_hash(s_entry);
251 if (s_hash) {
252 s_hash->nlink++;
253 } else {
254 add_hash(s_entry);
255 s_hash = find_hash(s_entry);
256 if (s_hash == NULL) {
257 if (s_entry->dev == UNCACHED_DEVICE &&
258 s_entry->inode == TABLE_INODE) {
259 continue;
260 }
262 _("Implementation botch: File '%s' not hashed (dev/ino %llX/%llX).\n"),
263 s_entry->whole_name ?
264 s_entry->whole_name : s_entry->name,
265 (Llong)s_entry->dev,
266 (Llong)s_entry->inode);
267 }
268 s_hash->nlink++;
269 }
270 }
271 if (dpnt->subdir) {
273 }
274
275 dpnt = dpnt->next;
276 }
277}
#define NULL
Definition: types.h:112
LOCAL void compute_linkcount(struct directory *dpnt)
Definition: inode.c:198
BOOL correct_inodes
Definition: mkisofs.c:324
long Llong
Definition: stdint.h:152

Referenced by compute_linkcount(), and do_inode().

◆ do_dir_nlink()

EXPORT void do_dir_nlink ( struct directory dpnt)

Definition at line 85 of file inode.c.

87{
88 int rootlinks;
89
90 if (!use_RockRidge)
91 return;
92
93 /*
94 * Update everything except "/..".
95 */
96 rootlinks = update_dir_nlink(dpnt);
97 if (reloc_dir)
98 rootlinks--; /* rr_moved is hidden */
99 /*
100 * Update "/." now.
101 */
102 update_nlink(dpnt->contents, rootlinks);
103 /*
104 * Update "/.." now.
105 */
106 update_nlink(dpnt->contents->next, rootlinks);
107}
LOCAL int update_dir_nlink(struct directory *dpnt)
Definition: inode.c:405
struct directory * reloc_dir
Definition: tree.c:111

Referenced by dirtree_fixup().

◆ do_inode()

EXPORT void do_inode ( struct directory dpnt)

Definition at line 55 of file inode.c.

57{
59
62
63#ifdef UDF
64 if (!use_RockRidge && !use_udf)
65 return;
66#else
67 if (!use_RockRidge)
68 return;
69#endif
70 if (!cache_inodes) /* Never FALSE if correct_inodes TRUE */
71 return;
72
74 if (use_RockRidge) /* If we have Rock Ridge extensions, */
75 assign_linkcount(dpnt); /* reassign computed linkcount in RR */
76
78 comerrno(EX_BAD, _("Inode number overflow, too many files in file system.\n"));
79}
LOCAL UInt32_t null_ino_high
Definition: inode.c:40
int cache_inodes
Definition: mkisofs.c:141

Referenced by file_gen(), and read_bitmaps().

◆ update_dir_nlink()

LOCAL int update_dir_nlink ( struct directory dpnt)

Definition at line 405 of file inode.c.

407{
408 struct directory *xpnt;
409 struct directory_entry *s_entry;
410 int i = 0;
411
412 while (dpnt) {
413 if (dpnt->dir_flags & INHIBIT_ISO9660_ENTRY) {
414 dpnt = dpnt->next;
415 continue;
416 }
417 /*
418 * First, count up the number of subdirectories this dir has.
419 */
420 for (i = 0, xpnt = dpnt->subdir; xpnt; xpnt = xpnt->next)
421 if ((xpnt->dir_flags & INHIBIT_ISO9660_ENTRY) == 0)
422 i++;
423 /*
424 * Next check to see if we have any relocated directories in
425 * this directory. The nlink field will include these as
426 * real directories when they are properly relocated.
427 * In the non-rockridge disk, the relocated entries appear as
428 * zero length files.
429 */
430 for (s_entry = dpnt->contents; s_entry;
431 s_entry = s_entry->next) {
432 if ((s_entry->de_flags & RELOCATED_DIRECTORY) != 0 &&
433 (s_entry->de_flags & INHIBIT_ISO9660_ENTRY) ==
434 0) {
435 i++;
436 }
437 }
438 /*
439 * Now update the field in the Rock Ridge entry.
440 */
441 update_nlink(dpnt->self, i + 2);
442
443 /*
444 * Update the '.' entry for this directory.
445 */
446 update_nlink(dpnt->contents, i + 2);
447
448 /*
449 * Update all of the '..' entries that point to this guy.
450 */
451 for (xpnt = dpnt->subdir; xpnt; xpnt = xpnt->next) {
452 update_nlink(xpnt->contents->next, i + 2);
453 }
454
455 if (dpnt->subdir)
457 dpnt = dpnt->next;
458 }
459 return (i+2);
460}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define INHIBIT_ISO9660_ENTRY
Definition: mkisofs.h:802
unsigned short dir_flags
Definition: mkisofs.h:285
struct directory_entry * self
Definition: mkisofs.h:272

Referenced by do_dir_nlink(), and update_dir_nlink().

◆ update_inode()

LOCAL void update_inode ( struct directory_entry s_entry,
int  value 
)

Definition at line 329 of file inode.c.

332{
333 unsigned char *pnt;
334 int len;
335
336 if (!rrip112)
337 return;
338
339 pnt = s_entry->rr_attributes;
340 len = s_entry->total_rr_attr_size;
341 pnt = parse_xa(pnt, &len, 0);
342 while (len >= 4) {
343 if (pnt[3] != 1 && pnt[3] != 2) {
345 _("**BAD RRVERSION (%d) in '%c%c' field (%2.2X %2.2X).\n"),
346 pnt[3], pnt[0], pnt[1], pnt[0], pnt[1]);
347 }
348 if (pnt[2] < 4) {
350 _("**BAD RRLEN (%d) in '%2.2s' field %2.2X %2.2X.\n"),
351 pnt[2], pnt, pnt[0], pnt[1]);
352 break;
353 }
354 if (pnt[0] == 'P' && pnt[1] == 'X') {
355 if ((pnt[2] & 0xFF) < 44) /* Paranoia */
356 return;
357 set_733((char *)pnt + 36, value);
358 break;
359 }
360 len -= pnt[2];
361 pnt += pnt[2];
362 }
363}
GLenum GLsizei len
Definition: glext.h:6722
BOOL rrip112
Definition: mkisofs.c:325
unsigned char * parse_xa(unsigned char *pnt, int *lenp, struct directory_entry *dpnt)
Definition: multi.c:169
unsigned char * rr_attributes
Definition: mkisofs.h:134
unsigned int total_rr_attr_size
Definition: mkisofs.h:136
Definition: pdh_main.c:94

Referenced by assign_inodes().

◆ update_nlink()

LOCAL void update_nlink ( struct directory_entry s_entry,
int  value 
)

Definition at line 369 of file inode.c.

372{
373 unsigned char *pnt;
374 int len;
375
376 pnt = s_entry->rr_attributes;
377 len = s_entry->total_rr_attr_size;
378 pnt = parse_xa(pnt, &len, 0);
379 while (len >= 4) {
380 if (pnt[3] != 1 && pnt[3] != 2) {
382 _("**BAD RRVERSION (%d) in '%c%c' field (%2.2X %2.2X).\n"),
383 pnt[3], pnt[0], pnt[1], pnt[0], pnt[1]);
384 }
385 if (pnt[2] < 4) {
387 _("**BAD RRLEN (%d) in '%2.2s' field %2.2X %2.2X.\n"),
388 pnt[2], pnt, pnt[0], pnt[1]);
389 break;
390 }
391 if (pnt[0] == 'P' && pnt[1] == 'X') {
392 set_733((char *)pnt + 12, value);
393 break;
394 }
395 len -= pnt[2];
396 pnt += pnt[2];
397 }
398}

Referenced by assign_linkcount(), do_dir_nlink(), and update_dir_nlink().

Variable Documentation

◆ null_ino_high

LOCAL UInt32_t null_ino_high

Definition at line 40 of file inode.c.

Referenced by do_inode().

◆ sccsid

UConst char sccsid[]
static
Initial value:
=
"@(#)inode.c 1.19 16/11/14 Copyright 2006-2015 J. Schilling"

Definition at line 4 of file inode.c.