Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 256234 | Differences between
and this patch

Collapse All | Expand All

(-)e2fsprogs-1.41.3/lib/ext2fs/Makefile.in (-1 / +5 lines)
Lines 74-80 Link Here
74
	unix_io.o \
74
	unix_io.o \
75
	unlink.o \
75
	unlink.o \
76
	valid_blk.o \
76
	valid_blk.o \
77
	version.o
77
	version.o \
78
	mint_io.o \
79
	xhdi.o
78
80
79
SRCS= ext2_err.c \
81
SRCS= ext2_err.c \
80
	$(srcdir)/alloc.c \
82
	$(srcdir)/alloc.c \
Lines 146-151 Link Here
146
	$(srcdir)/unlink.c \
148
	$(srcdir)/unlink.c \
147
	$(srcdir)/valid_blk.c \
149
	$(srcdir)/valid_blk.c \
148
	$(srcdir)/version.c \
150
	$(srcdir)/version.c \
151
 	$(srcdir)/mint_io.c \
152
 	$(srcdir)/xhdi.c \
149
	$(srcdir)/write_bb_file.c
153
	$(srcdir)/write_bb_file.c
150
154
151
HFILES= bitops.h ext2fs.h ext2_io.h ext2_fs.h ext2_ext_attr.h ext3_extents.h \
155
HFILES= bitops.h ext2fs.h ext2_io.h ext2_fs.h ext2_ext_attr.h ext3_extents.h \
(-)e2fsprogs-1.41.3/lib/ext2fs/bitops.h (-2 / +46 lines)
Lines 125-131 Link Here
125
 */
125
 */
126
#ifdef NO_INLINE_FUNCS
126
#ifdef NO_INLINE_FUNCS
127
#if (defined(__GNUC__) && (defined(__i386__) || defined(__i486__) || \
127
#if (defined(__GNUC__) && (defined(__i386__) || defined(__i486__) || \
128
			   defined(__i586__) || defined(__mc68000__)))
128
			   defined(__i586__) || defined(__mc68020__)))
129
	/* This prevents bitops.c from trying to include the C */
129
	/* This prevents bitops.c from trying to include the C */
130
	/* function version of these functions */
130
	/* function version of these functions */
131
#define _EXT2_HAVE_ASM_BITOPS_
131
#define _EXT2_HAVE_ASM_BITOPS_
Lines 246-252 Link Here
246
#endif	/* i386 */
246
#endif	/* i386 */
247
247
248
#if ((defined __GNUC__) && !defined(_EXT2_USE_C_VERSIONS_) && \
248
#if ((defined __GNUC__) && !defined(_EXT2_USE_C_VERSIONS_) && \
249
     (defined(__mc68000__)))
249
     (defined(__mc68020__)))
250
250
251
#define _EXT2_HAVE_ASM_BITOPS_
251
#define _EXT2_HAVE_ASM_BITOPS_
252
252
Lines 280-285 Link Here
280
	return retval;
280
	return retval;
281
}
281
}
282
282
283
#elif  defined(__mc68000__)
284
285
#define _EXT2_HAVE_ASM_BITOPS_
286
287
_INLINE_ int
288
ext2fs_set_bit (unsigned int nr, void *addr)
289
{
290
	int mask, retval;
291
	unsigned char *ADDR = (unsigned char *) addr;
292
	
293
	ADDR += nr >> 3;
294
	mask = 1UL << (nr & 0x07);
295
	retval = (mask & *ADDR) != 0;
296
	*ADDR |= mask;
297
	
298
	return retval;
299
}
300
301
_INLINE_ int
302
ext2fs_clear_bit (unsigned int nr, void *addr)
303
{
304
	int mask, retval;
305
	unsigned char *ADDR = (unsigned char *) addr;
306
	
307
	ADDR += nr >> 3;
308
	mask = 1UL << (nr & 0x07);
309
	retval = (mask & *ADDR) != 0;
310
	*ADDR &= ~mask;
311
	
312
	return retval;
313
}
314
315
_INLINE_ int
316
ext2fs_test_bit (unsigned int nr, const void *addr)
317
{
318
	int mask;
319
	const unsigned char *ADDR = (const unsigned char *) addr;
320
	
321
	ADDR += nr >> 3;
322
	mask = 1UL << (nr & 0x07);
323
	
324
	return ((mask & *ADDR) != 0);
325
}
326
283
#endif /* __mc68000__ */
327
#endif /* __mc68000__ */
284
328
285
329
(-)e2fsprogs-1.41.3/lib/ext2fs/ext2_fs.h (+4 lines)
Lines 307-312 Link Here
307
#define _IOT_ext2_new_group_input _IOT (_IOTS(__u32), 5, _IOTS(__u16), 2, 0, 0)
307
#define _IOT_ext2_new_group_input _IOT (_IOTS(__u32), 5, _IOTS(__u16), 2, 0, 0)
308
#endif
308
#endif
309
309
310
#ifndef __MINT__
310
#define EXT2_IOC_GETFLAGS		_IOR('f', 1, long)
311
#define EXT2_IOC_GETFLAGS		_IOR('f', 1, long)
311
#define EXT2_IOC_SETFLAGS		_IOW('f', 2, long)
312
#define EXT2_IOC_SETFLAGS		_IOW('f', 2, long)
312
#define EXT2_IOC_GETVERSION		_IOR('v', 1, long)
313
#define EXT2_IOC_GETVERSION		_IOR('v', 1, long)
Lines 316-321 Link Here
316
#define EXT2_IOC_GROUP_EXTEND		_IOW('f', 7, unsigned long)
317
#define EXT2_IOC_GROUP_EXTEND		_IOW('f', 7, unsigned long)
317
#define EXT2_IOC_GROUP_ADD		_IOW('f', 8,struct ext2_new_group_input)
318
#define EXT2_IOC_GROUP_ADD		_IOW('f', 8,struct ext2_new_group_input)
318
#define EXT4_IOC_GROUP_ADD		_IOW('f', 8,struct ext4_new_group_input)
319
#define EXT4_IOC_GROUP_ADD		_IOW('f', 8,struct ext4_new_group_input)
320
#else
321
#include <mint/dcntl.h>
322
#endif
319
323
320
/*
324
/*
321
 * Structure of an inode on the disk
325
 * Structure of an inode on the disk
(-)e2fsprogs-1.41.3/lib/ext2fs/getsize.c (+5 lines)
Lines 58-63 Link Here
58
#define BLKGETSIZE DKIOCGETBLOCKCOUNT32
58
#define BLKGETSIZE DKIOCGETBLOCKCOUNT32
59
#endif /* APPLE_DARWIN */
59
#endif /* APPLE_DARWIN */
60
60
61
#ifdef __MINT__
62
#include <sys/ioctl.h>
63
#include "mint_io.h"
64
#endif
65
61
#include "ext2_fs.h"
66
#include "ext2_fs.h"
62
#include "ext2fs.h"
67
#include "ext2fs.h"
63
68
(-)e2fsprogs-1.41.3/lib/ext2fs/llseek.c (+4 lines)
Lines 115-120 Link Here
115
115
116
#else /* !linux */
116
#else /* !linux */
117
117
118
#ifndef __MINT__
119
118
#ifndef EINVAL
120
#ifndef EINVAL
119
#define EINVAL EXT2_ET_INVALID_ARGUMENT
121
#define EINVAL EXT2_ET_INVALID_ARGUMENT
120
#endif
122
#endif
Lines 133-138 Link Here
133
#endif
135
#endif
134
}
136
}
135
137
138
#endif /* __MINT__ */
139
136
#endif 	/* linux */
140
#endif 	/* linux */
137
141
138
142
(-)e2fsprogs-1.41.3/lib/ext2fs/mint_io.c (+858 lines)
Line 0 Link Here
1
/*
2
 * $Id: mint_io.c,v 1.4 2003/11/18 21:05:42 standa Exp $
3
 * 
4
 * This file belongs to FreeMiNT. It's not in the original MiNT 1.12
5
 * distribution. See the file CHANGES for a detailed log of changes.
6
 * 
7
 * 
8
 * Copyright 2000 Frank Naumann <fnaumann@freemint.de>
9
 * All rights reserved.
10
 * 
11
 * This program is free software; you can redistribute it and/or modify
12
 * it under the terms of the GNU General Public License as published by
13
 * the Free Software Foundation; either version 2, or (at your option)
14
 * any later version.
15
 * 
16
 * This file is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 * 
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24
 * 
25
 * 
26
 * Author: Frank Naumann <fnaumann@freemint.de>
27
 * Started: 200-06-14
28
 * 
29
 * Please send suggestions, patches or bug reports to me or
30
 * the MiNT mailing list.
31
 * 
32
 */
33
34
# ifdef __MINT__
35
36
# include <assert.h>
37
# include <ctype.h>
38
# include <errno.h>
39
# include <fcntl.h>
40
# include <limits.h>
41
# include <stdarg.h>
42
# include <stdlib.h>
43
# include <stdio.h>
44
# include <string.h>
45
# include <time.h>
46
# include <unistd.h>
47
48
# include "et/com_err.h"
49
# include "ext2fs/ext2_io.h"
50
# include <sys/ioctl.h>
51
# include <sys/stat.h>
52
# define loff_t ext2_loff_t
53
# define llseek ext2fs_llseek
54
55
# include <mintbind.h>
56
# include "mint_io.h"
57
# include "xhdi.h"
58
59
60
# if 0
61
# define DEBUG(x)	printf x
62
# else
63
# define DEBUG(x)
64
# endif
65
66
67
/* prototypes */
68
69
int __open_v(const char *_filename, int iomode, va_list argp);
70
71
int open(__const char *__file, int __oflag, ...) __THROW;
72
int __open(__const char *__file, int __oflag, ...) __THROW;
73
74
int ioctl(int fd, int cmd, void *arg);
75
int __ioctl(int fd, int cmd, void *arg);
76
77
int fsync(int __fd) __THROW;
78
int __fsync(int __fd) __THROW;
79
80
__off_t lseek(int __fd, __off_t __offset, int __whence) __THROW;
81
__off_t __lseek(int __fd, __off_t __offset, int __whence) __THROW;
82
83
int close(int __fd) __THROW;
84
int __close(int __fd) __THROW;
85
86
ssize_t read(int __fd, void *__buf, size_t __nbytes) __THROW;
87
ssize_t __read(int __fd, void *__buf, size_t __nbytes) __THROW;
88
89
ssize_t write(int __fd, __const void *__buf, size_t __n) __THROW;
90
ssize_t __write(int __fd, __const void *__buf, size_t __n) __THROW;
91
92
int fstat(int __fd, struct stat *__buf) __THROW;
93
int __fstat(int __fd, struct stat *__buf) __THROW;
94
95
int stat(const char *filename, struct stat *st) __THROW;
96
97
98
struct device
99
{
100
	int used;
101
	
102
	int drv;
103
	int open_flags;
104
	
105
	ushort xhdi_maj;
106
	ushort xhdi_min;
107
	ulong xhdi_start;
108
	ulong xhdi_blocks;
109
	ulong xhdi_blocksize;
110
	char xhdi_id[4];
111
	
112
	loff_t pos;
113
};
114
115
# define DEVS 16
116
static struct device devs[DEVS];
117
118
static void
119
init_device(struct device *dev)
120
{
121
	dev->used = 0;
122
	
123
	dev->drv = -1;
124
	dev->open_flags = 0;
125
	dev->xhdi_maj = 0;
126
	dev->xhdi_min = 0;
127
	dev->xhdi_start = 0;
128
	dev->xhdi_blocks = 0;
129
	dev->xhdi_blocksize = 0;
130
	
131
	dev->pos = 0;
132
}
133
134
static inline void
135
init(void)
136
{
137
	static int done = 0;
138
	int i;
139
	
140
	if (done)
141
		return;
142
	
143
	assert(sizeof(loff_t) == sizeof(long long));
144
	
145
	for (i = 0; i < DEVS; i++)
146
		init_device (&devs[i]);
147
	
148
	init_XHDI();
149
	
150
	/* we are now initialized */
151
	done = 1;
152
}
153
154
static struct device *
155
get_device(int fd)
156
{
157
	struct device *dev;
158
	
159
	if ((fd < 1024) || (fd >= (1024 + DEVS)))
160
		return NULL;
161
	
162
	fd -= 1024;
163
	dev = &devs[fd];
164
	
165
	assert(dev->used);
166
	
167
	return dev;
168
}
169
170
static int
171
alloc_device(void)
172
{
173
	int i;
174
	
175
	for (i = 0; i < DEVS; i++)
176
	{
177
		struct device *dev = &devs[i];
178
		
179
		if (!dev->used)
180
		{
181
			dev->used = 1;
182
			return (i + 1024);
183
		}
184
	}
185
	
186
	__set_errno(ENOMEM);
187
	return -1;
188
}
189
190
static void
191
free_device(struct device *dev)
192
{
193
	assert(dev->used);
194
	
195
	init_device (dev);
196
}
197
198
199
int
200
open(const char *filename, int iomode, ...)
201
{
202
	const char *f = filename;
203
	struct device *mydev = NULL;
204
	int dev = -1;
205
	long ret;
206
	
207
	init();
208
	
209
	if (!filename)
210
	{
211
		__set_errno(EINVAL);
212
		return -1;
213
	}
214
	
215
	if ((f[1] == ':') && (f[2] == '\0'))
216
	{
217
		int c = tolower(f[0]);
218
		
219
		if (c >= 'a' && c <= 'z')
220
			c = c - 'a';
221
		else if (c >= '1' && c <= '6')
222
			c = 26 + (c - '1');
223
		
224
		if ((c >= 0) && (c < 32))
225
		{
226
			dev = alloc_device();
227
			if (dev != -1)
228
			{
229
				mydev = get_device(dev);
230
				assert(mydev);
231
				
232
				mydev->drv = c;
233
				mydev->open_flags = iomode;
234
			}
235
		}
236
	}
237
	
238
	if (dev == -1)
239
	{
240
		/* fall through */
241
		
242
		va_list args;
243
		int retval;
244
		
245
		va_start(args, iomode);
246
		retval = __open_v(filename, iomode, args);
247
		va_end(args);
248
		
249
		return retval;
250
	}
251
	
252
	if (mydev->open_flags == O_RDONLY)
253
	{
254
		DEBUG(("readonly mode!\n"));
255
		sync();
256
	}
257
	else if (Dlock(1, mydev->drv))
258
	{
259
		printf("Can't lock partition %c:!\n", mydev->drv+'A');
260
		
261
		if (mydev)
262
			free_device(mydev);
263
		
264
		__set_errno(EACCES);
265
		return -1;
266
	}
267
	
268
	__set_errno(EERROR);
269
	
270
	ret = XHGetVersion ();
271
	DEBUG(("XHDI version: %lx\n", ret));
272
	
273
	ret = XHInqDev2(mydev->drv,
274
			&mydev->xhdi_maj, &mydev->xhdi_min,
275
			&mydev->xhdi_start, NULL,
276
			&mydev->xhdi_blocks, mydev->xhdi_id);
277
	if (ret)
278
	{
279
		printf("XHInqDev2 [%c] fail (ret = %li, errno = %i)\n",
280
			mydev->drv+'A', ret, errno);
281
		ret = -1;
282
	}
283
	else
284
	{
285
		ret = XHInqTarget(mydev->xhdi_maj, mydev->xhdi_min,
286
				  &mydev->xhdi_blocksize, NULL, NULL);
287
		if (ret)
288
		{
289
			printf("XHInqTarget [%i:%i] fail (ret = %li, errno = %i)\n",
290
				mydev->xhdi_maj, mydev->xhdi_min, ret, errno);
291
			ret = -1;
292
		}
293
		else
294
		{
295
			char *xhdi_id = mydev->xhdi_id;
296
			
297
			if (       0
298
			        || ((xhdi_id[0] == 'G') && (xhdi_id[1] == 'E') && (xhdi_id[2] == 'M')) /* GEM */
299
				|| ((xhdi_id[0] == 'B') && (xhdi_id[1] == 'G') && (xhdi_id[2] == 'M')) /* BGM */
300
				|| ((xhdi_id[0] == 'F') && (xhdi_id[1] == '3') && (xhdi_id[2] == '2')) /* F32 */
301
				|| ((xhdi_id[0] == 'M') && (xhdi_id[1] == 'I') && (xhdi_id[2] == 'X')) /* MIX */
302
				|| ((xhdi_id[0] == 'R') && (xhdi_id[1] == 'A') && (xhdi_id[2] == 'W')) /* RAW */
303
				|| ((xhdi_id[0] == 'L') && (xhdi_id[1] == 'N') && (xhdi_id[2] == 'X')) /* LNX */
304
				|| ((xhdi_id[0] == '\0') && (xhdi_id[1] == 'D')))                  /* any DOS */
305
			{
306
				DEBUG(("Partition ok and accepted!\n"));
307
				DEBUG(("start = %lu, blocks = %lu, blocksize = %lu\n",
308
					mydev->xhdi_start, mydev->xhdi_blocks,
309
					mydev->xhdi_blocksize));
310
			}
311
			else
312
			{
313
				xhdi_id [3] = '\0';
314
				printf("Wrong partition ID [%s]!\n", xhdi_id);
315
				printf("Only 'RAW', 'LNX' and DOS partitions are supported.\n");
316
				
317
				__set_errno(EPERM);
318
				ret = -1;
319
			}
320
		}
321
	}
322
	
323
	if (ret)
324
	{
325
		if (mydev)
326
			free_device(mydev);
327
		
328
		dev = -1;
329
	}
330
	
331
	return dev;
332
}
333
334
int
335
close(int fd)
336
{
337
	struct device *mydev = get_device(fd);
338
	int ret = 0;
339
	
340
	if (!mydev)
341
		/* fall through */
342
		return __close(fd);
343
	
344
	if (mydev->open_flags == O_RDONLY)
345
	{
346
		;
347
	}
348
	else if (Dlock(0, mydev->drv))
349
	{
350
		printf("Can't unlock partition %c:!\n", 'A'+mydev->drv);
351
		
352
		__set_errno(EACCES);
353
		ret = -1;
354
	}
355
	
356
	free_device(mydev);
357
	return ret;
358
}
359
360
/* simple buffer */
361
static char buffer[1024L * 128];
362
static ulong buf_recno = 0;
363
static long buf_n = 0;
364
365
static long
366
rwabs_xhdi(struct device *mydev, ushort rw, void *buf, ulong size, ulong recno)
367
{
368
	ulong n = size / mydev->xhdi_blocksize;
369
	long r;
370
	
371
	assert((size % mydev->xhdi_blocksize) == 0);
372
	
373
	if (!n || (recno + n) > mydev->xhdi_blocks)
374
	{
375
		printf("rwabs_xhdi: access outside partition (drv = %c:)\n", 'A'+mydev->drv);
376
		exit(2);
377
	}
378
	
379
	if (n > 65535UL)
380
	{
381
		printf("rwabs_xhdi: n to large (drv = %c)\n", 'A'+mydev->drv);
382
		exit(2);
383
	}
384
	
385
	if (!rw && (buf_recno == recno) && (buf_n == n))
386
	{
387
		bcopy(buffer, buf, buf_n * mydev->xhdi_blocksize);
388
		return 0;
389
	}
390
	
391
	r = XHReadWrite (mydev->xhdi_maj, mydev->xhdi_min, rw, mydev->xhdi_start + recno, n, buf);
392
	
393
	if (!r && (n * mydev->xhdi_blocksize) <= sizeof(buffer))
394
	{
395
		bcopy(buf, buffer, n * mydev->xhdi_blocksize);
396
		
397
		buf_recno = recno;
398
		buf_n = n;
399
	}
400
	else
401
		buf_n = 0;
402
	
403
	return r;
404
}
405
406
# define max(a,b)	(a > b ? a : b)
407
# define min(a,b)	(a > b ? b : a)
408
409
int
410
read(int fd, void *_buf, size_t size)
411
{
412
	struct device *mydev = get_device(fd);
413
	
414
	if (!mydev)
415
		/* fall through */
416
		return __read(fd, _buf, size);
417
		
418
{
419
	char *buf = _buf;
420
	long todo;		/* characters remaining */
421
	long done;		/* characters processed */
422
	
423
	todo = size;
424
	done = 0;
425
	
426
	if (todo == 0)
427
		return 0;
428
	
429
	/* partial block copy
430
	 */
431
	if (mydev->pos % mydev->xhdi_blocksize)
432
	{
433
		char tmp[mydev->xhdi_blocksize];
434
		
435
		ulong recno = mydev->pos / mydev->xhdi_blocksize;
436
		ulong offset = mydev->pos % mydev->xhdi_blocksize;
437
		ulong data;
438
		long ret;
439
		
440
		ret = rwabs_xhdi(mydev, 0, tmp, mydev->xhdi_blocksize, recno);
441
		if (ret)
442
		{
443
			DEBUG(("read: partial part: read failure (r = %li, errno = %i)\n", ret, errno));
444
			goto out;
445
		}
446
		
447
		data = mydev->xhdi_blocksize - offset;
448
		data = min (todo, data);
449
		
450
		memcpy(buf, tmp + offset, data);
451
		
452
		buf += data;
453
		todo -= data;
454
		done += data;
455
		mydev->pos += data;
456
	}
457
	
458
	if (todo)
459
	{
460
		assert((todo > 0));
461
		assert((mydev->pos % mydev->xhdi_blocksize) == 0);
462
	}
463
	
464
	
465
	/* full blocks
466
	 */
467
	if (todo / mydev->xhdi_blocksize)
468
	{
469
		ulong recno = mydev->pos / mydev->xhdi_blocksize;
470
		ulong data = (todo / mydev->xhdi_blocksize) * mydev->xhdi_blocksize;
471
		long ret;
472
		
473
		ret = rwabs_xhdi (mydev, 0, buf, data, recno);
474
		if (ret)
475
		{
476
			DEBUG(("read: full blocks: read failure (r = %li, errno = %i)\n", ret, errno));
477
			goto out;
478
		}
479
		
480
		buf += data;
481
		todo -= data;
482
		done += data;
483
		mydev->pos += data;
484
	}
485
	
486
	if (todo)
487
	{
488
		assert((todo > 0) && (todo < mydev->xhdi_blocksize));
489
		assert((mydev->pos % mydev->xhdi_blocksize) == 0);
490
	}
491
	
492
	/* anything left?
493
	 */
494
	if (todo)
495
	{
496
		char tmp[mydev->xhdi_blocksize];
497
		
498
		ulong recno = mydev->pos / mydev->xhdi_blocksize;
499
		long ret;
500
		
501
		ret = rwabs_xhdi (mydev, 0, tmp, mydev->xhdi_blocksize, recno);
502
		if (ret)
503
		{
504
			DEBUG(("read: left part: read failure (r = %li, errno = %i)]\n", ret, errno));
505
			goto out;
506
		}
507
		
508
		memcpy(buf, tmp, todo);
509
		
510
		done += todo;
511
		mydev->pos += todo;
512
	}
513
	
514
	assert(done == size);
515
	
516
out:
517
	return done;
518
}
519
}
520
521
int
522
write(int fd, const void *_buf, size_t size)
523
{
524
	struct device *mydev = get_device(fd);
525
	
526
	if (!mydev)
527
		/* fall through */
528
		return __write(fd, _buf, size);
529
	
530
	if (mydev->open_flags == O_RDONLY)
531
	{
532
		__set_errno(EPERM);
533
		return -1;
534
	}
535
{
536
	const char *buf = _buf;
537
	long todo;		/* characters remaining */
538
	long done;		/* characters processed */
539
	
540
	todo = size;
541
	done = 0;
542
	
543
	if (todo == 0)
544
		return 0;
545
	
546
	/* partial block copy
547
	 */
548
	if (mydev->pos % mydev->xhdi_blocksize)
549
	{
550
		char tmp[mydev->xhdi_blocksize];
551
		
552
		ulong recno = mydev->pos / mydev->xhdi_blocksize;
553
		ulong offset = mydev->pos % mydev->xhdi_blocksize;
554
		ulong data;
555
		long ret;
556
		
557
		ret = rwabs_xhdi(mydev, 0, tmp, mydev->xhdi_blocksize, recno);
558
		if (ret)
559
		{
560
			DEBUG(("write: partial part: read failure (r = %li, errno = %i)\n", ret, errno));
561
			goto out;
562
		}
563
		
564
		data = mydev->xhdi_blocksize - offset;
565
		data = min (todo, data);
566
		
567
		memcpy(tmp + offset, buf, data);
568
		
569
		ret = rwabs_xhdi(mydev, 1, tmp, mydev->xhdi_blocksize, recno);
570
		if (ret)
571
		{
572
			DEBUG(("write: partial part: write failure (r = %li, errno = %i)\n", ret, errno));
573
			goto out;
574
		}
575
		
576
		buf += data;
577
		todo -= data;
578
		done += data;
579
		mydev->pos += data;
580
	}
581
	
582
	if (todo)
583
	{
584
		assert((todo > 0));
585
		assert((mydev->pos % mydev->xhdi_blocksize) == 0);
586
	}
587
	
588
	/* full blocks
589
	 */
590
	if (todo / mydev->xhdi_blocksize)
591
	{
592
		ulong recno = mydev->pos / mydev->xhdi_blocksize;
593
		ulong data = (todo / mydev->xhdi_blocksize) * mydev->xhdi_blocksize;
594
		long ret;
595
		
596
		ret = rwabs_xhdi(mydev, 1, (void *)buf, data, recno);
597
		if (ret)
598
		{
599
			DEBUG(("write: full blocks: write failure (r = %li, errno = %i)\n", ret, errno));
600
			goto out;
601
		}
602
		
603
		buf += data;
604
		todo -= data;
605
		done += data;
606
		mydev->pos += data;
607
	}
608
	
609
	if (todo)
610
	{
611
		assert((todo > 0) && (todo < mydev->xhdi_blocksize));
612
		assert((mydev->pos % mydev->xhdi_blocksize) == 0);
613
	}
614
	
615
	/* anything left?
616
	 */
617
	if (todo)
618
	{
619
		char tmp[mydev->xhdi_blocksize];
620
		
621
		ulong recno = mydev->pos / mydev->xhdi_blocksize;
622
		long ret;
623
		
624
		ret = rwabs_xhdi(mydev, 0, tmp, mydev->xhdi_blocksize, recno);
625
		if (ret)
626
		{
627
			DEBUG(("write: left part: read failure (r = %li, errno = %i)]\n", ret, errno));
628
			goto out;
629
		}
630
		
631
		memcpy(tmp, buf, todo);
632
		
633
		ret = rwabs_xhdi(mydev, 1, tmp, mydev->xhdi_blocksize, recno);
634
		if (ret)
635
		{
636
			DEBUG(("write: partial part: write failure (r = %li, errno = %i)\n", ret, errno));
637
			goto out;
638
		}
639
		
640
		done += todo;
641
		mydev->pos += todo;
642
	}
643
	
644
	assert(done == size);
645
	
646
out:
647
	return done;
648
}
649
}
650
651
int
652
ioctl(int fd, int cmd, void *arg)
653
{
654
	struct device *mydev = get_device(fd);
655
	
656
	if (!mydev)
657
		/* fall through */
658
		return __ioctl(fd, cmd, arg);
659
	
660
	DEBUG(("ioctl: cmd = %i\n", cmd));
661
	
662
	switch (cmd)
663
	{
664
		case BLKGETSIZE:
665
		{
666
			ulong *size = arg;
667
			*size = mydev->xhdi_blocks * (mydev->xhdi_blocksize / 512);
668
			break;
669
		}
670
		case BLOCKSIZE:
671
		{
672
			ulong *block_size = arg;
673
			*block_size = mydev->xhdi_blocksize;
674
			break;
675
		}
676
		default:
677
			__set_errno(EINVAL);
678
			return -1;
679
	}
680
	
681
	return 0;
682
}
683
684
int
685
fstat(int fd, struct stat *st)
686
{
687
	struct device *mydev = get_device(fd);
688
	
689
	if (!mydev)
690
		/* fall through */
691
		return __fstat(fd, st);
692
	
693
	bzero(st, sizeof(*st));
694
	
695
	st->st_dev	= mydev->xhdi_maj;
696
	st->st_ino	= mydev->drv;
697
	st->st_mode	= S_IFBLK | S_IRUSR | S_IWUSR;
698
	st->st_nlink	= 1;
699
	st->st_uid	= 0;
700
	st->st_gid	= 0;
701
	st->st_rdev	= mydev->xhdi_min;
702
	st->st_atime	= time (NULL);
703
	st->st_mtime	= time (NULL);
704
	st->st_ctime	= time (NULL);
705
	st->st_size	= (int64_t) mydev->xhdi_blocks * mydev->xhdi_blocksize;
706
	st->st_blocks	= (int64_t) mydev->xhdi_blocks * mydev->xhdi_blocksize / 512;
707
	st->st_blksize	= mydev->xhdi_blocksize;
708
	st->st_flags	= 0;
709
	st->st_gen	= 0;
710
	
711
	return 0;
712
}
713
714
int
715
stat(const char *filename, struct stat *st)
716
{
717
	struct device *mydev;
718
	int fd, res;
719
	
720
	fd = open(filename, O_RDONLY);
721
	if (fd == -1)
722
		return -1;
723
724
	mydev = get_device(fd);
725
	if (!mydev)
726
	{
727
		close(fd);
728
		
729
		/* fall through */
730
		return __stat(filename, st);
731
	}
732
	
733
	res = fstat(fd, st); 
734
	close(fd);
735
	
736
	return res;
737
}
738
739
int
740
fsync(int fd)
741
{
742
	struct device *mydev = get_device(fd);
743
	
744
	if (!mydev)
745
		/* fall through */
746
		return __fsync(fd);
747
	
748
	/* nothing todo */
749
	return 0;
750
}
751
752
loff_t llseek(int fd, loff_t offset, int origin);
753
754
loff_t
755
llseek(int fd, loff_t offset, int origin)
756
{
757
	struct device *mydev = get_device(fd);
758
	
759
	if (!mydev)
760
		/* fall through */
761
		return __lseek(fd, (off_t) offset, origin);
762
	
763
	
764
	switch (origin)
765
	{
766
		case SEEK_SET:
767
			break;
768
		case SEEK_CUR:
769
			offset += mydev->pos;
770
			break;
771
		case SEEK_END:
772
			offset += (int64_t) mydev->xhdi_blocks * mydev->xhdi_blocksize;
773
			break;
774
		default:
775
			return -1;
776
	}
777
	
778
	if (offset > (loff_t) mydev->xhdi_blocks * mydev->xhdi_blocksize)
779
	{
780
		__set_errno(EINVAL);
781
		return -1;
782
	}
783
	
784
	mydev->pos = offset;
785
	return mydev->pos;
786
}
787
788
loff_t lseek64(int fd, loff_t offset, int origin);
789
790
loff_t
791
lseek64(int fd, loff_t offset, int origin)
792
{
793
	return llseek(fd, offset, origin);
794
}
795
796
__off_t
797
lseek(int fd, __off_t offset, int mode)
798
{
799
	struct device *mydev = get_device(fd);
800
	
801
	if (!mydev)
802
		/* fall through */
803
		return __lseek(fd, offset, mode);
804
	
805
{
806
	loff_t _offset = offset;
807
	
808
	switch (mode)
809
	{
810
		case SEEK_SET:
811
			break;
812
		case SEEK_CUR:
813
			_offset += mydev->pos;
814
			break;
815
		case SEEK_END:
816
			_offset += (loff_t) mydev->xhdi_blocks * mydev->xhdi_blocksize;
817
			break;
818
		default:
819
			return -1;
820
	}
821
	
822
	if (_offset > LONG_MAX)
823
	{
824
		__set_errno(EINVAL);
825
		return -1;
826
	}
827
	
828
	if (_offset > (loff_t) mydev->xhdi_blocks * mydev->xhdi_blocksize)
829
	{
830
		__set_errno(EINVAL);
831
		return -1;
832
	}
833
	
834
	mydev->pos = _offset;
835
	return (off_t) mydev->pos;
836
}
837
}
838
839
int gettype(int fd);
840
841
int
842
gettype(int fd)
843
{
844
	struct device *mydev = get_device(fd);
845
	char *xhdi_id;
846
	
847
	if (!mydev)
848
		return -1;
849
850
	/* Get filesystem type by XHDI ID */
851
	xhdi_id = mydev->xhdi_id;
852
	if ((xhdi_id[0] == '\0') && (xhdi_id[1] == 'D'))
853
		return 0;   /* DOS (\0D*) */
854
	else
855
		return 1;   /* Atari (GEM/GBM) */
856
}
857
858
# endif /* __MINT__ */
(-)e2fsprogs-1.41.3/lib/ext2fs/mint_io.h (+22 lines)
Line 0 Link Here
1
/*
2
 * mint_io.h
3
 *
4
 * Copyright (C) 2000 Frank Naumann <fnaumann@freemint.de>.
5
 *
6
 * %Begin-Header%
7
 * This file may be redistributed under the terms of the GNU Public
8
 * License.
9
 * %End-Header%
10
 */
11
12
# ifdef __MINT__
13
14
# ifndef _mint_io_h
15
# define _mint_io_h
16
17
# define BLKGETSIZE		(('b'<< 8) | 1)
18
# define BLOCKSIZE		(('b'<< 8) | 2)
19
20
# endif /* _mint_io_h */
21
22
# endif /* __MINT__ */
(-)e2fsprogs-1.41.3/lib/ext2fs/unix_io.c (+16 lines)
Lines 51-59 Link Here
51
#define BLKROGET   _IO(0x12, 94) /* Get read-only status (0 = read_write).  */
51
#define BLKROGET   _IO(0x12, 94) /* Get read-only status (0 = read_write).  */
52
#endif
52
#endif
53
53
54
#ifdef __MINT__
55
#include <sys/ioctl.h>
56
#include "mint_io.h"
57
#endif
58
54
#include "ext2_fs.h"
59
#include "ext2_fs.h"
55
#include "ext2fs.h"
60
#include "ext2fs.h"
56
61
62
57
/*
63
/*
58
 * For checking structure magic numbers...
64
 * For checking structure magic numbers...
59
 */
65
 */
Lines 512-517 Link Here
512
		}
518
		}
513
	}
519
	}
514
#endif
520
#endif
521
	
522
#ifdef __MINT__
523
	{
524
		unsigned long block_size;
525
		retval = ioctl(data->dev, BLOCKSIZE, &block_size);
526
		if (retval == 0)
527
			io->block_size = block_size;
528
	}
529
#endif
530
	
515
	*channel = io;
531
	*channel = io;
516
	return 0;
532
	return 0;
517
533
(-)e2fsprogs-1.41.3/lib/ext2fs/xhdi.c (+577 lines)
Line 0 Link Here
1
/*
2
 * Copyright 2000 Frank Naumann <fnaumann@freemint.de>
3
 * All rights reserved.
4
 * 
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2, or (at your option)
8
 * any later version.
9
 * 
10
 * This file is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 * 
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
 * 
19
 * 
20
 * Started:      2000-05-02
21
 * 
22
 * Changes:
23
 * 
24
 * 0.1:
25
 * 
26
 * fix: Cookie handling stuff; use Getcookie from MiNT-Lib now
27
 *      requires an actual MiNT-Lib (>= PL49)
28
 * 
29
 * 0.0:
30
 * 
31
 * - inital version
32
 * 
33
 */
34
35
# include "xhdi.h"
36
37
# include <stdio.h>
38
# include <stdlib.h>
39
# include <errno.h>
40
# include <mintbind.h>
41
# include <mint/cookie.h>
42
43
44
/*
45
 * internal usage
46
 */
47
48
/* dummy routine */
49
static long
50
XHDIfail (void)
51
{
52
	return -ENOSYS;
53
}
54
55
/* XHDI handler function */
56
static long (*XHDI)() = XHDIfail;
57
58
ushort XHDI_installed = 0;
59
60
61
# define C_XHDI		0x58484449L
62
# define XHDIMAGIC	0x27011992L
63
64
/* initalize flag */
65
static ushort init = 1;
66
67
long
68
init_XHDI (void)
69
{
70
	long *val;
71
	long r;
72
	
73
	init = 0;
74
	
75
	r = Getcookie (C_XHDI, (long *) &val);
76
	if (r == C_FOUND)
77
	{
78
		long *magic_test = val;
79
		
80
		/* check magic */
81
		if (magic_test)
82
		{
83
			magic_test--;
84
			if (*magic_test == XHDIMAGIC)
85
			{
86
				XHDI = val;
87
			}
88
		}
89
	}
90
	
91
	r = XHGetVersion ();
92
	if (r < 0)
93
	{
94
		perror ("XHGetVersion");
95
		
96
		XHDI = XHDIfail;
97
		return r;
98
	}
99
	
100
	/* we need at least XHDI 1.10 */
101
	if (r >= 0x110)
102
	{
103
		XHDI_installed = r;
104
		return 0;
105
	}
106
	
107
	XHDI = XHDIfail;
108
	return -1;
109
}
110
111
112
/*
113
 * XHDI wrapper routines
114
 */
115
116
# define CALL \
117
	long oldstack = 0;		\
118
	long r;				\
119
					\
120
	if (init) init_XHDI ();		\
121
					\
122
	if (!Super (1L))		\
123
		oldstack = Super (0L);	\
124
					\
125
	r = XHDI (args);		\
126
	if (r < 0)			\
127
	{				\
128
		__set_errno (-r);	\
129
		r = -1;			\
130
	}				\
131
					\
132
	if (oldstack)			\
133
		Super (oldstack);	\
134
					\
135
	return r
136
137
long
138
XHGetVersion (void)
139
{
140
	struct args_XHGetVersion
141
	{
142
		ushort	opcode;
143
	}
144
	args = 
145
	{
146
		0
147
	};
148
	
149
	CALL;
150
}
151
152
long
153
XHInqTarget (ushort major, ushort minor, ulong *block_size, ulong *device_flags, char *product_name)
154
{
155
	struct args_XHInqTarget
156
	{
157
		ushort	opcode;
158
		ushort	major;
159
		ushort	minor;
160
		ulong	*block_size;
161
		ulong	*device_flags;
162
		char	*product_name;
163
	}
164
	args =
165
	{
166
		1,
167
		major,
168
		minor,
169
		block_size,
170
		device_flags,
171
		product_name
172
	};
173
	
174
	CALL;
175
}
176
177
long
178
XHReserve (ushort major, ushort minor, ushort do_reserve, ushort key)
179
{
180
	struct args_XHReserve
181
	{
182
		ushort	opcode;
183
		ushort	major;
184
		ushort	minor;
185
		ushort	do_reserve;
186
		ushort	key;
187
	}
188
	args =
189
	{
190
		2,
191
		major,
192
		minor,
193
		do_reserve,
194
		key
195
	};
196
	
197
	CALL;
198
}
199
200
long
201
XHLock (ushort major, ushort minor, ushort do_lock, ushort key)
202
{
203
	struct args_XHLock
204
	{
205
		ushort	opcode;
206
		ushort	major;
207
		ushort	minor;
208
		ushort	do_lock;
209
		ushort	key;
210
	}
211
	args =
212
	{
213
		3,
214
		major,
215
		minor,
216
		do_lock,
217
		key
218
	};
219
	
220
	CALL;
221
}
222
223
long
224
XHStop (ushort major, ushort minor, ushort do_stop, ushort key)
225
{
226
	struct args_XHStop
227
	{
228
		ushort	opcode;
229
		ushort	major;
230
		ushort	minor;
231
		ushort	do_stop;
232
		ushort	key;
233
	}
234
	args =
235
	{
236
		4,
237
		major,
238
		minor,
239
		do_stop,
240
		key
241
	};
242
	
243
	CALL;
244
}
245
246
long
247
XHEject (ushort major, ushort minor, ushort do_eject, ushort key)
248
{
249
	struct args_XHEject
250
	{
251
		ushort	opcode;
252
		ushort	major;
253
		ushort	minor;
254
		ushort	do_eject;
255
		ushort	key;
256
	}
257
	args =
258
	{
259
		5,
260
		major,
261
		minor,
262
		do_eject,
263
		key
264
	};
265
	
266
	CALL;
267
}
268
269
long
270
XHDrvMap (void)
271
{
272
	struct args_XHDrvMap
273
	{
274
		ushort	opcode;
275
	}
276
	args =
277
	{
278
		6
279
	};
280
	
281
	CALL;
282
}
283
284
long
285
XHInqDev (ushort bios, ushort *major, ushort *minor, ulong *start, __BPB *bpb)
286
{
287
	struct args_XHInqDev
288
	{
289
		ushort	opcode;
290
		ushort	bios;
291
		ushort	*major;
292
		ushort	*minor;
293
		ulong	*start;
294
		__BPB	*bpb;
295
	}
296
	args =
297
	{
298
		7,
299
		bios,
300
		major,
301
		minor,
302
		start,
303
		bpb
304
	};
305
	
306
	CALL;
307
}
308
309
long
310
XHInqDriver (ushort bios, char *name, char *version, char *company, ushort *ahdi_version, ushort *maxIPL)
311
{
312
	struct args_XHInqDriver
313
	{
314
		ushort	opcode;
315
		ushort	bios;
316
		char	*name;
317
		char	*version;
318
		char	*company;
319
		ushort	*ahdi_version;
320
		ushort	*maxIPL;
321
	}
322
	args =
323
	{
324
		8,
325
		bios,
326
		name,
327
		version,
328
		company,
329
		ahdi_version,
330
		maxIPL
331
	};
332
	
333
	CALL;
334
}
335
336
long
337
XHNewCookie (void *newcookie)
338
{
339
	struct args_XHNewCookie
340
	{
341
		ushort	opcode;
342
		void	*newcookie;
343
	}
344
	args =
345
	{
346
		9,
347
		newcookie
348
	};
349
	
350
	CALL;
351
}
352
353
long
354
XHReadWrite (ushort major, ushort minor, ushort rwflag, ulong recno, ushort count, void *buf)
355
{
356
	struct args_XHReadWrite
357
	{
358
		ushort	opcode;
359
		ushort	major;
360
		ushort	minor;
361
		ushort	rwflag;
362
		ulong	recno;
363
		ushort	count;
364
		void	*buf;
365
	}
366
	args =
367
	{
368
		10,
369
		major,
370
		minor,
371
		rwflag,
372
		recno,
373
		count,
374
		buf
375
	};
376
	
377
	CALL;
378
}
379
380
long
381
XHInqTarget2 (ushort major, ushort minor, ulong *block_size, ulong *device_flags, char *product_name, ushort stringlen)
382
{
383
	struct args_XHInqTarget2
384
	{
385
		ushort	opcode;
386
		ushort	major;
387
		ushort	minor;
388
		ulong	*block_size;
389
		ulong	*device_flags;
390
		char	*product_name;
391
		ushort	stringlen;
392
	}
393
	args =
394
	{
395
		11,
396
		major,
397
		minor,
398
		block_size,
399
		device_flags,
400
		product_name,
401
		stringlen
402
	};
403
	
404
	CALL;
405
}
406
407
long
408
XHInqDev2 (ushort bios, ushort *major, ushort *minor, ulong *start, __BPB *bpb, ulong *blocks, char *partid)
409
{
410
	struct args_XHInqDev2
411
	{
412
		ushort	opcode;
413
		ushort	bios;
414
		ushort	*major;
415
		ushort	*minor;
416
		ulong	*start;
417
		__BPB	*bpb;
418
		ulong	*blocks;
419
		char	*partid;
420
	}
421
	args =
422
	{
423
		12,
424
		bios,
425
		major,
426
		minor,
427
		start,
428
		bpb,
429
		blocks,
430
		partid
431
	};
432
	
433
	CALL;
434
}
435
436
long
437
XHDriverSpecial (ulong key1, ulong key2, ushort subopcode, void *data)
438
{
439
	struct args_XHDriverSpecial
440
	{
441
		ushort	opcode;
442
		ulong	key1;
443
		ulong	key2;
444
		ushort	subopcode;
445
		void 	*data;
446
	}
447
	args =
448
	{
449
		13,
450
		key1,
451
		key2,
452
		subopcode,
453
		data
454
	};
455
	
456
	CALL;
457
}
458
459
long
460
XHGetCapacity (ushort major, ushort minor, ulong *blocks, ulong *bs)
461
{
462
	struct args_XHGetCapacity
463
	{
464
		ushort	opcode;
465
		ushort	major;
466
		ushort	minor;
467
		ulong	*blocks;
468
		ulong	*bs;
469
	}
470
	args =
471
	{
472
		14,
473
		major,
474
		minor,
475
		blocks,
476
		bs
477
	};
478
	
479
	CALL;
480
}
481
482
long
483
XHMediumChanged (ushort major, ushort minor)
484
{
485
	struct args_XHMediumChanged
486
	{
487
		ushort	opcode;
488
		ushort	major;
489
		ushort	minor;
490
	}
491
	args =
492
	{
493
		15,
494
		major,
495
		minor
496
	};
497
	
498
	CALL;
499
}
500
501
long
502
XHMiNTInfo (ushort op, void *data)
503
{
504
	struct args_XHMiNTInfo
505
	{
506
		ushort	opcode;
507
		ushort	op;
508
		void	*data;
509
	}
510
	args =
511
	{
512
		16,
513
		op,
514
		data
515
	};
516
	
517
	CALL;
518
}
519
520
long
521
XHDOSLimits (ushort which, ulong limit)
522
{
523
	struct args_XHDOSLimits
524
	{
525
		ushort	opcode;
526
		ushort	which;
527
		ulong	limit;
528
	}
529
	args =
530
	{
531
		17,
532
		which,
533
		limit
534
	};
535
	
536
	CALL;
537
}
538
539
long
540
XHLastAccess (ushort major, ushort minor, ulong *ms)
541
{
542
	struct args_XHLastAccess
543
	{
544
		ushort	opcode;
545
		ushort	major;
546
		ushort	minor;
547
		ulong	*ms;
548
	}
549
	args =
550
	{
551
		18,
552
		major,
553
		minor,
554
		ms
555
	};
556
	
557
	CALL;
558
}
559
560
long
561
XHReaccess (ushort major, ushort minor)
562
{
563
	struct args_XHReaccess
564
	{
565
		ushort	opcode;
566
		ushort	major;
567
		ushort	minor;
568
	}
569
	args =
570
	{
571
		19,
572
		major,
573
		minor
574
	};
575
	
576
	CALL;
577
}
(-)e2fsprogs-1.41.3/lib/ext2fs/xhdi.h (+144 lines)
Line 0 Link Here
1
/*
2
 * Copyright 2000 Frank Naumann <fnaumann@freemint.de>
3
 * All rights reserved.
4
 * 
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2, or (at your option)
8
 * any later version.
9
 * 
10
 * This file is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 * 
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
 * 
19
 */
20
21
# ifndef _xhdi_h
22
# define _xhdi_h
23
24
# include <sys/types.h>
25
26
typedef unsigned char uchar;
27
28
29
/*
30
 * BIOS parameter block (osbind.h is buggy)
31
 */
32
33
typedef struct
34
{
35
	ushort	recsiz;		/* bytes per sector */
36
	short	clsiz;		/* sectors per cluster */
37
	ushort	clsizb;		/* bytes per cluster */
38
	short	rdlen;		/* root directory size */
39
	short	fsiz;		/* size of FAT */
40
	short	fatrec;		/* startsector of second FAT */
41
	short	datrec;		/* first data sector */
42
	ushort	numcl;		/* total number of clusters */
43
	short	bflags;		/* some flags */
44
	
45
} __BPB;
46
47
48
/*
49
 * Extended BIOS Parameter Block (XHDI)
50
 */
51
52
typedef struct
53
{
54
	ushort	recsiz;		/* bytes per sector */
55
	short	clsiz;		/* sectors per cluster */
56
	ushort	clsizb;		/* bytes per cluster */
57
	short	rdlen;		/* root directory size or 0 if FAT32 */
58
	short	fsiz;		/* size of FAT or 0 if FAT32 */
59
	short	fatrec;		/* startsector of second FAT or 0 if FAT32 */
60
	short	datrec;		/* first data sector or 0 if FAT32 */
61
	ushort	numcl;		/* total number of clusters or 0 if FAT32 */
62
	short	bflags;		/* bit 0: 0 = FAT12, 1 = FAT16
63
				 * bit 1: 0 = 2 FATs, 1 = 1 FAT
64
				 * bit 2: 0 = BPB, 1 = EXTENDED_BPB
65
				 */
66
	
67
	/* Ab hier undokumentiert, nur A: und B:! */
68
	short	ntracks;	/* Anzahl Spuren */
69
	short	nsides;		/* Anzahl Seiten */
70
	short	spc;		/* Sektoren pro Zylinder */
71
	short	spt;		/* Sektoren pro Spur */
72
	ushort	nhid;		/* Anzahl versteckte Sektoren */
73
	uchar	ser[3];		/* Seriennummer */
74
	uchar	serms[4];	/* ab TOS 2.06: MS-DOS-4.0-Seriennummer */
75
	char	unused;
76
	
77
	/* if bit 2 of bflags are set */
78
	long	l_recsiz;	/* bytes per sector */
79
	long	l_clsiz;	/* sectors per cluster */
80
	long	l_clsizb;	/* bytes per cluster */
81
	long	l_rdlen;	/* root directory size */
82
	long	l_fsiz;		/* size of FAT */
83
	long	l_fatrec;	/* startsector of second FAT */
84
	long	l_datrec;	/* first data sector */
85
	long	l_numcl;	/* total number of clusters */
86
	long	l_rdstcl;	/* if FAT32: startcluster of root directory
87
				 * otherwise 0
88
				 */
89
} __xhdi_BPB;
90
91
92
# define XH_TARGET_STOPPABLE	0x00000001L
93
# define XH_TARGET_REMOVABLE	0x00000002L
94
# define XH_TARGET_LOCKABLE	0x00000004L
95
# define XH_TARGET_EJECTABLE	0x00000008L
96
# define XH_TARGET_LOCKED	0x20000000L
97
# define XH_TARGET_STOPPED	0x40000000L
98
# define XH_TARGET_RESERVED	0x80000000L
99
100
# define XH_MI_SETKERINFO	0
101
# define XH_MI_GETKERINFO	1
102
103
# define XH_DL_SECSIZ		0
104
# define XH_DL_MINFAT		1
105
# define XH_DL_MAXFAT		2
106
# define XH_DL_MINSPC		3
107
# define XH_DL_MAXSPC		4
108
# define XH_DL_CLUSTS		5
109
# define XH_DL_MAXSEC		6
110
# define XH_DL_DRIVES		7
111
# define XH_DL_CLSIZB		8
112
# define XH_DL_RDLEN		9
113
# define XH_DL_CLUSTS12		12
114
# define XH_DL_CLUSTS32		13
115
# define XH_DL_BFLAGS		14
116
117
118
extern ushort XHDI_installed;
119
120
long	init_XHDI	(void);
121
122
long	XHGetVersion	(void);
123
long	XHInqTarget	(ushort major, ushort minor, ulong *block_size, ulong *device_flags, char *product_name);
124
long	XHReserve	(ushort major, ushort minor, ushort do_reserve, ushort key);
125
long	XHLock		(ushort major, ushort minor, ushort do_lock, ushort key);
126
long	XHStop		(ushort major, ushort minor, ushort do_stop, ushort key);
127
long	XHEject		(ushort major, ushort minor, ushort do_eject, ushort key);
128
long	XHDrvMap	(void);
129
long	XHInqDev	(ushort bios, ushort *major, ushort *minor, ulong *start, __BPB *bpb);
130
long	XHInqDriver	(ushort bios, char *name, char *version, char *company, ushort *ahdi_version, ushort *maxIPL);
131
long	XHNewCookie	(void *newcookie);
132
long	XHReadWrite	(ushort major, ushort minor, ushort rwflag, ulong recno, ushort count, void *buf);
133
long	XHInqTarget2	(ushort major, ushort minor, ulong *block_size, ulong *device_flags, char *product_name, ushort stringlen);
134
long	XHInqDev2	(ushort bios, ushort *major, ushort *minor, ulong *start, __BPB *bpb, ulong *blocks, char *partid);
135
long	XHDriverSpecial	(ulong key1, ulong key2, ushort subopcode, void *data);
136
long	XHGetCapacity	(ushort major, ushort minor, ulong *blocks, ulong *bs);
137
long	XHMediumChanged	(ushort major, ushort minor);
138
long	XHMiNTInfo	(ushort op, void *data);
139
long	XHDOSLimits	(ushort which, ulong limit);
140
long	XHLastAccess	(ushort major, ushort minor, ulong *ms);
141
long	XHReaccess	(ushort major, ushort minor);
142
143
144
# endif /* _xhdi_h */
(-)e2fsprogs-1.41.3/misc/e2undo.c (+1 lines)
Lines 19-24 Link Here
19
#if HAVE_ERRNO_H
19
#if HAVE_ERRNO_H
20
#include <errno.h>
20
#include <errno.h>
21
#endif
21
#endif
22
#include <sys/types.h>
22
#include "ext2fs/tdb.h"
23
#include "ext2fs/tdb.h"
23
#include "ext2fs/ext2fs.h"
24
#include "ext2fs/ext2fs.h"
24
#include "nls-enable.h"
25
#include "nls-enable.h"
(-)e2fsprogs-1.41.3/misc/e2initrd_helper.c (-10 / +10 lines)
Lines 50-56 Link Here
50
	int	ptr;
50
	int	ptr;
51
};
51
};
52
52
53
struct fs_info {
53
struct _fs_info {
54
	char  *device;
54
	char  *device;
55
	char  *mountpt;
55
	char  *mountpt;
56
	char  *type;
56
	char  *type;
Lines 58-64 Link Here
58
	int   freq;
58
	int   freq;
59
	int   passno;
59
	int   passno;
60
	int   flags;
60
	int   flags;
61
	struct fs_info *next;
61
	struct _fs_info *next;
62
};
62
};
63
63
64
static void usage(void)
64
static void usage(void)
Lines 230-236 Link Here
230
	*q = 0;
230
	*q = 0;
231
}
231
}
232
232
233
static int parse_fstab_line(char *line, struct fs_info *fs)
233
static int parse_fstab_line(char *line, struct _fs_info *fs)
234
{
234
{
235
	char	*dev, *device, *mntpnt, *type, *opts, *freq, *passno, *cp;
235
	char	*dev, *device, *mntpnt, *type, *opts, *freq, *passno, *cp;
236
236
Lines 280-286 Link Here
280
	return 0;
280
	return 0;
281
}
281
}
282
282
283
static void free_fstab_line(struct fs_info *fs)
283
static void free_fstab_line(struct _fs_info *fs)
284
{
284
{
285
	if (fs->device)
285
	if (fs->device)
286
		fs->device = 0;
286
		fs->device = 0;
Lines 290-296 Link Here
290
		fs->type = 0;
290
		fs->type = 0;
291
	if (fs->opts)
291
	if (fs->opts)
292
		fs->opts = 0;
292
		fs->opts = 0;
293
	memset(fs, 0, sizeof(struct fs_info));
293
	memset(fs, 0, sizeof(struct _fs_info));
294
}
294
}
295
295
296
296
Lines 334-340 Link Here
334
	errcode_t retval;
334
	errcode_t retval;
335
	struct mem_file file;
335
	struct mem_file file;
336
	char 		*buf;
336
	char 		*buf;
337
	struct fs_info fs_info;
337
	struct _fs_info _fs_info;
338
	int		ret;
338
	int		ret;
339
339
340
	retval = get_file(fs, "/etc/fstab", &file);
340
	retval = get_file(fs, "/etc/fstab", &file);
Lines 344-357 Link Here
344
		if (!buf)
344
		if (!buf)
345
			continue;
345
			continue;
346
346
347
		ret = parse_fstab_line(buf, &fs_info);
347
		ret = parse_fstab_line(buf, &_fs_info);
348
		if (ret < 0)
348
		if (ret < 0)
349
			goto next_line;
349
			goto next_line;
350
350
351
		if (!strcmp(fs_info.mountpt, "/"))
351
		if (!strcmp(_fs_info.mountpt, "/"))
352
			printf("%s\n", fs_info.type);
352
			printf("%s\n", _fs_info.type);
353
353
354
		free_fstab_line(&fs_info);
354
		free_fstab_line(&_fs_info);
355
355
356
	next_line:
356
	next_line:
357
		free(buf);
357
		free(buf);
(-)e2fsprogs-1.41.3/misc/mke2fs.c (+35 lines)
Lines 1819-1824 Link Here
1819
	return retval;
1819
	return retval;
1820
}
1820
}
1821
1821
1822
#ifdef __MINT__
1823
void
1824
warn (const char *drv)
1825
{
1826
	char c;
1827
	int check;
1828
	
1829
	check = open (drv, O_RDONLY);
1830
	if (check == -1)
1831
		return;
1832
	
1833
	close (check);
1834
	
1835
	if (check < 1024)
1836
		return;
1837
	
1838
	fprintf (stderr, "\n");
1839
	fprintf (stderr, "WARNING: THIS WILL TOTALLY DESTROY ANY DATA ON %s:\n", drv);
1840
	fprintf (stderr, "Are you ABSOLUTELY SURE you want to do this? (y/n) ");
1841
	scanf ("%c", &c);
1842
	fprintf (stderr, "\n");
1843
	
1844
	if (c == 'y' || c == 'Y')
1845
		return;
1846
	
1847
	fprintf (stderr, "Aborted\n");
1848
	exit (1);
1849
}
1850
#endif
1851
1822
int main (int argc, char *argv[])
1852
int main (int argc, char *argv[])
1823
{
1853
{
1824
	errcode_t	retval = 0;
1854
	errcode_t	retval = 0;
Lines 1839-1844 Link Here
1839
#endif
1869
#endif
1840
	PRS(argc, argv);
1870
	PRS(argc, argv);
1841
1871
1872
#ifdef __MINT__
1873
	if (!quiet)
1874
		warn (device_name);
1875
#endif
1876
1842
#ifdef CONFIG_TESTIO_DEBUG
1877
#ifdef CONFIG_TESTIO_DEBUG
1843
	if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_BLOCK")) {
1878
	if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_BLOCK")) {
1844
		io_ptr = test_io_manager;
1879
		io_ptr = test_io_manager;

Return to bug 256234