|
|
1.1 root 1: /*
2: * UAE - The Un*x Amiga Emulator
3: *
4: * Unix file system handler for AmigaDOS
5: *
1.1.1.3 root 6: * Copyright 1996 Ed Hanway
7: * Copyright 1996, 1997 Bernd Schmidt
1.1 root 8: *
1.1.1.3 root 9: * Version 0.4: 970308
1.1 root 10: *
11: * Based on example code (c) 1988 The Software Distillery
12: * and published in Transactor for the Amiga, Volume 2, Issues 2-5.
13: * (May - August 1989)
14: *
15: * Known limitations:
16: * Does not support ACTION_INHIBIT (big deal).
1.1.1.6 root 17: * Does not support several 2.0+ packet types.
1.1 root 18: * Does not support removable volumes.
19: * May not return the correct error code in some cases.
20: * Does not check for sane values passed by AmigaDOS. May crash the emulation
21: * if passed garbage values.
1.1.1.3 root 22: * Could do tighter checks on malloc return values.
23: * Will probably fail spectacularly in some cases if the filesystem is
24: * modified at the same time by another process while UAE is running.
1.1 root 25: */
26:
27: #include "sysconfig.h"
28: #include "sysdeps.h"
29:
30: #include "config.h"
1.1.1.7 root 31: #include "threaddep/penguin.h"
1.1 root 32: #include "options.h"
1.1.1.3 root 33: #include "uae.h"
1.1 root 34: #include "memory.h"
35: #include "custom.h"
36: #include "newcpu.h"
1.1.1.3 root 37: #include "filesys.h"
1.1 root 38: #include "autoconf.h"
39: #include "compiler.h"
1.1.1.4 root 40: #include "fsusage.h"
1.1.1.7 root 41: #include "native2amiga.h"
42: #include "scsidev.h"
43: #include "fsdb.h"
1.1 root 44:
1.1.1.3 root 45: /* #define TRACING_ENABLED */
46: #ifdef TRACING_ENABLED
1.1.1.4 root 47: #define TRACE(x) do { write_log x; } while(0)
1.1.1.3 root 48: #define DUMPLOCK(u,x) dumplock(u,x)
49: #else
50: #define TRACE(x)
51: #define DUMPLOCK(u,x)
52: #endif
53:
54: static long dos_errno(void)
1.1 root 55: {
1.1.1.3 root 56: int e = errno;
1.1 root 57:
1.1.1.4 root 58: switch (e) {
1.1.1.3 root 59: case ENOMEM: return ERROR_NO_FREE_STORE;
60: case EEXIST: return ERROR_OBJECT_EXISTS;
61: case EACCES: return ERROR_WRITE_PROTECTED;
1.1.1.11 root 62: case ENOENT: return ERROR_OBJECT_NOT_AROUND;
1.1.1.3 root 63: case ENOTDIR: return ERROR_OBJECT_WRONG_TYPE;
1.1.1.6 root 64: case ENOSPC: return ERROR_DISK_IS_FULL;
1.1.1.3 root 65: case EBUSY: return ERROR_OBJECT_IN_USE;
66: case EISDIR: return ERROR_OBJECT_WRONG_TYPE;
67: #if defined(ETXTBSY)
68: case ETXTBSY: return ERROR_OBJECT_IN_USE;
69: #endif
70: #if defined(EROFS)
71: case EROFS: return ERROR_DISK_WRITE_PROTECTED;
72: #endif
73: #if defined(ENOTEMPTY)
74: #if ENOTEMPTY != EEXIST
75: case ENOTEMPTY: return ERROR_DIRECTORY_NOT_EMPTY;
76: #endif
77: #endif
78:
79: default:
1.1.1.4 root 80: TRACE(("Unimplemented error %s\n", strerror(e)));
1.1.1.3 root 81: return ERROR_NOT_IMPLEMENTED;
82: }
1.1 root 83: }
84:
1.1.1.3 root 85: /*
86: * This _should_ be no issue for us, but let's rather use a guaranteed
87: * thread safe function if we have one.
1.1.1.4 root 88: * This used to be broken in glibc versions <= 2.0.1 (I think). I hope
89: * no one is using this these days.
90: * Michael Krause says it's also broken in libc5. ARRRGHHHHHH!!!!
1.1.1.3 root 91: */
92: #if 0 && defined HAVE_READDIR_R
93:
94: static struct dirent *my_readdir (DIR *dirstream, struct dirent *space)
95: {
96: struct dirent *loc;
97: if (readdir_r (dirstream, space, &loc) == 0) {
98: /* Success */
99: return loc;
100: }
101: return 0;
102: }
103:
104: #else
105: #define my_readdir(dirstream, space) readdir(dirstream)
106: #endif
107:
1.1.1.4 root 108: uaecptr filesys_initcode;
109: static uae_u32 fsdevname, filesys_configdev;
110:
1.1.1.3 root 111: #define FS_STARTUP 0
112: #define FS_GO_DOWN 1
113:
1.1 root 114: typedef struct {
115: char *devname; /* device name, e.g. UAE0: */
1.1.1.3 root 116: uaecptr devname_amiga;
117: uaecptr startup;
1.1 root 118: char *volname; /* volume name, e.g. CDROM, WORK, etc. */
119: char *rootdir; /* root unix directory */
120: int readonly; /* disallow write access? */
121: int devno;
1.1.1.3 root 122:
123: struct hardfiledata hf;
124:
125: /* Threading stuff */
126: smp_comm_pipe *unit_pipe, *back_pipe;
127: penguin_id tid;
128: struct _unit *volatile self;
1.1.1.4 root 129: /* Reset handling */
130: uae_sem_t reset_sync_sem;
131: int reset_state;
1.1 root 132: } UnitInfo;
133:
134: #define MAX_UNITS 20
135:
1.1.1.4 root 136: struct uaedev_mount_info {
137: int num_units;
138: UnitInfo ui[MAX_UNITS];
139: };
140:
141: static struct uaedev_mount_info *current_mountinfo;
142:
143: int nr_units (struct uaedev_mount_info *mountinfo)
144: {
145: return mountinfo->num_units;
146: }
147:
148: int is_hardfile (struct uaedev_mount_info *mountinfo, int unit_no)
149: {
150: return mountinfo->ui[unit_no].volname == 0;
151: }
152:
1.1.1.6 root 153: static void close_filesys_unit (UnitInfo *uip)
1.1.1.4 root 154: {
155: if (uip->hf.fd != 0)
156: fclose (uip->hf.fd);
157: if (uip->volname != 0)
158: free (uip->volname);
159: if (uip->devname != 0)
160: free (uip->devname);
161: if (uip->rootdir != 0)
162: free (uip->rootdir);
163: if (uip->unit_pipe)
164: free (uip->unit_pipe);
165: if (uip->back_pipe)
166: free (uip->back_pipe);
167:
168: uip->unit_pipe = 0;
169: uip->back_pipe = 0;
170:
171: uip->hf.fd = 0;
172: uip->volname = 0;
173: uip->devname = 0;
174: uip->rootdir = 0;
175: }
176:
177: char *get_filesys_unit (struct uaedev_mount_info *mountinfo, int nr,
178: char **volname, char **rootdir, int *readonly,
179: int *secspertrack, int *surfaces, int *reserved,
1.1.1.6 root 180: int *cylinders, int *size, int *blocksize)
1.1.1.4 root 181: {
182: UnitInfo *uip = mountinfo->ui + nr;
183:
184: if (nr >= mountinfo->num_units)
185: return "No slot allocated for this unit";
186:
187: *volname = uip->volname ? my_strdup (uip->volname) : 0;
188: *rootdir = uip->rootdir ? my_strdup (uip->rootdir) : 0;
189: *readonly = uip->readonly;
190: *secspertrack = uip->hf.secspertrack;
191: *surfaces = uip->hf.surfaces;
192: *reserved = uip->hf.reservedblocks;
193: *size = uip->hf.size;
194: *cylinders = uip->hf.nrcyls;
1.1.1.6 root 195: *blocksize = uip->hf.blocksize;
1.1.1.4 root 196: return 0;
197: }
198:
1.1.1.6 root 199: static char *set_filesys_unit_1 (struct uaedev_mount_info *mountinfo, int nr,
200: char *volname, char *rootdir, int readonly,
201: int secspertrack, int surfaces, int reserved,
202: int blocksize)
1.1 root 203: {
1.1.1.6 root 204: UnitInfo *ui = mountinfo->ui + nr;
1.1.1.4 root 205:
206: if (nr >= mountinfo->num_units)
207: return "No slot allocated for this unit";
1.1 root 208:
1.1.1.6 root 209: ui->hf.fd = 0;
210: ui->devname = 0;
211: ui->volname = 0;
212: ui->rootdir = 0;
213: ui->unit_pipe = 0;
214: ui->back_pipe = 0;
1.1.1.5 root 215:
1.1.1.3 root 216: if (volname != 0) {
1.1.1.6 root 217: ui->volname = my_strdup (volname);
218: ui->hf.fd = 0;
1.1.1.3 root 219: } else {
1.1.1.6 root 220: ui->volname = 0;
221: ui->hf.fd = fopen (rootdir, "r+b");
222: if (ui->hf.fd == 0) {
1.1.1.3 root 223: readonly = 1;
1.1.1.6 root 224: ui->hf.fd = fopen (rootdir, "rb");
1.1.1.3 root 225: }
1.1.1.6 root 226: if (ui->hf.fd == 0)
1.1.1.3 root 227: return "Hardfile not found";
1.1.1.4 root 228:
1.1.1.3 root 229: if (secspertrack < 1 || secspertrack > 32767
230: || surfaces < 1 || surfaces > 1023
1.1.1.6 root 231: || reserved < 0 || reserved > 1023
232: || (blocksize & (blocksize - 1)) != 0)
1.1.1.4 root 233: {
1.1.1.3 root 234: return "Bad hardfile geometry";
235: }
1.1.1.6 root 236: fseek (ui->hf.fd, 0, SEEK_END);
237: ui->hf.size = ftell (ui->hf.fd);
238: ui->hf.secspertrack = secspertrack;
239: ui->hf.surfaces = surfaces;
240: ui->hf.reservedblocks = reserved;
241: ui->hf.nrcyls = (ui->hf.size / blocksize) / (secspertrack * surfaces);
242: ui->hf.blocksize = blocksize;
243: }
244: ui->self = 0;
245: ui->reset_state = FS_STARTUP;
246: ui->rootdir = my_strdup (rootdir);
247: ui->readonly = readonly;
1.1 root 248:
1.1.1.3 root 249: return 0;
1.1 root 250: }
1.1.1.6 root 251:
252: char *set_filesys_unit (struct uaedev_mount_info *mountinfo, int nr,
253: char *volname, char *rootdir, int readonly,
254: int secspertrack, int surfaces, int reserved,
255: int blocksize)
256: {
257: UnitInfo ui = mountinfo->ui[nr];
258: char *result = set_filesys_unit_1 (mountinfo, nr, volname, rootdir, readonly,
259: secspertrack, surfaces, reserved, blocksize);
260: if (result)
261: mountinfo->ui[nr] = ui;
262: else
263: close_filesys_unit (&ui);
264:
265: return result;
266: }
267:
1.1.1.4 root 268: char *add_filesys_unit (struct uaedev_mount_info *mountinfo,
269: char *volname, char *rootdir, int readonly,
1.1.1.6 root 270: int secspertrack, int surfaces, int reserved,
271: int blocksize)
1.1.1.4 root 272: {
273: char *retval;
274: int nr = mountinfo->num_units;
275: UnitInfo *uip = mountinfo->ui + nr;
1.1 root 276:
1.1.1.4 root 277: if (nr >= MAX_UNITS)
278: return "Maximum number of file systems mounted";
279:
280: mountinfo->num_units++;
1.1.1.6 root 281: retval = set_filesys_unit_1 (mountinfo, nr, volname, rootdir, readonly,
282: secspertrack, surfaces, reserved, blocksize);
1.1.1.4 root 283: if (retval)
284: mountinfo->num_units--;
285: return retval;
286: }
287:
288: int kill_filesys_unit (struct uaedev_mount_info *mountinfo, int nr)
1.1.1.2 root 289: {
1.1.1.4 root 290: UnitInfo *uip = mountinfo->ui;
291: if (nr >= mountinfo->num_units || nr < 0)
1.1.1.2 root 292: return -1;
293:
1.1.1.6 root 294: close_filesys_unit (mountinfo->ui + nr);
1.1.1.4 root 295:
296: mountinfo->num_units--;
297: for (; nr < mountinfo->num_units; nr++) {
298: uip[nr] = uip[nr+1];
1.1.1.2 root 299: }
300: return 0;
301: }
302:
1.1.1.4 root 303: int move_filesys_unit (struct uaedev_mount_info *mountinfo, int nr, int to)
1.1.1.3 root 304: {
1.1.1.4 root 305: UnitInfo tmpui;
306: UnitInfo *uip = mountinfo->ui;
307:
308: if (nr >= mountinfo->num_units || nr < 0
309: || to >= mountinfo->num_units || to < 0
310: || to == nr)
311: return -1;
312: tmpui = uip[nr];
313: if (to > nr) {
314: int i;
315: for (i = nr; i < to; i++)
316: uip[i] = uip[i + 1];
317: } else {
318: int i;
319: for (i = nr; i > to; i--)
320: uip[i] = uip[i - 1];
321: }
322: uip[to] = tmpui;
323: return 0;
1.1.1.3 root 324: }
325:
1.1.1.4 root 326: int sprintf_filesys_unit (struct uaedev_mount_info *mountinfo, char *buffer, int num)
1.1.1.2 root 327: {
1.1.1.4 root 328: UnitInfo *uip = mountinfo->ui;
329: if (num >= mountinfo->num_units)
1.1.1.2 root 330: return -1;
1.1.1.4 root 331:
332: if (uip[num].volname != 0)
1.1.1.6 root 333: sprintf (buffer, "(DH%d:) Filesystem, %s: %s %s", num, uip[num].volname,
1.1.1.4 root 334: uip[num].rootdir, uip[num].readonly ? "ro" : "");
1.1.1.2 root 335: else
1.1.1.6 root 336: sprintf (buffer, "(DH%d:) Hardfile, \"%s\", size %d bytes", num,
1.1.1.4 root 337: uip[num].rootdir, uip[num].hf.size);
1.1.1.2 root 338: return 0;
339: }
340:
1.1.1.6 root 341: void write_filesys_config (struct uaedev_mount_info *mountinfo,
342: const char *unexpanded, const char *default_path, FILE *f)
1.1 root 343: {
1.1.1.4 root 344: UnitInfo *uip = mountinfo->ui;
1.1 root 345: int i;
1.1.1.4 root 346:
347: for (i = 0; i < mountinfo->num_units; i++) {
1.1.1.6 root 348: char *str;
349: str = cfgfile_subst_path (default_path, unexpanded, uip[i].rootdir);
1.1.1.4 root 350: if (uip[i].volname != 0) {
1.1.1.7 root 351: fprintf (f, "filesystem=%s,%s:%s\n", uip[i].readonly ? "ro" : "rw",
1.1.1.6 root 352: uip[i].volname, str);
1.1.1.3 root 353: } else {
1.1.1.12! root 354: fprintf (f, "hardfile=%s,%d,%d,%d,%d,%s\n",
! 355: uip[i].readonly ? "ro" : "rw", uip[i].hf.secspertrack,
1.1.1.6 root 356: uip[i].hf.surfaces, uip[i].hf.reservedblocks, 512, str);
1.1 root 357: }
1.1.1.6 root 358: free (str);
1.1 root 359: }
360: }
361:
1.1.1.4 root 362: struct uaedev_mount_info *alloc_mountinfo (void)
363: {
364: struct uaedev_mount_info *info;
365: info = (struct uaedev_mount_info *)malloc (sizeof *info);
1.1.1.6 root 366: /* memset (info, 0xaa, sizeof *info);*/
1.1.1.4 root 367: info->num_units = 0;
368: return info;
369: }
370:
371: struct uaedev_mount_info *dup_mountinfo (struct uaedev_mount_info *mip)
372: {
373: int i;
374: struct uaedev_mount_info *i2 = alloc_mountinfo ();
375:
376: memcpy (i2, mip, sizeof *i2);
377:
378: for (i = 0; i < i2->num_units; i++) {
379: UnitInfo *uip = i2->ui + i;
380: if (uip->volname)
381: uip->volname = my_strdup (uip->volname);
382: if (uip->rootdir)
383: uip->rootdir = my_strdup (uip->rootdir);
384: if (uip->hf.fd)
1.1.1.7 root 385: uip->hf.fd = fdopen ( dup (fileno (uip->hf.fd)), uip->readonly ? "rb" : "r+b");
1.1.1.4 root 386: }
387: return i2;
388: }
389:
390: void free_mountinfo (struct uaedev_mount_info *mip)
391: {
392: int i;
393: for (i = 0; i < mip->num_units; i++)
1.1.1.6 root 394: close_filesys_unit (mip->ui + i);
1.1.1.4 root 395: free (mip);
396: }
397:
398: struct hardfiledata *get_hardfile_data (int nr)
399: {
400: UnitInfo *uip = current_mountinfo->ui;
401: if (nr < 0 || nr >= current_mountinfo->num_units || uip[nr].volname != 0)
402: return 0;
403: return &uip[nr].hf;
404: }
405:
1.1 root 406: /* minimal AmigaDOS definitions */
407:
408: /* field offsets in DosPacket */
1.1.1.3 root 409: #define dp_Type 8
410: #define dp_Res1 12
411: #define dp_Res2 16
412: #define dp_Arg1 20
413: #define dp_Arg2 24
414: #define dp_Arg3 28
415: #define dp_Arg4 32
1.1 root 416:
417: /* result codes */
1.1.1.3 root 418: #define DOS_TRUE ((unsigned long)-1L)
1.1 root 419: #define DOS_FALSE (0L)
420:
421: /* packet types */
422: #define ACTION_CURRENT_VOLUME 7
423: #define ACTION_LOCATE_OBJECT 8
424: #define ACTION_RENAME_DISK 9
425: #define ACTION_FREE_LOCK 15
426: #define ACTION_DELETE_OBJECT 16
427: #define ACTION_RENAME_OBJECT 17
428: #define ACTION_COPY_DIR 19
429: #define ACTION_SET_PROTECT 21
430: #define ACTION_CREATE_DIR 22
431: #define ACTION_EXAMINE_OBJECT 23
432: #define ACTION_EXAMINE_NEXT 24
433: #define ACTION_DISK_INFO 25
434: #define ACTION_INFO 26
435: #define ACTION_FLUSH 27
436: #define ACTION_SET_COMMENT 28
437: #define ACTION_PARENT 29
438: #define ACTION_SET_DATE 34
439: #define ACTION_FIND_WRITE 1004
440: #define ACTION_FIND_INPUT 1005
441: #define ACTION_FIND_OUTPUT 1006
442: #define ACTION_END 1007
443: #define ACTION_SEEK 1008
444: #define ACTION_IS_FILESYSTEM 1027
445: #define ACTION_READ 'R'
446: #define ACTION_WRITE 'W'
447:
1.1.1.3 root 448: /* 2.0+ packet types */
449: #define ACTION_INHIBIT 31
450: #define ACTION_SET_FILE_SIZE 1022
451: #define ACTION_LOCK_RECORD 2008
452: #define ACTION_FREE_RECORD 2009
453: #define ACTION_SAME_LOCK 40
454: #define ACTION_CHANGE_MODE 1028
455: #define ACTION_FH_FROM_LOCK 1026
456: #define ACTION_COPY_DIR_FH 1030
457: #define ACTION_PARENT_FH 1031
458: #define ACTION_EXAMINE_FH 1034
459: #define ACTION_EXAMINE_ALL 1033
460: #define ACTION_MAKE_LINK 1021
461: #define ACTION_READ_LINK 1024
462: #define ACTION_FORMAT 1020
463: #define ACTION_IS_FILESYSTEM 1027
464: #define ACTION_ADD_NOTIFY 4097
465: #define ACTION_REMOVE_NOTIFY 4098
1.1 root 466:
1.1.1.3 root 467: #define DISK_TYPE 0x444f5301 /* DOS\1 */
1.1 root 468:
1.1.1.3 root 469: typedef struct {
470: uae_u32 uniq;
1.1.1.7 root 471: a_inode *aino;
1.1.1.3 root 472: DIR* dir;
473: } ExamineKey;
1.1 root 474:
1.1.1.3 root 475: typedef struct key {
476: struct key *next;
1.1.1.7 root 477: a_inode *aino;
1.1.1.3 root 478: uae_u32 uniq;
479: int fd;
480: off_t file_pos;
481: } Key;
1.1 root 482:
1.1.1.3 root 483: /* Since ACTION_EXAMINE_NEXT is so braindamaged, we have to keep
484: * some of these around
485: */
486:
487: #define EXKEYS 100
488: #define MAX_AINO_HASH 128
1.1 root 489:
490: /* handler state info */
491:
492: typedef struct _unit {
493: struct _unit *next;
494:
495: /* Amiga stuff */
1.1.1.4 root 496: uaecptr dosbase;
497: uaecptr volume;
498: uaecptr port; /* Our port */
499: uaecptr locklist;
1.1 root 500:
501: /* Native stuff */
1.1.1.4 root 502: uae_s32 unit; /* unit number */
503: UnitInfo ui; /* unit startup info */
504: char tmpbuf3[256];
1.1.1.3 root 505:
506: /* Dummy message processing */
1.1.1.4 root 507: uaecptr dummy_message;
1.1.1.3 root 508: volatile unsigned int cmds_sent;
509: volatile unsigned int cmds_complete;
510: volatile unsigned int cmds_acked;
511:
512: /* ExKeys */
513: ExamineKey examine_keys[EXKEYS];
1.1.1.4 root 514: int next_exkey;
1.1.1.3 root 515:
516: /* Keys */
1.1.1.4 root 517: struct key *keys;
518: uae_u32 key_uniq;
519: uae_u32 a_uniq;
1.1.1.3 root 520:
1.1.1.7 root 521: a_inode rootnode;
1.1.1.3 root 522: unsigned long aino_cache_size;
1.1.1.7 root 523: a_inode *aino_hash[MAX_AINO_HASH];
1.1.1.3 root 524: unsigned long nr_cache_hits;
525: unsigned long nr_cache_lookups;
1.1 root 526: } Unit;
527:
1.1.1.3 root 528: typedef uae_u8 *dpacket;
529: #define PUT_PCK_RES1(p,v) do { do_put_mem_long ((uae_u32 *)((p) + dp_Res1), (v)); } while (0)
530: #define PUT_PCK_RES2(p,v) do { do_put_mem_long ((uae_u32 *)((p) + dp_Res2), (v)); } while (0)
531: #define GET_PCK_TYPE(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp_Type))))
532: #define GET_PCK_RES1(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp_Res1))))
533: #define GET_PCK_RES2(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp_Res2))))
534: #define GET_PCK_ARG1(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp_Arg1))))
535: #define GET_PCK_ARG2(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp_Arg2))))
536: #define GET_PCK_ARG3(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp_Arg3))))
537: #define GET_PCK_ARG4(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp_Arg4))))
1.1 root 538:
1.1.1.3 root 539: static char *bstr1 (uaecptr addr)
1.1 root 540: {
541: static char buf[256];
542: int i;
1.1.1.3 root 543: int n = get_byte(addr);
544: addr++;
545:
1.1.1.4 root 546: for (i = 0; i < n; i++, addr++)
1.1.1.3 root 547: buf[i] = get_byte(addr);
1.1 root 548: buf[i] = 0;
549: return buf;
550: }
551:
1.1.1.3 root 552: static char *bstr (Unit *unit, uaecptr addr)
553: {
554: int i;
555: int n = get_byte(addr);
556:
557: addr++;
1.1.1.4 root 558: for (i = 0; i < n; i++, addr++)
1.1.1.3 root 559: unit->tmpbuf3[i] = get_byte(addr);
560: unit->tmpbuf3[i] = 0;
561: return unit->tmpbuf3;
562: }
563:
564: static char *bstr_cut (Unit *unit, uaecptr addr)
565: {
566: char *p = unit->tmpbuf3;
567: int i, colon_seen = 0;
568: int n = get_byte (addr);
569:
570: addr++;
1.1.1.4 root 571: for (i = 0; i < n; i++, addr++) {
1.1.1.3 root 572: uae_u8 c = get_byte(addr);
573: unit->tmpbuf3[i] = c;
574: if (c == '/' || (c == ':' && colon_seen++ == 0))
575: p = unit->tmpbuf3 + i + 1;
576: }
577: unit->tmpbuf3[i] = 0;
578: return p;
579: }
580:
581: static Unit *units = 0;
1.1 root 582: static int unit_num = 0;
583:
584: static Unit*
1.1.1.4 root 585: find_unit (uaecptr port)
1.1 root 586: {
587: Unit* u;
1.1.1.4 root 588: for (u = units; u; u = u->next)
589: if (u->port == port)
1.1 root 590: break;
591:
592: return u;
593: }
1.1.1.7 root 594:
1.1.1.3 root 595: static void prepare_for_open (char *name)
596: {
597: #if 0
598: struct stat statbuf;
599: int mode;
600:
601: if (-1 == stat (name, &statbuf))
602: return;
603:
604: mode = statbuf.st_mode;
605: mode |= S_IRUSR;
606: mode |= S_IWUSR;
607: mode |= S_IXUSR;
608: chmod (name, mode);
609: #endif
610: }
611:
1.1.1.7 root 612: static void de_recycle_aino (Unit *unit, a_inode *aino)
1.1 root 613: {
1.1.1.3 root 614: if (aino->next == 0 || aino == &unit->rootnode)
615: return;
616: aino->next->prev = aino->prev;
617: aino->prev->next = aino->next;
618: aino->next = aino->prev = 0;
619: unit->aino_cache_size--;
620: }
621:
1.1.1.7 root 622: static void dispose_aino (Unit *unit, a_inode **aip, a_inode *aino)
623: {
624: int hash = aino->uniq % MAX_AINO_HASH;
625: if (unit->aino_hash[hash] == aino)
626: unit->aino_hash[hash] = 0;
627:
628: if (aino->dirty && aino->parent)
629: fsdb_dir_writeback (aino->parent);
630:
631: *aip = aino->sibling;
632: if (aino->comment)
633: free (aino->comment);
634: free (aino->nname);
635: free (aino->aname);
636: free (aino);
637: }
638:
1.1.1.9 root 639: static void recycle_aino (Unit *unit, a_inode *new_aino)
1.1.1.3 root 640: {
1.1.1.9 root 641: if (new_aino->dir || new_aino->shlock > 0
642: || new_aino->elock || new_aino == &unit->rootnode)
1.1.1.3 root 643: /* Still in use */
644: return;
645:
646: if (unit->aino_cache_size > 500) {
647: /* Reap a few. */
648: int i = 0;
649: while (i < 50) {
1.1.1.7 root 650: a_inode **aip;
1.1.1.3 root 651: aip = &unit->rootnode.prev->parent->child;
652: for (;;) {
1.1.1.9 root 653: a_inode *aino = *aip;
1.1.1.3 root 654: if (aino == 0)
655: break;
656:
657: if (aino->next == 0)
658: aip = &aino->sibling;
659: else {
660: if (aino->shlock > 0 || aino->elock)
661: write_log ("panic: freeing locked a_inode!\n");
662:
1.1.1.7 root 663: de_recycle_aino (unit, aino);
664: dispose_aino (unit, aip, aino);
665: i++;
1.1.1.3 root 666: }
667: }
668: }
669: #if 0
670: {
671: char buffer[40];
672: sprintf (buffer, "%d ainos reaped.\n", i);
673: write_log (buffer);
674: }
675: #endif
676: }
1.1.1.9 root 677:
678: /* Chain it into circular list. */
679: new_aino->next = unit->rootnode.next;
680: new_aino->prev = &unit->rootnode;
681: new_aino->prev->next = new_aino;
682: new_aino->next->prev = new_aino;
683: unit->aino_cache_size++;
1.1.1.3 root 684: }
1.1 root 685:
1.1.1.7 root 686: static void update_child_names (Unit *unit, a_inode *a, a_inode *parent)
1.1.1.3 root 687: {
688: int l0 = strlen (parent->nname) + 2;
1.1 root 689:
1.1.1.3 root 690: while (a != 0) {
691: char *name_start;
692: char *new_name;
1.1 root 693:
1.1.1.3 root 694: a->parent = parent;
695: name_start = strrchr (a->nname, '/');
696: if (name_start == 0) {
697: write_log ("malformed file name");
698: }
699: name_start++;
700: new_name = (char *)xmalloc (strlen (name_start) + l0);
701: strcpy (new_name, parent->nname);
702: strcat (new_name, "/");
703: strcat (new_name, name_start);
704: free (a->nname);
705: a->nname = new_name;
706: if (a->child)
707: update_child_names (unit, a->child, a);
708: a = a->sibling;
1.1 root 709: }
1.1.1.3 root 710: }
1.1 root 711:
1.1.1.7 root 712: static void move_aino_children (Unit *unit, a_inode *from, a_inode *to)
1.1.1.3 root 713: {
714: to->child = from->child;
715: from->child = 0;
716: update_child_names (unit, to->child, to);
1.1 root 717: }
718:
1.1.1.7 root 719: static void delete_aino (Unit *unit, a_inode *aino)
1.1 root 720: {
1.1.1.7 root 721: a_inode **aip;
1.1.1.3 root 722: int hash;
723:
1.1.1.4 root 724: TRACE(("deleting aino %x\n", aino->uniq));
1.1.1.3 root 725:
1.1.1.7 root 726: aino->dirty = 1;
727: aino->deleted = 1;
1.1.1.3 root 728: de_recycle_aino (unit, aino);
729: aip = &aino->parent->child;
730: while (*aip != aino && *aip != 0)
731: aip = &(*aip)->sibling;
732: if (*aip != aino) {
733: write_log ("Couldn't delete aino.\n");
734: return;
735: }
1.1.1.7 root 736: dispose_aino (unit, aip, aino);
1.1 root 737: }
738:
1.1.1.7 root 739: static a_inode *lookup_sub (a_inode *dir, uae_u32 uniq)
1.1.1.3 root 740: {
1.1.1.7 root 741: a_inode **cp = &dir->child;
742: a_inode *c, *retval;
1.1.1.3 root 743:
744: for (;;) {
745: c = *cp;
746: if (c == 0)
747: return 0;
748:
749: if (c->uniq == uniq) {
750: retval = c;
751: break;
752: }
753: if (c->dir) {
1.1.1.7 root 754: a_inode *a = lookup_sub (c, uniq);
1.1.1.3 root 755: if (a != 0) {
756: retval = a;
757: break;
758: }
759: }
760: cp = &c->sibling;
761: }
762: *cp = c->sibling;
763: c->sibling = dir->child;
764: dir->child = c;
765: return retval;
766: }
767:
1.1.1.7 root 768: static a_inode *lookup_aino (Unit *unit, uae_u32 uniq)
1.1 root 769: {
1.1.1.7 root 770: a_inode *a;
1.1.1.3 root 771: int hash = uniq % MAX_AINO_HASH;
772:
773: if (uniq == 0)
774: return &unit->rootnode;
775: a = unit->aino_hash[hash];
776: if (a == 0 || a->uniq != uniq)
777: a = lookup_sub (&unit->rootnode, uniq);
778: else
779: unit->nr_cache_hits++;
780: unit->nr_cache_lookups++;
781: unit->aino_hash[hash] = a;
782: return a;
783: }
784:
1.1.1.7 root 785: char *build_nname (const char *d, const char *n)
786: {
787: char dsep[2] = { FSDB_DIR_SEPARATOR, '\0' };
788: char *p = (char *) xmalloc (strlen (d) + strlen (n) + 2);
789: strcpy (p, d);
790: strcat (p, dsep);
791: strcat (p, n);
792: return p;
793: }
794:
795: char *build_aname (const char *d, const char *n)
796: {
797: char *p = (char *) xmalloc (strlen (d) + strlen (n) + 2);
798: strcpy (p, d);
799: strcat (p, "/");
800: strcat (p, n);
801: return p;
802: }
803:
1.1.1.3 root 804: /* This gets called to translate an Amiga name that some program used to
1.1.1.7 root 805: * a name that we can use on the native filesystem. */
806: static char *get_nname (Unit *unit, a_inode *base, char *rel,
807: char **modified_rel)
1.1.1.3 root 808: {
1.1.1.7 root 809: char *found;
1.1.1.3 root 810: char *p = 0;
811:
1.1.1.7 root 812: *modified_rel = 0;
813:
814: /* If we have a mapping of some other aname to "rel", we must pretend
815: * it does not exist.
816: * This can happen for example if an Amiga program creates a
817: * file called ".". We can't represent this in our filesystem,
818: * so we create a special file "uae_xxx" and record the mapping
819: * aname "." -> nname "uae_xxx" in the database. Then, the Amiga
820: * program looks up "uae_xxx" (yes, it's contrived). The filesystem
821: * should not make the uae_xxx file visible to the Amiga side. */
822: if (fsdb_used_as_nname (base, rel))
823: return 0;
824: /* A file called "." (or whatever else is invalid on this filesystem)
825: * does not exist, as far as the Amiga side is concerned. */
826: if (fsdb_name_invalid (rel))
1.1.1.4 root 827: return 0;
828:
1.1.1.7 root 829: /* See if we have a file that has the same name as the aname we are
830: * looking for. */
831: found = fsdb_search_dir (base->nname, rel);
832: if (found == 0)
833: return found;
834: if (found == rel)
835: return build_nname (base->nname, rel);
836:
837: *modified_rel = found;
838: return build_nname (base->nname, found);
839: }
840:
841: static char *create_nname (Unit *unit, a_inode *base, char *rel)
842: {
843: char *p;
844:
845: /* We are trying to create a file called REL. */
846:
847: /* If the name is used otherwise in the directory (or globally), we
848: * need a new unique nname. */
849: if (fsdb_name_invalid (rel) || fsdb_used_as_nname (base, rel)) {
850: oh_dear:
851: p = fsdb_create_unique_nname (base, rel);
852: return p;
853: }
854: p = build_nname (base->nname, rel);
855:
856: /* Delete this code once we know everything works. */
857: if (access (p, R_OK) >= 0 || errno != ENOENT) {
858: write_log ("Filesystem in trouble... please report.\n");
859: free (p);
860: goto oh_dear;
1.1.1.3 root 861: }
862: return p;
863: }
864:
865: /*
866: * This gets called if an ACTION_EXAMINE_NEXT happens and we hit an object
867: * for which we know the name on the native filesystem, but no corresponding
868: * Amiga filesystem name.
869: * @@@ For DOS filesystems, it might make sense to declare the new name
870: * "weak", so that it can get overriden by a subsequent call to get_nname().
871: * That way, if someone does "dir :" and there is a file "foobar.inf", and
872: * someone else tries to open "foobar.info", get_nname() could maybe made to
873: * figure out that this is supposed to be the file "foobar.inf".
874: * DOS sucks...
875: */
1.1.1.7 root 876: static char *get_aname (Unit *unit, a_inode *base, char *rel)
1.1.1.3 root 877: {
1.1.1.7 root 878: return my_strdup (rel);
1.1.1.3 root 879: }
880:
1.1.1.7 root 881: static void init_child_aino (Unit *unit, a_inode *base, a_inode *aino)
1.1.1.3 root 882: {
883: aino->uniq = ++unit->a_uniq;
884: if (unit->a_uniq == 0xFFFFFFFF) {
885: write_log ("Running out of a_inodes (prepare for big trouble)!\n");
886: }
887: aino->shlock = 0;
888: aino->elock = 0;
889:
1.1.1.7 root 890: aino->dirty = 0;
891: aino->deleted = 0;
892:
1.1.1.3 root 893: /* Update tree structure */
894: aino->parent = base;
895: aino->child = 0;
896: aino->sibling = base->child;
897: base->child = aino;
898: aino->next = aino->prev = 0;
1.1.1.7 root 899: }
1.1.1.3 root 900:
1.1.1.7 root 901: static a_inode *new_child_aino (Unit *unit, a_inode *base, char *rel)
902: {
903: char *modified_rel;
904: char *nn;
905: a_inode *aino;
906:
907: TRACE(("new_child_aino %s, %s\n", base->aname, rel));
908:
909: aino = fsdb_lookup_aino_aname (base, rel);
910: if (aino == 0) {
911: nn = get_nname (unit, base, rel, &modified_rel);
912: if (nn == 0)
913: return 0;
914:
1.1.1.11 root 915: aino = (a_inode *) xcalloc (sizeof (a_inode), 1);
1.1.1.7 root 916: if (aino == 0)
917: return 0;
918: aino->aname = modified_rel ? modified_rel : my_strdup (rel);
919: aino->nname = nn;
920:
921: aino->comment = 0;
922: aino->has_dbentry = 0;
923:
924: fsdb_fill_file_attrs (aino);
925: if (aino->dir)
926: fsdb_clean_dir (aino);
1.1.1.3 root 927: }
1.1.1.7 root 928: init_child_aino (unit, base, aino);
929:
930: recycle_aino (unit, aino);
931: TRACE(("created aino %x, lookup\n", aino->uniq));
932: return aino;
933: }
934:
935: static a_inode *create_child_aino (Unit *unit, a_inode *base, char *rel, int isdir)
936: {
1.1.1.11 root 937: a_inode *aino = (a_inode *) xcalloc (sizeof (a_inode), 1);
1.1.1.7 root 938: if (aino == 0)
939: return 0;
940:
941: aino->aname = my_strdup (rel);
942: aino->nname = create_nname (unit, base, rel);
943:
944: init_child_aino (unit, base, aino);
945: aino->amigaos_mode = 0;
946: aino->dir = isdir;
947:
948: aino->comment = 0;
949: aino->has_dbentry = 0;
950: aino->dirty = 1;
1.1.1.5 root 951:
1.1.1.3 root 952: recycle_aino (unit, aino);
1.1.1.7 root 953: TRACE(("created aino %x, create\n", aino->uniq));
1.1.1.3 root 954: return aino;
955: }
956:
1.1.1.7 root 957: static a_inode *lookup_child_aino (Unit *unit, a_inode *base, char *rel, uae_u32 *err)
1.1.1.3 root 958: {
1.1.1.7 root 959: a_inode *c = base->child;
1.1.1.3 root 960: int l0 = strlen (rel);
961:
962: if (base->dir == 0) {
963: *err = ERROR_OBJECT_WRONG_TYPE;
964: return 0;
965: }
966:
967: while (c != 0) {
968: int l1 = strlen (c->aname);
1.1.1.7 root 969: if (l0 <= l1 && same_aname (rel, c->aname + l1 - l0)
1.1.1.3 root 970: && (l0 == l1 || c->aname[l1-l0-1] == '/'))
971: break;
972: c = c->sibling;
973: }
974: if (c != 0)
975: return c;
1.1.1.7 root 976: c = new_child_aino (unit, base, rel);
1.1.1.3 root 977: if (c == 0)
1.1.1.11 root 978: *err = ERROR_OBJECT_NOT_AROUND;
1.1.1.3 root 979: return c;
980: }
981:
1.1.1.7 root 982: /* Different version because for this one, REL is an nname. */
983: static a_inode *lookup_child_aino_for_exnext (Unit *unit, a_inode *base, char *rel, uae_u32 *err)
1.1.1.3 root 984: {
1.1.1.7 root 985: a_inode *c = base->child;
1.1.1.3 root 986: int l0 = strlen (rel);
987:
988: *err = 0;
989: while (c != 0) {
990: int l1 = strlen (c->nname);
1.1.1.7 root 991: /* Note: using strcmp here. */
992: if (l0 <= l1 && strcmp (rel, c->nname + l1 - l0) == 0
993: && (l0 == l1 || c->nname[l1-l0-1] == FSDB_DIR_SEPARATOR))
1.1.1.3 root 994: break;
995: c = c->sibling;
996: }
997: if (c != 0)
998: return c;
1.1.1.7 root 999: c = fsdb_lookup_aino_nname (base, rel);
1000: if (c == 0) {
1001: c = (a_inode *)malloc (sizeof (a_inode));
1002: if (c == 0) {
1003: *err = ERROR_NO_FREE_STORE;
1004: return 0;
1005: }
1006:
1007: c->nname = build_nname (base->nname, rel);
1.1.1.3 root 1008: c->aname = get_aname (unit, base, rel);
1.1.1.7 root 1009: c->comment = 0;
1010: c->has_dbentry = 0;
1011: fsdb_fill_file_attrs (c);
1012: if (c->dir)
1013: fsdb_clean_dir (c);
1.1.1.3 root 1014: }
1.1.1.7 root 1015: init_child_aino (unit, base, c);
1016:
1017: recycle_aino (unit, c);
1018: TRACE(("created aino %x, exnext\n", c->uniq));
1019:
1.1.1.3 root 1020: return c;
1021: }
1022:
1.1.1.7 root 1023: static a_inode *get_aino (Unit *unit, a_inode *base, const char *rel, uae_u32 *err)
1.1.1.3 root 1024: {
1025: char *tmp;
1026: char *p;
1.1.1.7 root 1027: a_inode *curr;
1.1.1.3 root 1028: int i;
1029:
1030: *err = 0;
1.1.1.4 root 1031: TRACE(("get_path(%s,%s)\n", base->aname, rel));
1.1.1.3 root 1032:
1033: /* root-relative path? */
1.1.1.4 root 1034: for (i = 0; rel[i] && rel[i] != '/' && rel[i] != ':'; i++)
1.1.1.3 root 1035: ;
1036: if (':' == rel[i])
1037: rel += i+1;
1038:
1039: tmp = my_strdup (rel);
1040: p = tmp;
1041: curr = base;
1042:
1.1.1.7 root 1043: while (*p) {
1.1.1.3 root 1044: /* start with a slash? go up a level. */
1045: if (*p == '/') {
1046: if (curr->parent != 0)
1047: curr = curr->parent;
1048: p++;
1049: } else {
1.1.1.7 root 1050: a_inode *next;
1.1.1.3 root 1051:
1052: char *component_end;
1053: component_end = strchr (p, '/');
1054: if (component_end != 0)
1055: *component_end = '\0';
1056: next = lookup_child_aino (unit, curr, p, err);
1057: if (next == 0) {
1058: /* if only last component not found, return parent dir. */
1.1.1.11 root 1059: if (*err != ERROR_OBJECT_NOT_AROUND || component_end != 0)
1.1.1.3 root 1060: curr = 0;
1061: /* ? what error is appropriate? */
1062: break;
1063: }
1064: curr = next;
1065: if (component_end)
1066: p = component_end+1;
1067: else
1068: break;
1069:
1070: }
1071: }
1072: free (tmp);
1073: return curr;
1074: }
1075:
1076: static uae_u32 startup_handler (void)
1077: {
1078: /* Just got the startup packet. It's in A4. DosBase is in A2,
1079: * our allocated volume structure is in D6, A5 is a pointer to
1080: * our port. */
1.1.1.7 root 1081: uaecptr rootnode = get_long (m68k_areg (regs, 2) + 34);
1082: uaecptr dos_info = get_long (rootnode + 24) << 2;
1.1.1.3 root 1083: uaecptr pkt = m68k_dreg (regs, 3);
1084: uaecptr arg2 = get_long (pkt + dp_Arg2);
1.1 root 1085: int i, namelen;
1.1.1.3 root 1086: char* devname = bstr1 (get_long (pkt + dp_Arg1) << 2);
1.1 root 1087: char* s;
1.1.1.4 root 1088: Unit *unit;
1.1.1.3 root 1089: UnitInfo *uinfo;
1.1 root 1090:
1091: /* find UnitInfo with correct device name */
1.1.1.4 root 1092: s = strchr (devname, ':');
1093: if (s)
1.1.1.3 root 1094: *s = '\0';
1.1 root 1095:
1.1.1.4 root 1096: for (i = 0; i < current_mountinfo->num_units; i++) {
1.1 root 1097: /* Hardfile volume name? */
1.1.1.4 root 1098: if (current_mountinfo->ui[i].volname == 0)
1.1 root 1099: continue;
1.1.1.3 root 1100:
1.1.1.4 root 1101: if (current_mountinfo->ui[i].startup == arg2)
1.1.1.3 root 1102: break;
1.1 root 1103: }
1.1.1.3 root 1104:
1.1.1.4 root 1105: if (i == current_mountinfo->num_units
1106: || access (current_mountinfo->ui[i].rootdir, R_OK) != 0)
1107: {
1108: write_log ("Failed attempt to mount device\n", devname);
1.1.1.3 root 1109: put_long (pkt + dp_Res1, DOS_FALSE);
1110: put_long (pkt + dp_Res2, ERROR_DEVICE_NOT_MOUNTED);
1111: return 1;
1.1 root 1112: }
1.1.1.4 root 1113: uinfo = current_mountinfo->ui + i;
1.1 root 1114:
1.1.1.11 root 1115: unit = (Unit *) xcalloc (sizeof (Unit), 1);
1.1 root 1116: unit->next = units;
1117: units = unit;
1.1.1.3 root 1118: uinfo->self = unit;
1.1 root 1119:
1120: unit->volume = 0;
1.1.1.7 root 1121: unit->port = m68k_areg (regs, 5);
1.1 root 1122: unit->unit = unit_num++;
1123:
1.1.1.3 root 1124: unit->ui.devname = uinfo->devname;
1125: unit->ui.volname = my_strdup (uinfo->volname); /* might free later for rename */
1126: unit->ui.rootdir = uinfo->rootdir;
1127: unit->ui.readonly = uinfo->readonly;
1128: unit->ui.unit_pipe = uinfo->unit_pipe;
1129: unit->ui.back_pipe = uinfo->back_pipe;
1130: unit->cmds_complete = 0;
1131: unit->cmds_sent = 0;
1132: unit->cmds_acked = 0;
1133: for (i = 0; i < EXKEYS; i++) {
1134: unit->examine_keys[i].aino = 0;
1135: unit->examine_keys[i].dir = 0;
1136: unit->examine_keys[i].uniq = 0;
1137: }
1138: unit->next_exkey = 1;
1139: unit->keys = 0;
1140: unit->a_uniq = unit->key_uniq = 0;
1141:
1142: unit->rootnode.aname = uinfo->volname;
1143: unit->rootnode.nname = uinfo->rootdir;
1144: unit->rootnode.sibling = 0;
1145: unit->rootnode.next = unit->rootnode.prev = &unit->rootnode;
1146: unit->rootnode.uniq = 0;
1147: unit->rootnode.parent = 0;
1148: unit->rootnode.child = 0;
1149: unit->rootnode.dir = 1;
1150: unit->rootnode.amigaos_mode = 0;
1151: unit->rootnode.shlock = 0;
1152: unit->rootnode.elock = 0;
1.1.1.11 root 1153: unit->rootnode.comment = 0;
1154: unit->rootnode.has_dbentry = 0;
1.1.1.3 root 1155: unit->aino_cache_size = 0;
1156: for (i = 0; i < MAX_AINO_HASH; i++)
1157: unit->aino_hash[i] = 0;
1158:
1159: /* write_comm_pipe_int (unit->ui.unit_pipe, -1, 1);*/
1.1 root 1160:
1.1.1.4 root 1161: TRACE(("**** STARTUP volume %s\n", unit->ui.volname));
1.1 root 1162:
1163: /* fill in our process in the device node */
1.1.1.3 root 1164: put_long ((get_long (pkt + dp_Arg3) << 2) + 8, unit->port);
1.1.1.7 root 1165: unit->dosbase = m68k_areg (regs, 2);
1.1 root 1166:
1.1.1.3 root 1167: /* make new volume */
1168: unit->volume = m68k_areg (regs, 3) + 32;
1169: #ifdef UAE_FILESYS_THREADS
1170: unit->locklist = m68k_areg (regs, 3) + 8;
1171: #else
1172: unit->locklist = m68k_areg (regs, 3);
1173: #endif
1174: unit->dummy_message = m68k_areg (regs, 3) + 12;
1.1 root 1175:
1.1.1.3 root 1176: put_long (unit->dummy_message + 10, 0);
1177:
1178: put_long (unit->volume + 4, 2); /* Type = dt_volume */
1179: put_long (unit->volume + 12, 0); /* Lock */
1180: put_long (unit->volume + 16, 3800); /* Creation Date */
1181: put_long (unit->volume + 20, 0);
1182: put_long (unit->volume + 24, 0);
1183: put_long (unit->volume + 28, 0); /* lock list */
1184: put_long (unit->volume + 40, (unit->volume + 44) >> 2); /* Name */
1185: namelen = strlen (unit->ui.volname);
1186: put_byte (unit->volume + 44, namelen);
1.1.1.4 root 1187: for (i = 0; i < namelen; i++)
1.1.1.3 root 1188: put_byte (unit->volume + 45 + i, unit->ui.volname[i]);
1189:
1190: /* link into DOS list */
1.1.1.7 root 1191: put_long (unit->volume, get_long (dos_info + 4));
1.1.1.3 root 1192: put_long (dos_info + 4, unit->volume >> 2);
1193:
1194: put_long (unit->volume + 8, unit->port);
1195: put_long (unit->volume + 32, DISK_TYPE);
1.1 root 1196:
1.1.1.3 root 1197: put_long (pkt + dp_Res1, DOS_TRUE);
1.1.1.7 root 1198:
1199: fsdb_clean_dir (&unit->rootnode);
1200:
1.1.1.3 root 1201: return 0;
1.1 root 1202: }
1203:
1204: static void
1.1.1.4 root 1205: do_info (Unit *unit, dpacket packet, uaecptr info)
1.1 root 1206: {
1.1.1.4 root 1207: struct fs_usage fsu;
1208:
1209: if (get_fs_usage (unit->ui.rootdir, 0, &fsu) != 0) {
1.1.1.3 root 1210: PUT_PCK_RES1 (packet, DOS_FALSE);
1211: PUT_PCK_RES2 (packet, dos_errno ());
1.1.1.4 root 1212: return;
1.1 root 1213: }
1214:
1.1.1.4 root 1215: fsu.fsu_blocks >>= 1;
1216: fsu.fsu_bavail >>= 1;
1.1.1.7 root 1217: put_long (info, 0); /* errors */
1218: put_long (info + 4, unit->unit); /* unit number */
1219: put_long (info + 8, unit->ui.readonly ? 80 : 82); /* state */
1220: put_long (info + 12, fsu.fsu_blocks ); /* numblocks */
1221: put_long (info + 16, fsu.fsu_blocks - fsu.fsu_bavail); /* inuse */
1222: put_long (info + 20, 1024); /* bytesperblock */
1223: put_long (info + 24, DISK_TYPE); /* disk type */
1224: put_long (info + 28, unit->volume >> 2); /* volume node */
1225: put_long (info + 32, 0); /* inuse */
1.1.1.3 root 1226: PUT_PCK_RES1 (packet, DOS_TRUE);
1.1 root 1227: }
1228:
1229: static void
1.1.1.4 root 1230: action_disk_info (Unit *unit, dpacket packet)
1.1 root 1231: {
1.1.1.4 root 1232: TRACE(("ACTION_DISK_INFO\n"));
1.1.1.3 root 1233: do_info(unit, packet, GET_PCK_ARG1 (packet) << 2);
1.1 root 1234: }
1235:
1236: static void
1.1.1.4 root 1237: action_info (Unit *unit, dpacket packet)
1.1 root 1238: {
1.1.1.4 root 1239: TRACE(("ACTION_INFO\n"));
1.1.1.3 root 1240: do_info(unit, packet, GET_PCK_ARG2 (packet) << 2);
1.1 root 1241: }
1242:
1.1.1.4 root 1243: static void free_key (Unit *unit, Key *k)
1.1 root 1244: {
1245: Key *k1;
1.1.1.3 root 1246: Key *prev = 0;
1247: for (k1 = unit->keys; k1; k1 = k1->next) {
1248: if (k == k1) {
1.1.1.4 root 1249: if (prev)
1.1.1.3 root 1250: prev->next = k->next;
1251: else
1252: unit->keys = k->next;
1253: break;
1254: }
1255: prev = k1;
1.1 root 1256: }
1257:
1258: if (k->fd >= 0)
1259: close(k->fd);
1.1.1.3 root 1260:
1.1 root 1261: free(k);
1262: }
1263:
1.1.1.4 root 1264: static Key *lookup_key (Unit *unit, uae_u32 uniq)
1.1 root 1265: {
1266: Key *k;
1.1.1.3 root 1267: /* It's hardly worthwhile to optimize this - most of the time there are
1268: * only one or zero keys. */
1.1.1.4 root 1269: for (k = unit->keys; k; k = k->next) {
1.1.1.3 root 1270: if (uniq == k->uniq)
1271: return k;
1.1 root 1272: }
1.1.1.3 root 1273: write_log ("Error: couldn't find key!\n");
1274: #if 0
1.1 root 1275: exit(1);
1276: /* NOTREACHED */
1.1.1.3 root 1277: #endif
1278: /* There isn't much hope we will recover. Unix would kill the process,
1279: * AmigaOS gets killed by it. */
1280: write_log ("Better reset that Amiga - the system is messed up.\n");
1281: return 0;
1.1 root 1282: }
1283:
1.1.1.4 root 1284: static Key *new_key (Unit *unit)
1.1 root 1285: {
1.1.1.4 root 1286: Key *k = (Key *) xmalloc(sizeof(Key));
1.1.1.3 root 1287: k->uniq = ++unit->key_uniq;
1.1 root 1288: k->fd = -1;
1289: k->file_pos = 0;
1.1.1.3 root 1290: k->next = unit->keys;
1291: unit->keys = k;
1.1 root 1292:
1293: return k;
1294: }
1295:
1296: static void
1.1.1.4 root 1297: dumplock (Unit *unit, uaecptr lock)
1.1 root 1298: {
1.1.1.7 root 1299: a_inode *a;
1.1.1.4 root 1300: TRACE(("LOCK: 0x%lx", lock));
1301: if (!lock) {
1302: TRACE(("\n"));
1.1 root 1303: return;
1304: }
1.1.1.4 root 1305: TRACE(("{ next=0x%lx, mode=%ld, handler=0x%lx, volume=0x%lx, aino %lx ",
1.1.1.7 root 1306: get_long (lock) << 2, get_long (lock+8),
1307: get_long (lock+12), get_long (lock+16),
1308: get_long (lock + 4)));
1.1.1.3 root 1309: a = lookup_aino (unit, get_long (lock + 4));
1310: if (a == 0) {
1.1.1.4 root 1311: TRACE(("not found!"));
1.1.1.3 root 1312: } else {
1.1.1.4 root 1313: TRACE(("%s", a->nname));
1.1.1.3 root 1314: }
1.1.1.4 root 1315: TRACE((" }\n"));
1.1 root 1316: }
1317:
1.1.1.7 root 1318: static a_inode *find_aino (Unit *unit, uaecptr lock, const char *name, uae_u32 *err)
1.1 root 1319: {
1.1.1.7 root 1320: a_inode *a;
1.1 root 1321:
1.1.1.3 root 1322: if (lock) {
1.1.1.7 root 1323: a_inode *olda = lookup_aino (unit, get_long (lock + 4));
1.1.1.3 root 1324: if (olda == 0) {
1325: /* That's the best we can hope to do. */
1326: a = get_aino (unit, &unit->rootnode, name, err);
1.1 root 1327: } else {
1.1.1.4 root 1328: TRACE(("aino: 0x%08lx", (unsigned long int)olda->uniq));
1329: TRACE((" \"%s\"\n", olda->nname));
1.1.1.3 root 1330: a = get_aino (unit, olda, name, err);
1.1 root 1331: }
1332: } else {
1.1.1.3 root 1333: a = get_aino (unit, &unit->rootnode, name, err);
1.1 root 1334: }
1.1.1.3 root 1335: if (a) {
1.1.1.4 root 1336: TRACE(("aino=\"%s\"\n", a->nname));
1.1.1.3 root 1337: }
1338: return a;
1.1 root 1339: }
1340:
1.1.1.4 root 1341: static uaecptr make_lock (Unit *unit, uae_u32 uniq, long mode)
1.1 root 1342: {
1.1.1.3 root 1343: /* allocate lock from the list kept by the assembly code */
1344: uaecptr lock;
1.1 root 1345:
1.1.1.3 root 1346: lock = get_long (unit->locklist);
1347: put_long (unit->locklist, get_long (lock));
1348: lock += 4;
1.1 root 1349:
1.1.1.7 root 1350: put_long (lock + 4, uniq);
1351: put_long (lock + 8, mode);
1352: put_long (lock + 12, unit->port);
1353: put_long (lock + 16, unit->volume >> 2);
1.1 root 1354:
1355: /* prepend to lock chain */
1.1.1.7 root 1356: put_long (lock, get_long (unit->volume + 28));
1357: put_long (unit->volume + 28, lock >> 2);
1.1 root 1358:
1.1.1.3 root 1359: DUMPLOCK(unit, lock);
1.1 root 1360: return lock;
1361: }
1362:
1.1.1.4 root 1363: static void free_lock (Unit *unit, uaecptr lock)
1.1 root 1364: {
1.1.1.4 root 1365: if (! lock)
1.1 root 1366: return;
1367:
1.1.1.7 root 1368: if (lock == get_long (unit->volume + 28) << 2) {
1369: put_long (unit->volume + 28, get_long (lock));
1.1 root 1370: } else {
1.1.1.7 root 1371: uaecptr current = get_long (unit->volume + 28);
1.1.1.3 root 1372: uaecptr next = 0;
1.1.1.4 root 1373: while (current) {
1.1.1.7 root 1374: next = get_long (current << 2);
1.1.1.4 root 1375: if (lock == next << 2)
1.1 root 1376: break;
1377: current = next;
1378: }
1.1.1.7 root 1379: put_long (current << 2, get_long (lock));
1.1 root 1380: }
1.1.1.3 root 1381: lock -= 4;
1382: put_long (lock, get_long (unit->locklist));
1383: put_long (unit->locklist, lock);
1.1 root 1384: }
1385:
1386: static void
1.1.1.4 root 1387: action_lock (Unit *unit, dpacket packet)
1.1 root 1388: {
1.1.1.3 root 1389: uaecptr lock = GET_PCK_ARG1 (packet) << 2;
1390: uaecptr name = GET_PCK_ARG2 (packet) << 2;
1391: long mode = GET_PCK_ARG3 (packet);
1.1.1.7 root 1392: a_inode *a;
1.1.1.3 root 1393: uae_u32 err;
1.1 root 1394:
1.1.1.3 root 1395: if (mode != -2 && mode != -1) {
1.1.1.4 root 1396: TRACE(("Bad mode.\n"));
1.1.1.3 root 1397: mode = -2;
1398: }
1.1 root 1399:
1.1.1.4 root 1400: TRACE(("ACTION_LOCK(0x%lx, \"%s\", %d)\n", lock, bstr (unit, name), mode));
1.1.1.3 root 1401: DUMPLOCK(unit, lock);
1.1 root 1402:
1.1.1.3 root 1403: a = find_aino (unit, lock, bstr (unit, name), &err);
1404: if (err == 0 && (a->elock || (mode != -2 && a->shlock > 0))) {
1405: err = ERROR_OBJECT_IN_USE;
1.1 root 1406: }
1.1.1.3 root 1407: /* Lock() doesn't do access checks. */
1408: if (err != 0) {
1409: PUT_PCK_RES1 (packet, DOS_FALSE);
1410: PUT_PCK_RES2 (packet, err);
1411: return;
1412: }
1413: if (mode == -2)
1414: a->shlock++;
1415: else
1416: a->elock = 1;
1417: de_recycle_aino (unit, a);
1418: PUT_PCK_RES1 (packet, make_lock (unit, a->uniq, mode) >> 2);
1.1 root 1419: }
1420:
1.1.1.4 root 1421: static void action_free_lock (Unit *unit, dpacket packet)
1.1 root 1422: {
1.1.1.3 root 1423: uaecptr lock = GET_PCK_ARG1 (packet) << 2;
1.1.1.7 root 1424: a_inode *a;
1.1.1.4 root 1425: TRACE(("ACTION_FREE_LOCK(0x%lx)\n", lock));
1.1.1.3 root 1426: DUMPLOCK(unit, lock);
1.1 root 1427:
1.1.1.3 root 1428: a = lookup_aino (unit, get_long (lock + 4));
1429: if (a == 0) {
1430: PUT_PCK_RES1 (packet, DOS_FALSE);
1.1.1.11 root 1431: PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_AROUND);
1.1.1.3 root 1432: return;
1433: }
1434: if (a->elock)
1435: a->elock = 0;
1436: else
1437: a->shlock--;
1438: recycle_aino (unit, a);
1.1 root 1439: free_lock(unit, lock);
1440:
1.1.1.3 root 1441: PUT_PCK_RES1 (packet, DOS_TRUE);
1.1 root 1442: }
1443:
1444: static void
1.1.1.4 root 1445: action_dup_lock (Unit *unit, dpacket packet)
1.1 root 1446: {
1.1.1.3 root 1447: uaecptr lock = GET_PCK_ARG1 (packet) << 2;
1.1.1.7 root 1448: a_inode *a;
1.1.1.4 root 1449: TRACE(("ACTION_DUP_LOCK(0x%lx)\n", lock));
1.1.1.3 root 1450: DUMPLOCK(unit, lock);
1.1 root 1451:
1.1.1.4 root 1452: if (!lock) {
1.1.1.3 root 1453: PUT_PCK_RES1 (packet, 0);
1.1 root 1454: return;
1455: }
1.1.1.3 root 1456: a = lookup_aino (unit, get_long (lock + 4));
1457: if (a == 0) {
1458: PUT_PCK_RES1 (packet, DOS_FALSE);
1.1.1.11 root 1459: PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_AROUND);
1.1.1.3 root 1460: return;
1.1 root 1461: }
1.1.1.3 root 1462: /* DupLock()ing exclusive locks isn't possible, says the Autodoc, but
1463: * at least the RAM-Handler seems to allow it. Let's see what happens
1464: * if we don't. */
1465: if (a->elock) {
1466: PUT_PCK_RES1 (packet, DOS_FALSE);
1467: PUT_PCK_RES2 (packet, ERROR_OBJECT_IN_USE);
1468: return;
1469: }
1470: a->shlock++;
1471: de_recycle_aino (unit, a);
1472: PUT_PCK_RES1 (packet, make_lock (unit, a->uniq, -2) >> 2);
1.1 root 1473: }
1474:
1475: /* convert time_t to/from AmigaDOS time */
1476: const int secs_per_day = 24 * 60 * 60;
1477: const int diff = (8 * 365 + 2) * (24 * 60 * 60);
1478:
1479: static void
1.1.1.4 root 1480: get_time (time_t t, long* days, long* mins, long* ticks)
1.1 root 1481: {
1482: /* time_t is secs since 1-1-1970 */
1483: /* days since 1-1-1978 */
1484: /* mins since midnight */
1485: /* ticks past minute @ 50Hz */
1486:
1487: t -= diff;
1488: *days = t / secs_per_day;
1489: t -= *days * secs_per_day;
1490: *mins = t / 60;
1491: t -= *mins * 60;
1492: *ticks = t * 50;
1493: }
1494:
1495: static time_t
1.1.1.4 root 1496: put_time (long days, long mins, long ticks)
1.1 root 1497: {
1498: time_t t;
1499: t = ticks / 50;
1500: t += mins * 60;
1501: t += days * secs_per_day;
1502: t += diff;
1503:
1504: return t;
1505: }
1506:
1.1.1.4 root 1507: static void free_exkey (ExamineKey *ek)
1.1 root 1508: {
1.1.1.3 root 1509: ek->aino = 0;
1510: ek->uniq = 0;
1511: if (ek->dir)
1512: closedir (ek->dir);
1.1 root 1513: }
1514:
1.1.1.3 root 1515: /* This is so sick... who invented ACTION_EXAMINE_NEXT? What did he THINK??? */
1.1.1.7 root 1516: static ExamineKey *new_exkey (Unit *unit, a_inode *aino)
1.1 root 1517: {
1.1.1.3 root 1518: uae_u32 uniq;
1519: uae_u32 oldest = 0xFFFFFFFF;
1520: ExamineKey *ek, *oldest_ek = 0;
1521: int i;
1522:
1523: ek = unit->examine_keys;
1524: for (i = 0; i < EXKEYS; i++, ek++) {
1525: /* Did we find a free one? */
1526: if (ek->aino == 0)
1527: continue;
1528: if (ek->uniq < oldest)
1529: oldest = (oldest_ek = ek)->uniq;
1530: }
1531: ek = unit->examine_keys;
1532: for (i = 0; i < EXKEYS; i++, ek++) {
1533: /* Did we find a free one? */
1534: if (ek->aino == 0)
1535: goto found;
1536: }
1537: /* This message should usually be harmless. */
1538: write_log ("Houston, we have a problem.\n");
1539: free_exkey (oldest_ek);
1540: ek = oldest_ek;
1541: found:
1542:
1543: uniq = unit->next_exkey;
1544: if (uniq == 0xFFFFFFFF) {
1545: /* Things will probably go wrong, but most likely the Amiga will crash
1546: * before this happens because of something else. */
1547: uniq = 1;
1.1 root 1548: }
1.1.1.3 root 1549: unit->next_exkey = uniq+1;
1550: ek->aino = aino;
1.1 root 1551: ek->dir = 0;
1552: ek->uniq = uniq;
1553: return ek;
1554: }
1555:
1.1.1.4 root 1556: static ExamineKey *lookup_exkey (Unit *unit, uae_u32 uniq)
1.1.1.3 root 1557: {
1558: ExamineKey *ek;
1559: int i;
1560:
1561: ek = unit->examine_keys;
1562: for (i = 0; i < EXKEYS; i++, ek++) {
1563: /* Did we find a free one? */
1564: if (ek->uniq == uniq)
1565: return ek;
1566: }
1567: write_log ("Houston, we have a BIG problem.\n");
1568: return 0;
1569: }
1570:
1.1 root 1571: static void
1.1.1.7 root 1572: get_fileinfo (Unit *unit, dpacket packet, uaecptr info, a_inode *aino)
1.1 root 1573: {
1574: struct stat statbuf;
1575: long days, mins, ticks;
1.1.1.3 root 1576: int i, n;
1577: char *x;
1578:
1579: /* No error checks - this had better work. */
1580: stat (aino->nname, &statbuf);
1581:
1582: if (aino->parent == 0) {
1583: x = unit->ui.volname;
1584: put_long (info + 4, 1);
1585: put_long (info + 120, 1);
1.1 root 1586: } else {
1.1.1.3 root 1587: /* AmigaOS docs say these have to contain the same value. */
1.1.1.7 root 1588: put_long (info + 4, aino->dir ? 2 : -3);
1589: put_long (info + 120, aino->dir ? 2 : -3);
1590: x = aino->aname;
1.1.1.3 root 1591: }
1.1.1.4 root 1592: TRACE(("name=\"%s\"\n", x));
1.1.1.7 root 1593: n = strlen (x);
1.1.1.3 root 1594: if (n > 106)
1595: n = 106;
1596: i = 8;
1.1.1.7 root 1597: put_byte (info + i, n); i++;
1598: while (n--)
1599: put_byte (info + i, *x), i++, x++;
1600: while (i < 108)
1601: put_byte (info + i, 0), i++;
1.1.1.3 root 1602:
1603: put_long (info + 116, aino->amigaos_mode);
1.1.1.7 root 1604: put_long (info + 124, statbuf.st_size);
1.1 root 1605: #ifdef HAVE_ST_BLOCKS
1.1.1.7 root 1606: put_long (info + 128, statbuf.st_blocks);
1.1 root 1607: #else
1.1.1.7 root 1608: put_long (info + 128, statbuf.st_size / 512 + 1);
1.1 root 1609: #endif
1.1.1.7 root 1610: get_time (statbuf.st_mtime, &days, &mins, &ticks);
1611: put_long (info + 132, days);
1612: put_long (info + 136, mins);
1613: put_long (info + 140, ticks);
1614: if (aino->comment == 0)
1615: put_long (info + 144, 0);
1616: else {
1617: TRACE(("comment=\"%s\"\n", aino->comment));
1618: i = 144;
1619: n = strlen (x = aino->comment);
1620: if (n > 78)
1621: n = 78;
1622: put_byte (info + i, n); i++;
1623: while (n--)
1624: put_byte (info + i, *x), i++, x++;
1625: while (i < 224)
1626: put_byte (info + i, 0), i++;
1627: }
1.1.1.3 root 1628: PUT_PCK_RES1 (packet, DOS_TRUE);
1.1 root 1629: }
1630:
1.1.1.4 root 1631: static void do_examine (Unit *unit, dpacket packet, ExamineKey *ek, uaecptr info)
1.1 root 1632: {
1.1.1.3 root 1633: struct dirent de_space;
1.1 root 1634: struct dirent* de;
1.1.1.7 root 1635: a_inode *aino;
1.1.1.3 root 1636: uae_u32 err;
1.1 root 1637:
1.1.1.3 root 1638: if (!ek->dir) {
1639: ek->dir = opendir (ek->aino->nname);
1.1 root 1640: }
1.1.1.3 root 1641: if (!ek->dir) {
1642: free_exkey (ek);
1643: PUT_PCK_RES1 (packet, DOS_FALSE);
1644: PUT_PCK_RES2 (packet, ERROR_NO_MORE_ENTRIES);
1.1 root 1645: return;
1646: }
1647:
1.1.1.7 root 1648: do {
1.1.1.3 root 1649: de = my_readdir (ek->dir, &de_space);
1.1.1.7 root 1650: } while (de && fsdb_name_invalid (de->d_name));
1.1 root 1651:
1.1.1.3 root 1652: if (!de) {
1.1.1.4 root 1653: TRACE(("no more entries\n"));
1.1.1.3 root 1654: free_exkey (ek);
1655: PUT_PCK_RES1 (packet, DOS_FALSE);
1656: PUT_PCK_RES2 (packet, ERROR_NO_MORE_ENTRIES);
1.1 root 1657: return;
1658: }
1659:
1.1.1.4 root 1660: TRACE(("entry=\"%s\"\n", de->d_name));
1.1.1.3 root 1661: aino = lookup_child_aino_for_exnext (unit, ek->aino, de->d_name, &err);
1662: if (err != 0) {
1663: write_log ("Severe problem in ExNext.\n");
1664: free_exkey (ek);
1665: PUT_PCK_RES1 (packet, DOS_FALSE);
1666: PUT_PCK_RES2 (packet, err);
1667: return;
1668: }
1669: get_fileinfo (unit, packet, info, aino);
1.1 root 1670: }
1671:
1.1.1.4 root 1672: static void action_examine_object (Unit *unit, dpacket packet)
1.1 root 1673: {
1.1.1.3 root 1674: uaecptr lock = GET_PCK_ARG1 (packet) << 2;
1675: uaecptr info = GET_PCK_ARG2 (packet) << 2;
1.1.1.7 root 1676: a_inode *aino = 0;
1.1 root 1677:
1.1.1.4 root 1678: TRACE(("ACTION_EXAMINE_OBJECT(0x%lx,0x%lx)\n", lock, info));
1.1.1.3 root 1679: DUMPLOCK(unit, lock);
1.1 root 1680:
1.1.1.3 root 1681: if (lock != 0)
1.1.1.7 root 1682: aino = lookup_aino (unit, get_long (lock + 4));
1.1.1.3 root 1683: if (aino == 0)
1684: aino = &unit->rootnode;
1685:
1686: get_fileinfo (unit, packet, info, aino);
1687: if (aino->dir) {
1.1.1.7 root 1688: put_long (info, 0xFFFFFFFF);
1.1.1.3 root 1689: } else
1.1.1.7 root 1690: put_long (info, 0);
1.1 root 1691: }
1692:
1.1.1.4 root 1693: static void action_examine_next (Unit *unit, dpacket packet)
1.1 root 1694: {
1.1.1.3 root 1695: uaecptr lock = GET_PCK_ARG1 (packet) << 2;
1696: uaecptr info = GET_PCK_ARG2 (packet) << 2;
1.1.1.7 root 1697: a_inode *aino = 0;
1.1.1.3 root 1698: ExamineKey *ek;
1699: uae_u32 uniq;
1.1 root 1700:
1.1.1.4 root 1701: TRACE(("ACTION_EXAMINE_NEXT(0x%lx,0x%lx)\n", lock, info));
1.1.1.3 root 1702: DUMPLOCK(unit, lock);
1.1 root 1703:
1.1.1.3 root 1704: if (lock != 0)
1.1.1.7 root 1705: aino = lookup_aino (unit, get_long (lock + 4));
1.1.1.3 root 1706: if (aino == 0)
1707: aino = &unit->rootnode;
1708:
1709: uniq = get_long (info);
1710: if (uniq == 0) {
1711: write_log ("ExNext called for a file! (Houston?)\n");
1712: PUT_PCK_RES1 (packet, DOS_FALSE);
1713: PUT_PCK_RES2 (packet, ERROR_NO_MORE_ENTRIES);
1714: return;
1715: } else if (uniq == 0xFFFFFFFF) {
1716: ek = new_exkey(unit, aino);
1717: } else
1.1.1.7 root 1718: ek = lookup_exkey (unit, get_long (info));
1.1.1.3 root 1719: if (ek == 0) {
1720: write_log ("Couldn't find a matching ExKey. Prepare for trouble.\n");
1721: PUT_PCK_RES1 (packet, DOS_FALSE);
1722: PUT_PCK_RES2 (packet, ERROR_NO_MORE_ENTRIES);
1723: return;
1724: }
1.1.1.7 root 1725: put_long (info, ek->uniq);
1726: do_examine (unit, packet, ek, info);
1.1 root 1727: }
1728:
1.1.1.4 root 1729: static void do_find (Unit *unit, dpacket packet, int mode, int create, int fallback)
1.1 root 1730: {
1.1.1.3 root 1731: uaecptr fh = GET_PCK_ARG1 (packet) << 2;
1732: uaecptr lock = GET_PCK_ARG2 (packet) << 2;
1733: uaecptr name = GET_PCK_ARG3 (packet) << 2;
1.1.1.7 root 1734: a_inode *aino;
1.1 root 1735: Key *k;
1.1.1.3 root 1736: int fd;
1737: uae_u32 err;
1738: mode_t openmode;
1739: int aino_created = 0;
1740:
1.1.1.4 root 1741: TRACE(("ACTION_FIND_*(0x%lx,0x%lx,\"%s\",%d)\n", fh, lock, bstr (unit, name), mode));
1.1.1.3 root 1742: DUMPLOCK(unit, lock);
1743:
1744: aino = find_aino (unit, lock, bstr (unit, name), &err);
1745:
1.1.1.11 root 1746: if (aino == 0 || (err != 0 && err != ERROR_OBJECT_NOT_AROUND)) {
1.1.1.3 root 1747: /* Whatever it is, we can't handle it. */
1748: PUT_PCK_RES1 (packet, DOS_FALSE);
1749: PUT_PCK_RES2 (packet, err);
1750: return;
1751: }
1752: if (err == 0) {
1753: /* Object exists. */
1754: if (aino->dir) {
1755: PUT_PCK_RES1 (packet, DOS_FALSE);
1756: PUT_PCK_RES2 (packet, ERROR_OBJECT_WRONG_TYPE);
1757: return;
1758: }
1759: if (aino->elock || (create == 2 && aino->shlock > 0)) {
1760: PUT_PCK_RES1 (packet, DOS_FALSE);
1761: PUT_PCK_RES2 (packet, ERROR_OBJECT_IN_USE);
1762: return;
1763: }
1764: if (create == 2 && (aino->amigaos_mode & A_FIBF_DELETE) != 0) {
1765: PUT_PCK_RES1 (packet, DOS_FALSE);
1766: PUT_PCK_RES2 (packet, ERROR_DELETE_PROTECTED);
1767: return;
1768: }
1769: if (create != 2) {
1770: if ((((mode & aino->amigaos_mode) & A_FIBF_WRITE) != 0 || unit->ui.readonly)
1771: && fallback)
1772: {
1773: mode &= ~A_FIBF_WRITE;
1774: }
1775: /* Kick 1.3 doesn't check read and write access bits - maybe it would be
1776: * simpler just not to do that either. */
1777: if ((mode & A_FIBF_WRITE) != 0 && unit->ui.readonly) {
1778: PUT_PCK_RES1 (packet, DOS_FALSE);
1779: PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
1780: return;
1781: }
1782: if (((mode & aino->amigaos_mode) & A_FIBF_WRITE) != 0
1783: || mode == 0)
1784: {
1785: PUT_PCK_RES1 (packet, DOS_FALSE);
1786: PUT_PCK_RES2 (packet, ERROR_WRITE_PROTECTED);
1787: return;
1788: }
1789: if (((mode & aino->amigaos_mode) & A_FIBF_READ) != 0) {
1790: PUT_PCK_RES1 (packet, DOS_FALSE);
1791: PUT_PCK_RES2 (packet, ERROR_READ_PROTECTED);
1792: return;
1793: }
1794: }
1795: } else if (create == 0) {
1796: PUT_PCK_RES1 (packet, DOS_FALSE);
1797: PUT_PCK_RES2 (packet, err);
1.1 root 1798: return;
1.1.1.3 root 1799: } else {
1800: /* Object does not exist. aino points to containing directory. */
1.1.1.7 root 1801: aino = create_child_aino (unit, aino, my_strdup (bstr_cut (unit, name)), 0);
1.1.1.3 root 1802: if (aino == 0) {
1803: PUT_PCK_RES1 (packet, DOS_FALSE);
1.1.1.6 root 1804: PUT_PCK_RES2 (packet, ERROR_DISK_IS_FULL); /* best we can do */
1.1 root 1805: return;
1806: }
1.1.1.3 root 1807: aino_created = 1;
1.1 root 1808: }
1809:
1.1.1.3 root 1810: prepare_for_open (aino->nname);
1.1 root 1811:
1.1.1.3 root 1812: openmode = (((mode & A_FIBF_READ) == 0 ? O_WRONLY
1813: : (mode & A_FIBF_WRITE) == 0 ? O_RDONLY
1814: : O_RDWR)
1815: | (create ? O_CREAT : 0)
1816: | (create == 2 ? O_TRUNC : 0));
1817:
1818: fd = open (aino->nname, openmode | O_BINARY, 0777);
1819:
1820: if (fd < 0) {
1821: if (aino_created)
1822: delete_aino (unit, aino);
1823: PUT_PCK_RES1 (packet, DOS_FALSE);
1.1.1.7 root 1824: PUT_PCK_RES2 (packet, dos_errno ());
1.1 root 1825: return;
1826: }
1.1.1.3 root 1827: k = new_key (unit);
1828: k->fd = fd;
1829: k->aino = aino;
1.1 root 1830:
1.1.1.3 root 1831: put_long (fh+36, k->uniq);
1832: if (create == 2)
1833: aino->elock = 1;
1834: else
1835: aino->shlock++;
1836: de_recycle_aino (unit, aino);
1837: PUT_PCK_RES1 (packet, DOS_TRUE);
1.1 root 1838: }
1839:
1840: static void
1.1.1.6 root 1841: action_fh_from_lock (Unit *unit, dpacket packet)
1842: {
1843: uaecptr fh = GET_PCK_ARG1 (packet) << 2;
1844: uaecptr lock = GET_PCK_ARG2 (packet) << 2;
1.1.1.7 root 1845: a_inode *aino;
1.1.1.6 root 1846: Key *k;
1847: int fd;
1848: mode_t openmode;
1849: int mode;
1850:
1851: TRACE(("ACTION_FH_FROM_LOCK(0x%lx,0x%lx)\n",fh,lock));
1852: DUMPLOCK(unit,lock);
1853:
1854: if (!lock) {
1.1.1.7 root 1855: PUT_PCK_RES1 (packet, DOS_FALSE);
1856: PUT_PCK_RES2 (packet, 0);
1857: return;
1.1.1.6 root 1858: }
1859:
1860: aino = lookup_aino (unit, get_long (lock + 4));
1861: if (aino == 0)
1.1.1.7 root 1862: aino = &unit->rootnode;
1.1.1.6 root 1863: mode = aino->amigaos_mode; /* Use same mode for opened filehandle as existing Lock() */
1864:
1865: prepare_for_open (aino->nname);
1866:
1867: openmode = (((mode & A_FIBF_READ) == 0 ? O_WRONLY
1868: : (mode & A_FIBF_WRITE) == 0 ? O_RDONLY
1869: : O_RDWR));
1870:
1.1.1.8 root 1871: /* the files on CD really can have the write-bit set. */
1872: if (unit->ui.readonly)
1873: openmode = O_RDONLY;
1874:
1.1.1.6 root 1875: fd = open (aino->nname, openmode | O_BINARY, 0777);
1876:
1877: if (fd < 0) {
1878: PUT_PCK_RES1 (packet, DOS_FALSE);
1879: PUT_PCK_RES2 (packet, dos_errno());
1880: return;
1881: }
1882: k = new_key (unit);
1883: k->fd = fd;
1884: k->aino = aino;
1885:
1886: put_long (fh+36, k->uniq);
1887: /* I don't think I need to play with shlock count here, because I'm
1888: opening from an existing lock ??? */
1889:
1890: /* Is this right? I don't completely understand how this works. Do I
1891: also need to free_lock() my lock, since nobody else is going to? */
1892: de_recycle_aino (unit, aino);
1893: PUT_PCK_RES1 (packet, DOS_TRUE);
1894: /* PUT_PCK_RES2 (packet, k->uniq); - this shouldn't be necessary, try without it */
1895: }
1896:
1897: static void
1.1.1.4 root 1898: action_find_input (Unit *unit, dpacket packet)
1.1 root 1899: {
1.1.1.3 root 1900: do_find(unit, packet, A_FIBF_READ|A_FIBF_WRITE, 0, 1);
1.1 root 1901: }
1902:
1903: static void
1.1.1.4 root 1904: action_find_output (Unit *unit, dpacket packet)
1.1 root 1905: {
1.1.1.3 root 1906: if (unit->ui.readonly) {
1907: PUT_PCK_RES1 (packet, DOS_FALSE);
1908: PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
1.1 root 1909: return;
1910: }
1.1.1.3 root 1911: do_find(unit, packet, A_FIBF_READ|A_FIBF_WRITE, 2, 0);
1.1 root 1912: }
1913:
1914: static void
1.1.1.4 root 1915: action_find_write (Unit *unit, dpacket packet)
1.1 root 1916: {
1.1.1.3 root 1917: if (unit->ui.readonly) {
1918: PUT_PCK_RES1 (packet, DOS_FALSE);
1919: PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
1.1 root 1920: return;
1921: }
1.1.1.3 root 1922: do_find(unit, packet, A_FIBF_READ|A_FIBF_WRITE, 1, 0);
1.1 root 1923: }
1924:
1925: static void
1.1.1.4 root 1926: action_end (Unit *unit, dpacket packet)
1.1 root 1927: {
1928: Key *k;
1.1.1.4 root 1929: TRACE(("ACTION_END(0x%lx)\n", GET_PCK_ARG1 (packet)));
1.1 root 1930:
1.1.1.3 root 1931: k = lookup_key (unit, GET_PCK_ARG1 (packet));
1932: if (k != 0) {
1933: if (k->aino->elock)
1934: k->aino->elock = 0;
1935: else
1936: k->aino->shlock--;
1937: recycle_aino (unit, k->aino);
1938: free_key (unit, k);
1939: }
1940: PUT_PCK_RES1 (packet, DOS_TRUE);
1941: PUT_PCK_RES2 (packet, 0);
1.1 root 1942: }
1943:
1944: static void
1.1.1.4 root 1945: action_read (Unit *unit, dpacket packet)
1.1 root 1946: {
1.1.1.3 root 1947: Key *k = lookup_key (unit, GET_PCK_ARG1 (packet));
1948: uaecptr addr = GET_PCK_ARG2 (packet);
1949: long size = (uae_s32)GET_PCK_ARG3 (packet);
1.1 root 1950: int actual;
1951:
1.1.1.3 root 1952: if (k == 0) {
1953: PUT_PCK_RES1 (packet, DOS_FALSE);
1954: /* PUT_PCK_RES2 (packet, EINVAL); */
1955: return;
1956: }
1.1.1.4 root 1957: TRACE(("ACTION_READ(%s,0x%lx,%ld)\n",k->aino->nname,addr,size));
1.1 root 1958: #ifdef RELY_ON_LOADSEG_DETECTION
1.1.1.3 root 1959: /* HACK HACK HACK HACK
1.1 root 1960: * Try to detect a LoadSeg() */
1961: if (k->file_pos == 0 && size >= 4) {
1962: unsigned char buf[4];
1963: off_t currpos = lseek(k->fd, 0, SEEK_CUR);
1964: read(k->fd, buf, 4);
1965: lseek(k->fd, currpos, SEEK_SET);
1966: if (buf[0] == 0 && buf[1] == 0 && buf[2] == 3 && buf[3] == 0xF3)
1967: possible_loadseg();
1968: }
1969: #endif
1970: if (valid_address (addr, size)) {
1.1.1.3 root 1971: uae_u8 *realpt;
1.1 root 1972: realpt = get_real_address (addr);
1973: actual = read(k->fd, realpt, size);
1974:
1.1.1.2 root 1975: if (actual == 0) {
1.1.1.3 root 1976: PUT_PCK_RES1 (packet, 0);
1977: PUT_PCK_RES2 (packet, 0);
1.1.1.2 root 1978: } else if (actual < 0) {
1.1.1.3 root 1979: PUT_PCK_RES1 (packet, 0);
1980: PUT_PCK_RES2 (packet, dos_errno());
1.1 root 1981: } else {
1.1.1.3 root 1982: PUT_PCK_RES1 (packet, actual);
1.1 root 1983: k->file_pos += actual;
1984: }
1985: } else {
1986: char *buf;
1.1.1.4 root 1987: write_log ("unixfs warning: Bad pointer passed for read: %08x\n", addr);
1.1 root 1988: /* ugh this is inefficient but easy */
1989: buf = (char *)malloc(size);
1.1.1.4 root 1990: if (!buf) {
1.1.1.3 root 1991: PUT_PCK_RES1 (packet, -1);
1992: PUT_PCK_RES2 (packet, ERROR_NO_FREE_STORE);
1.1 root 1993: return;
1994: }
1995: actual = read(k->fd, buf, size);
1996:
1.1.1.2 root 1997: if (actual < 0) {
1.1.1.3 root 1998: PUT_PCK_RES1 (packet, 0);
1999: PUT_PCK_RES2 (packet, dos_errno());
1.1 root 2000: } else {
2001: int i;
1.1.1.3 root 2002: PUT_PCK_RES1 (packet, actual);
1.1.1.4 root 2003: for (i = 0; i < actual; i++)
1.1 root 2004: put_byte(addr + i, buf[i]);
2005: k->file_pos += actual;
2006: }
1.1.1.4 root 2007: free (buf);
1.1 root 2008: }
2009: }
2010:
2011: static void
1.1.1.4 root 2012: action_write (Unit *unit, dpacket packet)
1.1 root 2013: {
1.1.1.3 root 2014: Key *k = lookup_key (unit, GET_PCK_ARG1 (packet));
2015: uaecptr addr = GET_PCK_ARG2 (packet);
2016: long size = GET_PCK_ARG3 (packet);
1.1 root 2017: char *buf;
2018: int i;
2019:
1.1.1.3 root 2020: if (k == 0) {
2021: PUT_PCK_RES1 (packet, DOS_FALSE);
2022: /* PUT_PCK_RES2 (packet, EINVAL); */
2023: return;
2024: }
1.1 root 2025:
1.1.1.4 root 2026: TRACE(("ACTION_WRITE(%s,0x%lx,%ld)\n",k->aino->nname,addr,size));
1.1.1.3 root 2027:
2028: if (unit->ui.readonly) {
2029: PUT_PCK_RES1 (packet, DOS_FALSE);
2030: PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
1.1 root 2031: return;
2032: }
2033:
2034: /* ugh this is inefficient but easy */
2035: buf = (char *)malloc(size);
1.1.1.3 root 2036: if (!buf) {
2037: PUT_PCK_RES1 (packet, -1);
2038: PUT_PCK_RES2 (packet, ERROR_NO_FREE_STORE);
1.1 root 2039: return;
2040: }
2041:
1.1.1.3 root 2042: for (i = 0; i < size; i++)
1.1 root 2043: buf[i] = get_byte(addr + i);
2044:
1.1.1.3 root 2045: PUT_PCK_RES1 (packet, write(k->fd, buf, size));
2046: if (GET_PCK_RES1 (packet) != size)
2047: PUT_PCK_RES2 (packet, dos_errno ());
2048: if (GET_PCK_RES1 (packet) >= 0)
2049: k->file_pos += GET_PCK_RES1 (packet);
1.1 root 2050:
1.1.1.4 root 2051: free (buf);
1.1 root 2052: }
2053:
2054: static void
1.1.1.4 root 2055: action_seek (Unit *unit, dpacket packet)
1.1 root 2056: {
1.1.1.4 root 2057: Key *k = lookup_key (unit, GET_PCK_ARG1 (packet));
1.1.1.3 root 2058: long pos = (uae_s32)GET_PCK_ARG2 (packet);
2059: long mode = (uae_s32)GET_PCK_ARG3 (packet);
1.1 root 2060: off_t res;
2061: long old;
2062: int whence = SEEK_CUR;
2063:
1.1.1.3 root 2064: if (k == 0) {
2065: PUT_PCK_RES1 (packet, -1);
2066: PUT_PCK_RES2 (packet, ERROR_INVALID_LOCK);
2067: return;
2068: }
1.1 root 2069:
1.1.1.3 root 2070: if (mode > 0) whence = SEEK_END;
2071: if (mode < 0) whence = SEEK_SET;
1.1 root 2072:
1.1.1.4 root 2073: TRACE(("ACTION_SEEK(%s,%d,%d)\n", k->aino->nname, pos, mode));
1.1.1.3 root 2074:
2075: old = lseek (k->fd, 0, SEEK_CUR);
2076: res = lseek (k->fd, pos, whence);
2077:
2078: if (-1 == res) {
2079: PUT_PCK_RES1 (packet, res);
2080: PUT_PCK_RES2 (packet, ERROR_SEEK_ERROR);
2081: } else
2082: PUT_PCK_RES1 (packet, old);
1.1 root 2083: k->file_pos = res;
2084: }
2085:
2086: static void
1.1.1.4 root 2087: action_set_protect (Unit *unit, dpacket packet)
1.1 root 2088: {
1.1.1.3 root 2089: uaecptr lock = GET_PCK_ARG2 (packet) << 2;
2090: uaecptr name = GET_PCK_ARG3 (packet) << 2;
2091: uae_u32 mask = GET_PCK_ARG4 (packet);
1.1.1.7 root 2092: a_inode *a;
1.1.1.3 root 2093: uae_u32 err;
1.1 root 2094:
1.1.1.4 root 2095: TRACE(("ACTION_SET_PROTECT(0x%lx,\"%s\",0x%lx)\n", lock, bstr (unit, name), mask));
1.1 root 2096:
1.1.1.3 root 2097: if (unit->ui.readonly) {
2098: PUT_PCK_RES1 (packet, DOS_FALSE);
2099: PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
1.1 root 2100: return;
2101: }
2102:
1.1.1.3 root 2103: a = find_aino (unit, lock, bstr (unit, name), &err);
2104: if (err != 0) {
2105: PUT_PCK_RES1 (packet, DOS_FALSE);
2106: PUT_PCK_RES2 (packet, err);
1.1 root 2107: return;
2108: }
2109:
1.1.1.7 root 2110: err = fsdb_set_file_attrs (a, mask);
1.1.1.3 root 2111: if (err != 0) {
2112: PUT_PCK_RES1 (packet, DOS_FALSE);
2113: PUT_PCK_RES2 (packet, err);
2114: } else {
2115: PUT_PCK_RES1 (packet, DOS_TRUE);
1.1.1.2 root 2116: }
1.1.1.3 root 2117: }
1.1 root 2118:
1.1.1.7 root 2119: static void action_set_comment (Unit * unit, dpacket packet)
2120: {
2121: uaecptr lock = GET_PCK_ARG2 (packet) << 2;
2122: uaecptr name = GET_PCK_ARG3 (packet) << 2;
2123: uaecptr comment = GET_PCK_ARG4 (packet) << 2;
2124: char *commented;
2125: a_inode *a;
2126: uae_u32 err;
2127: long res1, res2;
2128:
2129: if (unit->ui.readonly) {
2130: PUT_PCK_RES1 (packet, DOS_FALSE);
2131: PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
2132: return;
2133: }
2134:
2135: commented = bstr (unit, comment);
2136: commented = strlen (commented) > 0 ? my_strdup (commented) : 0;
2137: TRACE (("ACTION_SET_COMMENT(0x%lx,\"%s\")\n", lock, commented));
2138:
2139: a = find_aino (unit, lock, bstr (unit, name), &err);
2140: if (err != 0) {
2141: PUT_PCK_RES1 (packet, DOS_FALSE);
2142: PUT_PCK_RES2 (packet, err);
2143:
2144: maybe_free_and_out:
2145: if (commented)
2146: free (commented);
2147: return;
2148: }
2149: PUT_PCK_RES1 (packet, DOS_TRUE);
2150: PUT_PCK_RES2 (packet, 0);
2151: if (a->comment == 0 && commented == 0)
2152: goto maybe_free_and_out;
2153: if (a->comment != 0 && commented != 0 && strcmp (a->comment, commented) == 0)
2154: goto maybe_free_and_out;
2155: if (a->comment)
2156: free (a->comment);
2157: a->comment = commented;
2158: a->dirty = 1;
2159: }
2160:
1.1.1.3 root 2161: static void
1.1.1.4 root 2162: action_same_lock (Unit *unit, dpacket packet)
1.1.1.3 root 2163: {
2164: uaecptr lock1 = GET_PCK_ARG1 (packet) << 2;
2165: uaecptr lock2 = GET_PCK_ARG2 (packet) << 2;
1.1 root 2166:
1.1.1.4 root 2167: TRACE(("ACTION_SAME_LOCK(0x%lx,0x%lx)\n",lock1,lock2));
1.1.1.3 root 2168: DUMPLOCK(unit, lock1); DUMPLOCK(unit, lock2);
1.1 root 2169:
1.1.1.3 root 2170: if (!lock1 || !lock2) {
2171: PUT_PCK_RES1 (packet, lock1 == lock2 ? DOS_TRUE : DOS_FALSE);
1.1 root 2172: } else {
1.1.1.3 root 2173: PUT_PCK_RES1 (packet, get_long (lock1 + 4) == get_long (lock2 + 4) ? DOS_TRUE : DOS_FALSE);
1.1 root 2174: }
2175: }
2176:
2177: static void
1.1.1.6 root 2178: action_change_mode (Unit *unit, dpacket packet)
1.1 root 2179: {
1.1.1.6 root 2180: #define CHANGE_LOCK 0
2181: #define CHANGE_FH 1
2182: /* will be CHANGE_FH or CHANGE_LOCK value */
2183: long type = GET_PCK_ARG1 (packet);
2184: /* either a file-handle or lock */
2185: uaecptr object = GET_PCK_ARG2 (packet) << 2;
2186: /* will be EXCLUSIVE_LOCK/SHARED_LOCK if CHANGE_LOCK,
2187: * or MODE_OLDFILE/MODE_NEWFILE/MODE_READWRITE if CHANGE_FH */
2188: long mode = GET_PCK_ARG3 (packet);
1.1.1.8 root 2189: unsigned long uniq;
1.1.1.7 root 2190: a_inode *a = NULL, *olda = NULL;
1.1.1.6 root 2191: uae_u32 err = 0;
2192: TRACE(("ACTION_CHANGE_MODE(0x%lx,%d,%d)\n",object,type,mode));
2193:
2194: if (! object
2195: || (type != CHANGE_FH && type != CHANGE_LOCK))
2196: {
1.1.1.7 root 2197: PUT_PCK_RES1 (packet, DOS_FALSE);
2198: PUT_PCK_RES2 (packet, ERROR_INVALID_LOCK);
2199: return;
1.1.1.6 root 2200: }
1.1 root 2201:
1.1.1.6 root 2202: /* @@@ Brian: shouldn't this be good enough to support
2203: CHANGE_FH? */
2204: if (type == CHANGE_FH)
2205: mode = (mode == 1006 ? -1 : -2);
1.1.1.8 root 2206:
2207: if (type == CHANGE_LOCK)
2208: uniq = get_long (object + 4);
2209: else {
2210: Key *k = lookup_key (unit, object);
2211: if (!k) {
2212: PUT_PCK_RES1 (packet, DOS_FALSE);
1.1.1.11 root 2213: PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_AROUND);
1.1.1.8 root 2214: return;
2215: }
2216: uniq = k->aino->uniq;
2217: }
2218: a = lookup_aino (unit, uniq);
2219:
1.1.1.6 root 2220: if (! a)
2221: err = ERROR_INVALID_LOCK;
2222: else {
2223: if (mode == -1) {
2224: if (a->shlock > 1)
2225: err = ERROR_OBJECT_IN_USE;
2226: else {
2227: a->shlock = 0;
2228: a->elock = 1;
2229: }
2230: } else { /* Must be SHARED_LOCK == -2 */
2231: a->elock = 0;
2232: a->shlock++;
2233: }
2234: }
2235:
2236: if (err) {
1.1.1.7 root 2237: PUT_PCK_RES1 (packet, DOS_FALSE);
2238: PUT_PCK_RES2 (packet, err);
2239: return;
1.1.1.6 root 2240: } else {
1.1.1.7 root 2241: de_recycle_aino (unit, a);
2242: PUT_PCK_RES1 (packet, DOS_TRUE);
1.1.1.3 root 2243: }
1.1.1.6 root 2244: }
1.1.1.3 root 2245:
1.1.1.6 root 2246: static void
1.1.1.8 root 2247: action_parent_common (Unit *unit, dpacket packet, unsigned long uniq)
1.1.1.6 root 2248: {
1.1.1.8 root 2249: a_inode *olda = lookup_aino (unit, uniq);
1.1.1.3 root 2250: if (olda == 0) {
2251: PUT_PCK_RES1 (packet, DOS_FALSE);
2252: PUT_PCK_RES2 (packet, ERROR_INVALID_LOCK);
2253: return;
2254: }
2255:
2256: if (olda->parent == 0) {
2257: PUT_PCK_RES1 (packet, 0);
2258: PUT_PCK_RES2 (packet, 0);
2259: return;
1.1 root 2260: }
1.1.1.3 root 2261: if (olda->parent->elock) {
2262: PUT_PCK_RES1 (packet, DOS_FALSE);
2263: PUT_PCK_RES2 (packet, ERROR_OBJECT_IN_USE);
2264: return;
2265: }
2266: olda->parent->shlock++;
2267: de_recycle_aino (unit, olda->parent);
2268: PUT_PCK_RES1 (packet, make_lock (unit, olda->parent->uniq, -2) >> 2);
1.1 root 2269: }
2270:
2271: static void
1.1.1.6 root 2272: action_parent_fh (Unit *unit, dpacket packet)
2273: {
1.1.1.8 root 2274: Key *k = lookup_key (unit, GET_PCK_ARG1 (packet));
2275: if (!k) {
1.1.1.7 root 2276: PUT_PCK_RES1 (packet, DOS_FALSE);
1.1.1.11 root 2277: PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_AROUND);
1.1.1.7 root 2278: return;
1.1.1.6 root 2279: }
1.1.1.8 root 2280: action_parent_common (unit, packet, k->aino->uniq);
1.1.1.6 root 2281: }
2282:
2283: static void
2284: action_parent (Unit *unit, dpacket packet)
2285: {
2286: uaecptr lock = GET_PCK_ARG1 (packet) << 2;
2287:
2288: TRACE(("ACTION_PARENT(0x%lx)\n",lock));
2289:
2290: if (!lock) {
2291: PUT_PCK_RES1 (packet, 0);
2292: PUT_PCK_RES2 (packet, 0);
2293: return;
2294: }
2295: action_parent_common (unit, packet, get_long (lock + 4));
2296: }
2297:
2298: static void
1.1.1.4 root 2299: action_create_dir (Unit *unit, dpacket packet)
1.1 root 2300: {
1.1.1.3 root 2301: uaecptr lock = GET_PCK_ARG1 (packet) << 2;
2302: uaecptr name = GET_PCK_ARG2 (packet) << 2;
1.1.1.7 root 2303: a_inode *aino;
1.1.1.3 root 2304: uae_u32 err;
1.1 root 2305:
1.1.1.4 root 2306: TRACE(("ACTION_CREATE_DIR(0x%lx,\"%s\")\n", lock, bstr (unit, name)));
1.1 root 2307:
1.1.1.3 root 2308: if (unit->ui.readonly) {
2309: PUT_PCK_RES1 (packet, DOS_FALSE);
2310: PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
1.1 root 2311: return;
2312: }
2313:
1.1.1.3 root 2314: aino = find_aino (unit, lock, bstr (unit, name), &err);
1.1.1.11 root 2315: if (aino == 0 || (err != 0 && err != ERROR_OBJECT_NOT_AROUND)) {
1.1.1.3 root 2316: PUT_PCK_RES1 (packet, DOS_FALSE);
2317: PUT_PCK_RES2 (packet, err);
1.1 root 2318: return;
2319: }
1.1.1.3 root 2320: if (err == 0) {
2321: /* Object exists. */
2322: PUT_PCK_RES1 (packet, DOS_FALSE);
2323: PUT_PCK_RES2 (packet, ERROR_OBJECT_EXISTS);
2324: return;
1.1 root 2325: }
1.1.1.3 root 2326: /* Object does not exist. aino points to containing directory. */
1.1.1.7 root 2327: aino = create_child_aino (unit, aino, my_strdup (bstr_cut (unit, name)), 1);
1.1.1.3 root 2328: if (aino == 0) {
2329: PUT_PCK_RES1 (packet, DOS_FALSE);
1.1.1.6 root 2330: PUT_PCK_RES2 (packet, ERROR_DISK_IS_FULL); /* best we can do */
1.1.1.3 root 2331: return;
2332: }
2333:
2334: if (mkdir (aino->nname, 0777) == -1) {
2335: PUT_PCK_RES1 (packet, DOS_FALSE);
2336: PUT_PCK_RES2 (packet, dos_errno());
2337: return;
2338: }
2339: aino->shlock = 1;
2340: de_recycle_aino (unit, aino);
2341: PUT_PCK_RES1 (packet, make_lock (unit, aino->uniq, -2) >> 2);
1.1 root 2342: }
2343:
2344: static void
1.1.1.4 root 2345: action_examine_fh (Unit *unit, dpacket packet)
1.1 root 2346: {
1.1.1.3 root 2347: Key *k;
1.1.1.7 root 2348: a_inode *aino = 0;
1.1.1.3 root 2349: uaecptr info = GET_PCK_ARG2 (packet) << 2;
1.1 root 2350:
1.1.1.6 root 2351: TRACE(("ACTION_EXAMINE_FH(0x%lx,0x%lx)\n",
2352: GET_PCK_ARG1 (packet), GET_PCK_ARG2 (packet) ));
1.1 root 2353:
1.1.1.3 root 2354: k = lookup_key (unit, GET_PCK_ARG1 (packet));
2355: if (k != 0)
2356: aino = k->aino;
2357: if (aino == 0)
2358: aino = &unit->rootnode;
2359:
2360: get_fileinfo (unit, packet, info, aino);
2361: if (aino->dir)
1.1.1.6 root 2362: put_long (info, 0xFFFFFFFF);
1.1.1.3 root 2363: else
1.1.1.6 root 2364: put_long (info, 0);
1.1.1.3 root 2365: }
2366:
2367: /* For a nice example of just how contradictory documentation can be, see the
2368: * Autodoc for DOS:SetFileSize and the Packets.txt description of this packet...
2369: * This implementation tries to mimic the behaviour of the Kick 3.1 ramdisk
2370: * (which seems to match the Autodoc description). */
2371: static void
1.1.1.4 root 2372: action_set_file_size (Unit *unit, dpacket packet)
1.1.1.3 root 2373: {
2374: Key *k, *k1;
2375: off_t offset = GET_PCK_ARG2 (packet);
2376: long mode = (uae_s32)GET_PCK_ARG3 (packet);
2377: int whence = SEEK_CUR;
2378:
2379: if (mode > 0) whence = SEEK_END;
2380: if (mode < 0) whence = SEEK_SET;
1.1 root 2381:
1.1.1.4 root 2382: TRACE(("ACTION_SET_FILE_SIZE(0x%lx, %d, 0x%x)\n", GET_PCK_ARG1 (packet), offset, mode));
1.1 root 2383:
1.1.1.3 root 2384: k = lookup_key (unit, GET_PCK_ARG1 (packet));
2385: if (k == 0) {
2386: PUT_PCK_RES1 (packet, DOS_TRUE);
1.1.1.11 root 2387: PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_AROUND);
1.1 root 2388: return;
2389: }
1.1.1.3 root 2390:
2391: /* If any open files have file pointers beyond this size, truncate only
2392: * so far that these pointers do not become invalid. */
2393: for (k1 = unit->keys; k1; k1 = k1->next) {
2394: if (k != k1 && k->aino == k1->aino) {
2395: if (k1->file_pos > offset)
2396: offset = k1->file_pos;
2397: }
2398: }
2399:
2400: /* Write one then truncate: that should give the right size in all cases. */
2401: offset = lseek (k->fd, offset, whence);
2402: write (k->fd, /* whatever */(char *)&k1, 1);
2403: if (k->file_pos > offset)
2404: k->file_pos = offset;
2405: lseek (k->fd, k->file_pos, SEEK_SET);
2406:
1.1.1.6 root 2407: /* Brian: no bug here; the file _must_ be one byte too large after writing
2408: The write is supposed to guarantee that the file can't be smaller than
2409: the requested size, the truncate guarantees that it can't be larger.
2410: If we were to write one byte earlier we'd clobber file data. */
2411: if (truncate (k->aino->nname, offset) == -1) {
1.1.1.3 root 2412: PUT_PCK_RES1 (packet, DOS_FALSE);
2413: PUT_PCK_RES2 (packet, dos_errno ());
1.1 root 2414: return;
2415: }
1.1.1.3 root 2416:
2417: PUT_PCK_RES1 (packet, offset);
2418: PUT_PCK_RES2 (packet, 0);
1.1 root 2419: }
2420:
2421: static void
1.1.1.4 root 2422: action_delete_object (Unit *unit, dpacket packet)
1.1 root 2423: {
1.1.1.3 root 2424: uaecptr lock = GET_PCK_ARG1 (packet) << 2;
2425: uaecptr name = GET_PCK_ARG2 (packet) << 2;
1.1.1.7 root 2426: a_inode *a;
1.1.1.3 root 2427: uae_u32 err;
1.1 root 2428:
1.1.1.4 root 2429: TRACE(("ACTION_DELETE_OBJECT(0x%lx,\"%s\")\n", lock, bstr (unit, name)));
1.1 root 2430:
1.1.1.3 root 2431: if (unit->ui.readonly) {
2432: PUT_PCK_RES1 (packet, DOS_FALSE);
2433: PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
1.1 root 2434: return;
2435: }
2436:
1.1.1.3 root 2437: a = find_aino (unit, lock, bstr (unit, name), &err);
1.1 root 2438:
1.1.1.3 root 2439: if (err != 0) {
2440: PUT_PCK_RES1 (packet, DOS_FALSE);
2441: PUT_PCK_RES2 (packet, err);
1.1 root 2442: return;
2443: }
1.1.1.7 root 2444: if (a->amigaos_mode & A_FIBF_DELETE) {
2445: PUT_PCK_RES1 (packet, DOS_FALSE);
2446: PUT_PCK_RES2 (packet, ERROR_DELETE_PROTECTED);
2447: return;
2448: }
1.1.1.3 root 2449: if (a->shlock > 0 || a->elock) {
2450: PUT_PCK_RES1 (packet, DOS_FALSE);
2451: PUT_PCK_RES2 (packet, ERROR_OBJECT_IN_USE);
1.1 root 2452: return;
2453: }
1.1.1.3 root 2454: if (a->dir) {
1.1.1.11 root 2455: /* This should take care of removing the fsdb if no files remain. */
2456: fsdb_dir_writeback (a);
1.1.1.3 root 2457: if (rmdir (a->nname) == -1) {
2458: PUT_PCK_RES1 (packet, DOS_FALSE);
2459: PUT_PCK_RES2 (packet, dos_errno());
1.1 root 2460: return;
2461: }
2462: } else {
1.1.1.3 root 2463: if (unlink (a->nname) == -1) {
2464: PUT_PCK_RES1 (packet, DOS_FALSE);
2465: PUT_PCK_RES2 (packet, dos_errno());
1.1 root 2466: return;
2467: }
2468: }
1.1.1.3 root 2469: if (a->child != 0) {
2470: write_log ("Serious error in action_delete_object.\n");
2471: } else {
2472: delete_aino (unit, a);
2473: }
2474: PUT_PCK_RES1 (packet, DOS_TRUE);
1.1 root 2475: }
2476:
2477: static void
1.1.1.4 root 2478: action_set_date (Unit *unit, dpacket packet)
1.1 root 2479: {
1.1.1.3 root 2480: uaecptr lock = GET_PCK_ARG2 (packet) << 2;
2481: uaecptr name = GET_PCK_ARG3 (packet) << 2;
2482: uaecptr date = GET_PCK_ARG4 (packet);
1.1.1.7 root 2483: a_inode *a;
1.1 root 2484: struct utimbuf ut;
1.1.1.3 root 2485: uae_u32 err;
1.1 root 2486:
1.1.1.4 root 2487: TRACE(("ACTION_SET_DATE(0x%lx,\"%s\")\n", lock, bstr (unit, name)));
1.1 root 2488:
1.1.1.4 root 2489: if (unit->ui.readonly) {
1.1.1.3 root 2490: PUT_PCK_RES1 (packet, DOS_FALSE);
2491: PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
1.1 root 2492: return;
2493: }
2494:
1.1.1.6 root 2495: ut.actime = ut.modtime = put_time(get_long (date), get_long (date + 4),
2496: get_long (date + 8));
1.1.1.3 root 2497: a = find_aino (unit, lock, bstr (unit, name), &err);
2498: if (err == 0 && utime (a->nname, &ut) == -1)
2499: err = dos_errno ();
2500: if (err != 0) {
2501: PUT_PCK_RES1 (packet, DOS_FALSE);
2502: PUT_PCK_RES2 (packet, err);
2503: } else
2504: PUT_PCK_RES1 (packet, DOS_TRUE);
1.1 root 2505: }
2506:
2507: static void
1.1.1.4 root 2508: action_rename_object (Unit *unit, dpacket packet)
1.1 root 2509: {
1.1.1.3 root 2510: uaecptr lock1 = GET_PCK_ARG1 (packet) << 2;
2511: uaecptr name1 = GET_PCK_ARG2 (packet) << 2;
2512: uaecptr lock2 = GET_PCK_ARG3 (packet) << 2;
2513: uaecptr name2 = GET_PCK_ARG4 (packet) << 2;
1.1.1.7 root 2514: a_inode *a1, *a2;
1.1.1.3 root 2515: uae_u32 err1, err2;
1.1 root 2516:
1.1.1.4 root 2517: TRACE(("ACTION_RENAME_OBJECT(0x%lx,\"%s\",", lock1, bstr (unit, name1)));
2518: TRACE(("0x%lx,\"%s\")\n", lock2, bstr (unit, name2)));
1.1 root 2519:
1.1.1.4 root 2520: if (unit->ui.readonly) {
1.1.1.3 root 2521: PUT_PCK_RES1 (packet, DOS_FALSE);
2522: PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
1.1 root 2523: return;
2524: }
2525:
1.1.1.3 root 2526: a1 = find_aino (unit, lock1, bstr (unit, name1), &err1);
2527: if (err1 != 0) {
2528: PUT_PCK_RES1 (packet, DOS_FALSE);
2529: PUT_PCK_RES2 (packet, err1);
2530: return;
2531: }
1.1.1.7 root 2532: /* See whether the other name already exists in the filesystem. */
1.1.1.3 root 2533: a2 = find_aino (unit, lock2, bstr (unit, name2), &err2);
1.1.1.7 root 2534: if (a2 == a1) {
2535: /* Renaming to the same name, but possibly different case. */
2536: if (strcmp (a1->aname, bstr_cut (unit, name2)) == 0) {
2537: /* Exact match -> do nothing. */
2538: PUT_PCK_RES1 (packet, DOS_TRUE);
2539: return;
2540: }
2541: a2 = a2->parent;
1.1.1.11 root 2542: } else if (a2 == 0 || err2 != ERROR_OBJECT_NOT_AROUND) {
1.1.1.3 root 2543: PUT_PCK_RES1 (packet, DOS_FALSE);
2544: PUT_PCK_RES2 (packet, err2 == 0 ? ERROR_OBJECT_EXISTS : err2);
1.1 root 2545: return;
2546: }
1.1.1.7 root 2547:
2548: a2 = create_child_aino (unit, a2, bstr_cut (unit, name2), a1->dir);
1.1.1.3 root 2549: if (a2 == 0) {
2550: PUT_PCK_RES1 (packet, DOS_FALSE);
1.1.1.6 root 2551: PUT_PCK_RES2 (packet, ERROR_DISK_IS_FULL); /* best we can do */
1.1 root 2552: return;
2553: }
2554:
1.1.1.3 root 2555: /* @@@ what should we do if there are locks on a1? */
1.1.1.5 root 2556: if (-1 == rename (a1->nname, a2->nname)) {
1.1.1.3 root 2557: PUT_PCK_RES1 (packet, DOS_FALSE);
1.1.1.5 root 2558: PUT_PCK_RES2 (packet, dos_errno ());
1.1 root 2559: return;
2560: }
1.1.1.7 root 2561: a2->comment = a1->comment;
2562: a1->comment = 0;
2563: a2->amigaos_mode = a1->amigaos_mode;
1.1.1.3 root 2564: move_aino_children (unit, a1, a2);
2565: delete_aino (unit, a1);
2566: PUT_PCK_RES1 (packet, DOS_TRUE);
1.1 root 2567: }
2568:
2569: static void
1.1.1.4 root 2570: action_current_volume (Unit *unit, dpacket packet)
1.1 root 2571: {
1.1.1.3 root 2572: PUT_PCK_RES1 (packet, unit->volume >> 2);
1.1 root 2573: }
2574:
2575: static void
1.1.1.4 root 2576: action_rename_disk (Unit *unit, dpacket packet)
1.1 root 2577: {
1.1.1.3 root 2578: uaecptr name = GET_PCK_ARG1 (packet) << 2;
1.1 root 2579: int i;
2580: int namelen;
2581:
1.1.1.4 root 2582: TRACE(("ACTION_RENAME_DISK(\"%s\")\n", bstr (unit, name)));
1.1 root 2583:
1.1.1.4 root 2584: if (unit->ui.readonly) {
1.1.1.3 root 2585: PUT_PCK_RES1 (packet, DOS_FALSE);
2586: PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
1.1 root 2587: return;
2588: }
2589:
2590: /* get volume name */
1.1.1.3 root 2591: namelen = get_byte (name); name++;
2592: free (unit->ui.volname);
2593: unit->ui.volname = (char *) xmalloc (namelen + 1);
1.1.1.4 root 2594: for (i = 0; i < namelen; i++, name++)
1.1.1.3 root 2595: unit->ui.volname[i] = get_byte (name);
1.1 root 2596: unit->ui.volname[i] = 0;
2597:
1.1.1.3 root 2598: put_byte (unit->volume + 44, namelen);
1.1.1.4 root 2599: for (i = 0; i < namelen; i++)
1.1.1.3 root 2600: put_byte (unit->volume + 45 + i, unit->ui.volname[i]);
1.1 root 2601:
1.1.1.3 root 2602: PUT_PCK_RES1 (packet, DOS_TRUE);
1.1 root 2603: }
2604:
2605: static void
1.1.1.4 root 2606: action_is_filesystem (Unit *unit, dpacket packet)
1.1 root 2607: {
1.1.1.3 root 2608: PUT_PCK_RES1 (packet, DOS_TRUE);
1.1 root 2609: }
2610:
2611: static void
1.1.1.4 root 2612: action_flush (Unit *unit, dpacket packet)
1.1 root 2613: {
2614: /* sync(); */ /* pretty drastic, eh */
1.1.1.3 root 2615: PUT_PCK_RES1 (packet, DOS_TRUE);
1.1 root 2616: }
2617:
1.1.1.3 root 2618: /* We don't want multiple interrupts to be active at the same time. I don't
2619: * know whether AmigaOS takes care of that, but this does. */
2620: static uae_sem_t singlethread_int_sem;
2621:
2622: static uae_u32 exter_int_helper (void)
2623: {
1.1.1.4 root 2624: UnitInfo *uip = current_mountinfo->ui;
1.1.1.7 root 2625: uaecptr port;
1.1.1.3 root 2626: static int unit_no;
2627:
2628: switch (m68k_dreg (regs, 0)) {
2629: case 0:
2630: /* Determine whether a given EXTER interrupt is for us. */
2631: if (uae_int_requested) {
2632: if (uae_sem_trywait (&singlethread_int_sem) != 0)
2633: /* Pretend it isn't for us. We might get it again later. */
2634: return 0;
2635: /* Clear the interrupt flag _before_ we do any processing.
2636: * That way, we can get too many interrupts, but never not
2637: * enough. */
2638: uae_int_requested = 0;
2639: unit_no = 0;
2640: return 1;
2641: }
1.1 root 2642: return 0;
1.1.1.3 root 2643: case 1:
2644: /* Release a message_lock. This is called as soon as the message is
2645: * received by the assembly code. We use the opportunity to check
2646: * whether we have some locks that we can give back to the assembler
2647: * code.
2648: * Note that this is called from the main loop, unlike the other cases
2649: * in this switch statement which are called from the interrupt handler.
2650: */
1.1.1.7 root 2651: #ifdef UAE_FILESYS_THREADS
1.1.1.3 root 2652: {
2653: Unit *unit = find_unit (m68k_areg (regs, 5));
2654: unit->cmds_complete = unit->cmds_acked;
2655: while (comm_pipe_has_data (unit->ui.back_pipe)) {
2656: uaecptr locks, lockend;
2657: locks = read_comm_pipe_int_blocking (unit->ui.back_pipe);
2658: lockend = locks;
2659: while (get_long (lockend) != 0)
2660: lockend = get_long (lockend);
2661: put_long (lockend, get_long (m68k_areg (regs, 3)));
2662: put_long (m68k_areg (regs, 3), locks);
2663: }
2664: }
1.1.1.7 root 2665: #else
2666: write_log ("exter_int_helper should not be called with arg 1!\n");
2667: #endif
1.1 root 2668: break;
1.1.1.3 root 2669: case 2:
1.1.1.7 root 2670: /* Find work that needs to be done:
2671: * return d0 = 0: none
2672: * d0 = 1: PutMsg(), port in a0, message in a1
2673: * d0 = 2: Signal(), task in a1, signal set in d1
2674: * d0 = 3: ReplyMsg(), message in a1 */
2675:
2676: #ifdef SUPPORT_THREADS
2677: /* First, check signals/messages */
2678: while (comm_pipe_has_data (&native2amiga_pending)) {
2679: switch (read_comm_pipe_int_blocking (&native2amiga_pending)) {
2680: case 0: /* Signal() */
2681: m68k_areg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
2682: m68k_dreg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
2683: return 2;
2684:
2685: case 1: /* PutMsg() */
2686: m68k_areg (regs, 0) = read_comm_pipe_u32_blocking (&native2amiga_pending);
2687: m68k_areg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
2688: return 1;
2689:
2690: case 2: /* ReplyMsg() */
2691: m68k_areg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
2692: return 3;
2693:
2694: default:
2695: write_log ("exter_int_helper: unknown native action\n");
2696: break;
2697: }
2698: }
2699: #endif
2700:
1.1.1.3 root 2701: /* Find some unit that needs a message sent, and return its port,
2702: * or zero if all are done.
2703: * Take care not to dereference self for units that didn't have their
2704: * startup packet sent. */
2705: for (;;) {
1.1.1.4 root 2706: if (unit_no >= current_mountinfo->num_units)
1.1.1.3 root 2707: return 0;
1.1.1.7 root 2708:
1.1.1.4 root 2709: if (uip[unit_no].self != 0
2710: && uip[unit_no].self->cmds_acked == uip[unit_no].self->cmds_complete
2711: && uip[unit_no].self->cmds_acked != uip[unit_no].self->cmds_sent)
1.1.1.3 root 2712: break;
2713: unit_no++;
2714: }
1.1.1.4 root 2715: uip[unit_no].self->cmds_acked = uip[unit_no].self->cmds_sent;
1.1.1.7 root 2716: port = uip[unit_no].self->port;
2717: if (port) {
2718: m68k_areg (regs, 0) = port;
2719: m68k_areg (regs, 1) = find_unit (port)->dummy_message;
2720: unit_no++;
2721: return 1;
1.1.1.3 root 2722: }
1.1 root 2723: break;
1.1.1.3 root 2724: case 4:
2725: /* Exit the interrupt, and release the single-threading lock. */
2726: uae_sem_post (&singlethread_int_sem);
1.1 root 2727: break;
2728:
1.1.1.3 root 2729: default:
2730: write_log ("Shouldn't happen in exter_int_helper.\n");
1.1 root 2731: break;
1.1.1.3 root 2732: }
2733: return 0;
2734: }
1.1 root 2735:
1.1.1.3 root 2736: static int handle_packet (Unit *unit, dpacket pck)
2737: {
2738: uae_s32 type = GET_PCK_TYPE (pck);
2739: PUT_PCK_RES2 (pck, 0);
2740: switch (type) {
1.1.1.4 root 2741: case ACTION_LOCATE_OBJECT: action_lock (unit, pck); break;
2742: case ACTION_FREE_LOCK: action_free_lock (unit, pck); break;
2743: case ACTION_COPY_DIR: action_dup_lock (unit, pck); break;
2744: case ACTION_DISK_INFO: action_disk_info (unit, pck); break;
2745: case ACTION_INFO: action_info (unit, pck); break;
2746: case ACTION_EXAMINE_OBJECT: action_examine_object (unit, pck); break;
2747: case ACTION_EXAMINE_NEXT: action_examine_next (unit, pck); break;
2748: case ACTION_FIND_INPUT: action_find_input (unit, pck); break;
2749: case ACTION_FIND_WRITE: action_find_write (unit, pck); break;
2750: case ACTION_FIND_OUTPUT: action_find_output (unit, pck); break;
2751: case ACTION_END: action_end (unit, pck); break;
2752: case ACTION_READ: action_read (unit, pck); break;
2753: case ACTION_WRITE: action_write (unit, pck); break;
2754: case ACTION_SEEK: action_seek (unit, pck); break;
2755: case ACTION_SET_PROTECT: action_set_protect (unit, pck); break;
1.1.1.7 root 2756: case ACTION_SET_COMMENT: action_set_comment (unit, pck); break;
1.1.1.4 root 2757: case ACTION_SAME_LOCK: action_same_lock (unit, pck); break;
2758: case ACTION_PARENT: action_parent (unit, pck); break;
2759: case ACTION_CREATE_DIR: action_create_dir (unit, pck); break;
2760: case ACTION_DELETE_OBJECT: action_delete_object (unit, pck); break;
2761: case ACTION_RENAME_OBJECT: action_rename_object (unit, pck); break;
2762: case ACTION_SET_DATE: action_set_date (unit, pck); break;
2763: case ACTION_CURRENT_VOLUME: action_current_volume (unit, pck); break;
2764: case ACTION_RENAME_DISK: action_rename_disk (unit, pck); break;
2765: case ACTION_IS_FILESYSTEM: action_is_filesystem (unit, pck); break;
2766: case ACTION_FLUSH: action_flush (unit, pck); break;
1.1.1.3 root 2767:
2768: /* 2.0+ packet types */
1.1.1.4 root 2769: case ACTION_SET_FILE_SIZE: action_set_file_size (unit, pck); break;
2770: case ACTION_EXAMINE_FH: action_examine_fh (unit, pck); break;
1.1.1.6 root 2771: case ACTION_FH_FROM_LOCK: action_fh_from_lock (unit, pck); break;
2772: case ACTION_CHANGE_MODE: action_change_mode (unit, pck); break;
2773: case ACTION_PARENT_FH: action_parent_fh (unit, pck); break;
1.1.1.3 root 2774:
2775: /* unsupported packets */
2776: case ACTION_LOCK_RECORD:
2777: case ACTION_FREE_RECORD:
2778: case ACTION_COPY_DIR_FH:
2779: case ACTION_EXAMINE_ALL:
2780: case ACTION_MAKE_LINK:
2781: case ACTION_READ_LINK:
2782: case ACTION_FORMAT:
2783: case ACTION_ADD_NOTIFY:
2784: case ACTION_REMOVE_NOTIFY:
2785: default:
1.1.1.4 root 2786: TRACE(("*** UNSUPPORTED PACKET %ld\n", type));
1.1.1.3 root 2787: return 0;
2788: }
2789: return 1;
2790: }
1.1 root 2791:
1.1.1.3 root 2792: #ifdef UAE_FILESYS_THREADS
2793: static void *filesys_penguin (void *unit_v)
2794: {
2795: UnitInfo *ui = (UnitInfo *)unit_v;
2796: for (;;) {
2797: uae_u8 *pck;
2798: uae_u8 *msg;
2799: uae_u32 morelocks;
2800: int i;
2801:
2802: pck = (uae_u8 *)read_comm_pipe_pvoid_blocking (ui->unit_pipe);
2803: msg = (uae_u8 *)read_comm_pipe_pvoid_blocking (ui->unit_pipe);
2804: morelocks = (uae_u32)read_comm_pipe_int_blocking (ui->unit_pipe);
2805:
1.1.1.4 root 2806: if (ui->reset_state == FS_GO_DOWN) {
1.1.1.3 root 2807: if (pck != 0)
2808: continue;
2809: /* Death message received. */
1.1.1.4 root 2810: uae_sem_post (&ui->reset_sync_sem);
2811: /* Die. */
2812: return 0;
1.1.1.3 root 2813: }
1.1 root 2814:
1.1.1.3 root 2815: put_long (get_long (morelocks), get_long (ui->self->locklist));
2816: put_long (ui->self->locklist, morelocks);
2817: if (! handle_packet (ui->self, pck)) {
2818: PUT_PCK_RES1 (pck, DOS_FALSE);
2819: PUT_PCK_RES2 (pck, ERROR_ACTION_NOT_KNOWN);
2820: }
2821: /* Mark the packet as processed for the list scan in the assembly code. */
2822: do_put_mem_long ((uae_u32 *)(msg + 4), -1);
2823: /* Acquire the message lock, so that we know we can safely send the
2824: * message. */
2825: ui->self->cmds_sent++;
2826: /* The message is sent by our interrupt handler, so make sure an interrupt
2827: * happens. */
2828: uae_int_requested = 1;
2829: /* Send back the locks. */
2830: if (get_long (ui->self->locklist) != 0)
1.1.1.7 root 2831: write_comm_pipe_int (ui->back_pipe, (int)(get_long (ui->self->locklist)), 0);
1.1.1.3 root 2832: put_long (ui->self->locklist, 0);
2833: }
2834: return 0;
2835: }
2836: #endif
1.1 root 2837:
1.1.1.3 root 2838: /* Talk about spaghetti code... */
1.1.1.4 root 2839: static uae_u32 filesys_handler (void)
1.1.1.3 root 2840: {
2841: Unit *unit = find_unit (m68k_areg (regs, 5));
2842: uaecptr packet_addr = m68k_dreg (regs, 3);
2843: uaecptr message_addr = m68k_areg (regs, 4);
2844: uae_u8 *pck;
2845: uae_u8 *msg;
2846: if (! valid_address (packet_addr, 36) || ! valid_address (message_addr, 14)) {
2847: write_log ("Bad address passed for packet.\n");
2848: goto error2;
2849: }
2850: pck = get_real_address (packet_addr);
2851: msg = get_real_address (message_addr);
2852:
1.1.1.4 root 2853: #if 0
1.1.1.3 root 2854: if (unit->reset_state == FS_GO_DOWN)
2855: /* You might as well queue it, if you live long enough */
2856: return 1;
1.1.1.4 root 2857: #endif
1.1.1.3 root 2858:
2859: do_put_mem_long ((uae_u32 *)(msg + 4), -1);
2860: if (!unit || !unit->volume) {
2861: write_log ("Filesystem was not initialized.\n");
2862: goto error;
2863: }
2864: #ifdef UAE_FILESYS_THREADS
2865: {
2866: /* Get two more locks and hand them over to the other thread. */
2867: uae_u32 morelocks;
2868: morelocks = get_long (m68k_areg (regs, 3));
2869: put_long (m68k_areg (regs, 3), get_long (get_long (morelocks)));
2870: put_long (get_long (morelocks), 0);
2871:
2872: /* The packet wasn't processed yet. */
2873: do_put_mem_long ((uae_u32 *)(msg + 4), 0);
2874: write_comm_pipe_pvoid (unit->ui.unit_pipe, (void *)pck, 0);
2875: write_comm_pipe_pvoid (unit->ui.unit_pipe, (void *)msg, 0);
2876: write_comm_pipe_int (unit->ui.unit_pipe, (int)morelocks, 1);
2877: /* Don't reply yet. */
2878: return 1;
2879: }
2880: #endif
1.1 root 2881:
1.1.1.3 root 2882: if (! handle_packet (unit, pck)) {
2883: error:
2884: PUT_PCK_RES1 (pck, DOS_FALSE);
2885: PUT_PCK_RES2 (pck, ERROR_ACTION_NOT_KNOWN);
2886: }
1.1.1.4 root 2887: TRACE(("reply: %8lx, %ld\n", GET_PCK_RES1 (pck), GET_PCK_RES2 (pck)));
1.1 root 2888:
1.1.1.3 root 2889: error2:
1.1 root 2890:
1.1.1.3 root 2891: return 0;
2892: }
1.1 root 2893:
1.1.1.11 root 2894: static int current_deviceno = 0;
2895:
2896: static void reset_uaedevices (void)
2897: {
2898: current_deviceno = 0;
2899: }
2900:
2901: static int get_new_device (char **devname, uaecptr *devname_amiga, int cdrom)
2902: {
2903: char buffer[80];
2904:
2905: sprintf (buffer, cdrom ? "CD%d" : "DH%d", current_deviceno);
2906:
2907: *devname_amiga = ds (*devname = my_strdup (buffer));
2908: return current_deviceno++;
2909: }
2910:
1.1.1.4 root 2911: void filesys_start_threads (void)
2912: {
2913: UnitInfo *uip;
2914: int i;
2915:
2916: current_mountinfo = dup_mountinfo (currprefs.mountinfo);
2917:
2918: reset_uaedevices ();
2919:
2920: uip = current_mountinfo->ui;
2921: for (i = 0; i < current_mountinfo->num_units; i++) {
2922: uip[i].unit_pipe = 0;
1.1.1.11 root 2923: uip[i].devno = get_new_device (&uip[i].devname, &uip[i].devname_amiga, 0);
1.1.1.4 root 2924:
2925: #ifdef UAE_FILESYS_THREADS
2926: if (! is_hardfile (current_mountinfo, i)) {
2927: uip[i].unit_pipe = (smp_comm_pipe *)xmalloc (sizeof (smp_comm_pipe));
2928: uip[i].back_pipe = (smp_comm_pipe *)xmalloc (sizeof (smp_comm_pipe));
2929: init_comm_pipe (uip[i].unit_pipe, 50, 3);
2930: init_comm_pipe (uip[i].back_pipe, 50, 1);
2931: start_penguin (filesys_penguin, (void *)(uip + i), &uip[i].tid);
2932: }
2933: #endif
2934: }
2935: }
2936:
1.1.1.3 root 2937: void filesys_reset (void)
2938: {
2939: Unit *u, *u1;
2940: int i;
1.1 root 2941:
1.1.1.4 root 2942: /* We get called once from customreset at the beginning of the program
2943: * before filesys_start_threads has been called. Survive that. */
2944: if (current_mountinfo == 0)
2945: return;
1.1 root 2946:
1.1.1.4 root 2947: for (u = units; u; u = u1) {
1.1.1.3 root 2948: u1 = u->next;
2949: free (u);
1.1 root 2950: }
1.1.1.3 root 2951: unit_num = 0;
2952: units = 0;
1.1.1.4 root 2953:
2954: free_mountinfo (current_mountinfo);
2955: current_mountinfo = 0;
1.1.1.3 root 2956: }
1.1 root 2957:
1.1.1.3 root 2958: void filesys_prepare_reset (void)
2959: {
1.1.1.4 root 2960: UnitInfo *uip = current_mountinfo->ui;
2961: Unit *u;
1.1.1.3 root 2962: int i;
1.1 root 2963:
1.1.1.3 root 2964: #ifdef UAE_FILESYS_THREADS
1.1.1.4 root 2965: for (i = 0; i < current_mountinfo->num_units; i++) {
2966: if (uip[i].unit_pipe != 0) {
2967: uae_sem_init (&uip[i].reset_sync_sem, 0, 0);
2968: uip[i].reset_state = FS_GO_DOWN;
1.1.1.3 root 2969: /* send death message */
1.1.1.4 root 2970: write_comm_pipe_int (uip[i].unit_pipe, 0, 0);
2971: write_comm_pipe_int (uip[i].unit_pipe, 0, 0);
2972: write_comm_pipe_int (uip[i].unit_pipe, 0, 1);
2973: uae_sem_wait (&uip[i].reset_sync_sem);
1.1.1.3 root 2974: }
2975: }
2976: #endif
2977: u = units;
2978: while (u != 0) {
2979: while (u->rootnode.next != &u->rootnode) {
1.1.1.7 root 2980: a_inode *a = u->rootnode.next;
1.1.1.3 root 2981: u->rootnode.next = a->next;
1.1.1.7 root 2982: if (a->dirty && a->parent)
2983: fsdb_dir_writeback (a->parent);
1.1.1.3 root 2984: free (a->nname);
2985: free (a->aname);
2986: free (a);
2987: }
2988: u = u->next;
2989: }
1.1 root 2990: }
2991:
1.1.1.4 root 2992: static uae_u32 filesys_diagentry (void)
1.1 root 2993: {
1.1.1.7 root 2994: uaecptr resaddr = m68k_areg (regs, 2) + 0x10;
2995: uaecptr start = resaddr;
2996: uaecptr residents, tmp;
1.1.1.3 root 2997:
1.1.1.4 root 2998: TRACE (("filesystem: diagentry called\n"));
1.1.1.3 root 2999:
1.1.1.7 root 3000: filesys_configdev = m68k_areg (regs, 3);
1.1.1.3 root 3001:
3002: do_put_mem_long ((uae_u32 *)(filesysory + 0x2100), EXPANSION_explibname);
3003: do_put_mem_long ((uae_u32 *)(filesysory + 0x2104), filesys_configdev);
3004: do_put_mem_long ((uae_u32 *)(filesysory + 0x2108), EXPANSION_doslibname);
1.1.1.4 root 3005: do_put_mem_long ((uae_u32 *)(filesysory + 0x210c), current_mountinfo->num_units);
1.1.1.3 root 3006:
3007: uae_sem_init (&singlethread_int_sem, 0, 1);
1.1 root 3008: if (ROM_hardfile_resid != 0) {
3009: /* Build a struct Resident. This will set up and initialize
3010: * the uae.device */
1.1.1.7 root 3011: put_word (resaddr + 0x0, 0x4AFC);
3012: put_long (resaddr + 0x2, resaddr);
3013: put_long (resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */
3014: put_word (resaddr + 0xA, 0x8101); /* RTF_AUTOINIT|RTF_COLDSTART; Version 1 */
3015: put_word (resaddr + 0xC, 0x0305); /* NT_DEVICE; pri 05 */
3016: put_long (resaddr + 0xE, ROM_hardfile_resname);
3017: put_long (resaddr + 0x12, ROM_hardfile_resid);
3018: put_long (resaddr + 0x16, ROM_hardfile_init); /* calls filesys_init */
1.1 root 3019: }
3020: resaddr += 0x1A;
1.1.1.7 root 3021: tmp = resaddr;
3022:
1.1.1.2 root 3023: /* The good thing about this function is that it always gets called
3024: * when we boot. So we could put all sorts of stuff that wants to be done
1.1.1.7 root 3025: * here.
3026: * We can simply add more Resident structures here. Although the Amiga OS
3027: * only knows about the one at address DiagArea + 0x10, we scan for other
3028: * Resident structures and call InitResident() for them at the end of the
3029: * diag entry. */
3030:
3031: resaddr = scsidev_startup(resaddr);
3032: native2amiga_startup();
3033:
3034: /* scan for Residents and return pointer to array of them */
3035: residents = resaddr;
3036: while (tmp < residents && tmp > start) {
3037: if (get_word (tmp) == 0x4AFC &&
3038: get_long (tmp + 0x2) == tmp) {
3039: put_word (resaddr, 0x227C); /* movea.l #tmp,a1 */
3040: put_long (resaddr + 2, tmp);
3041: put_word (resaddr + 6, 0x7200); /* moveq.l #0,d1 */
3042: put_long (resaddr + 8, 0x4EAEFF9A); /* jsr -$66(a6) ; InitResident */
3043: resaddr += 12;
3044: tmp = get_long (tmp + 0x6);
3045: } else {
3046: tmp++;
3047: }
3048: }
3049: put_word (resaddr, 0x7001); /* moveq.l #1,d0 */
3050: put_word (resaddr + 2, RTS);
1.1 root 3051:
1.1.1.7 root 3052: m68k_areg (regs, 0) = residents;
1.1.1.3 root 3053: return 1;
1.1 root 3054: }
3055:
1.1.1.3 root 3056: /* Remember a pointer AmigaOS gave us so we can later use it to identify
3057: * which unit a given startup message belongs to. */
1.1.1.4 root 3058: static uae_u32 filesys_dev_remember (void)
1.1.1.3 root 3059: {
3060: int unit_no = m68k_dreg (regs, 6);
3061: uaecptr devicenode = m68k_areg (regs, 3);
3062:
1.1.1.4 root 3063: current_mountinfo->ui[unit_no].startup = get_long (devicenode + 28);
1.1.1.3 root 3064: return devicenode;
3065: }
3066:
3067: /* Fill in per-unit fields of a parampacket */
1.1.1.4 root 3068: static uae_u32 filesys_dev_storeinfo (void)
1.1.1.3 root 3069: {
1.1.1.4 root 3070: UnitInfo *uip = current_mountinfo->ui;
1.1.1.3 root 3071: int unit_no = m68k_dreg (regs, 6);
3072: uaecptr parmpacket = m68k_areg (regs, 0);
3073:
1.1.1.4 root 3074: put_long (parmpacket, current_mountinfo->ui[unit_no].devname_amiga);
3075: put_long (parmpacket + 4, is_hardfile (current_mountinfo, unit_no) ? ROM_hardfile_resname : fsdevname);
3076: put_long (parmpacket + 8, uip[unit_no].devno);
1.1.1.3 root 3077: put_long (parmpacket + 12, 0); /* Device flags */
3078: put_long (parmpacket + 16, 16); /* Env. size */
1.1.1.6 root 3079: put_long (parmpacket + 20, uip[unit_no].hf.blocksize >> 2); /* longwords per block */
1.1.1.3 root 3080: put_long (parmpacket + 24, 0); /* unused */
1.1.1.4 root 3081: put_long (parmpacket + 28, uip[unit_no].hf.surfaces); /* heads */
1.1.1.3 root 3082: put_long (parmpacket + 32, 0); /* unused */
1.1.1.4 root 3083: put_long (parmpacket + 36, uip[unit_no].hf.secspertrack); /* sectors per track */
3084: put_long (parmpacket + 40, uip[unit_no].hf.reservedblocks); /* reserved blocks */
1.1.1.3 root 3085: put_long (parmpacket + 44, 0); /* unused */
3086: put_long (parmpacket + 48, 0); /* interleave */
3087: put_long (parmpacket + 52, 0); /* lowCyl */
1.1.1.4 root 3088: put_long (parmpacket + 56, uip[unit_no].hf.nrcyls - 1); /* hiCyl */
1.1.1.6 root 3089: put_long (parmpacket + 60, 50); /* Number of buffers */
1.1.1.3 root 3090: put_long (parmpacket + 64, 0); /* Buffer mem type */
3091: put_long (parmpacket + 68, 0x7FFFFFFF); /* largest transfer */
3092: put_long (parmpacket + 72, ~1); /* addMask (?) */
3093: put_long (parmpacket + 76, (uae_u32)-1); /* bootPri */
3094: put_long (parmpacket + 80, 0x444f5300); /* DOS\0 */
3095: put_long (parmpacket + 84, 0); /* pad */
3096:
1.1.1.4 root 3097: return is_hardfile (current_mountinfo, unit_no);
1.1 root 3098: }
3099:
1.1.1.3 root 3100: void filesys_install (void)
1.1 root 3101: {
3102: int i;
1.1.1.3 root 3103: uaecptr loop;
3104:
1.1.1.4 root 3105: TRACE (("Installing filesystem\n"));
1.1 root 3106:
3107: ROM_filesys_resname = ds("UAEunixfs.resource");
1.1.1.3 root 3108: ROM_filesys_resid = ds("UAE unixfs 0.4");
1.1 root 3109:
1.1.1.4 root 3110: fsdevname = ds ("uae.device"); /* does not really exist */
1.1 root 3111:
3112: ROM_filesys_diagentry = here();
1.1.1.7 root 3113: calltrap (deftrap(filesys_diagentry));
3114: dw(0x4ED0); /* JMP (a0) - jump to code that inits Residents */
1.1.1.3 root 3115:
3116: loop = here ();
3117: /* Special trap for the assembly make_dev routine */
1.1.1.4 root 3118: org (0xF0FF20);
1.1.1.3 root 3119: calltrap (deftrap (filesys_dev_remember));
1.1.1.4 root 3120: dw (RTS);
1.1.1.3 root 3121:
1.1.1.4 root 3122: org (0xF0FF28);
1.1.1.3 root 3123: calltrap (deftrap (filesys_dev_storeinfo));
1.1.1.4 root 3124: dw (RTS);
1.1.1.3 root 3125:
1.1.1.4 root 3126: org (0xF0FF30);
1.1.1.3 root 3127: calltrap (deftrap (filesys_handler));
1.1.1.4 root 3128: dw (RTS);
1.1.1.3 root 3129:
1.1.1.4 root 3130: org (0xF0FF40);
1.1.1.3 root 3131: calltrap (deftrap (startup_handler));
1.1.1.4 root 3132: dw (RTS);
1.1.1.3 root 3133:
1.1.1.4 root 3134: org (0xF0FF50);
1.1.1.3 root 3135: calltrap (deftrap (exter_int_helper));
1.1.1.4 root 3136: dw (RTS);
1.1.1.3 root 3137:
3138: org (loop);
3139: }
3140:
3141: void filesys_install_code (void)
3142: {
1.1 root 3143: align(4);
3144:
1.1.1.3 root 3145: /* The last offset comes from the code itself, look for it near the top. */
3146: EXPANSION_bootcode = here () + 8 + 0x14;
3147: /* Ouch. Make sure this is _always_ a multiple of two bytes. */
1.1.1.7 root 3148: filesys_initcode = here() + 8 + 0x28;
1.1.1.3 root 3149: db(0x00); db(0x00); db(0x00); db(0x10); db(0x00); db(0x00); db(0x00); db(0x00);
1.1.1.7 root 3150: db(0x60); db(0x00); db(0x01); db(0xd4); db(0x00); db(0x00); db(0x01); db(0x3e);
3151: db(0x00); db(0x00); db(0x00); db(0x28); db(0x00); db(0x00); db(0x00); db(0xbc);
3152: db(0x00); db(0x00); db(0x00); db(0x14); db(0x43); db(0xfa); db(0x03); db(0x11);
1.1.1.3 root 3153: db(0x4e); db(0xae); db(0xff); db(0xa0); db(0x20); db(0x40); db(0x20); db(0x28);
3154: db(0x00); db(0x16); db(0x20); db(0x40); db(0x4e); db(0x90); db(0x4e); db(0x75);
1.1.1.7 root 3155: db(0x48); db(0xe7); db(0xff); db(0xfe); db(0x2c); db(0x78); db(0x00); db(0x04);
3156: db(0x2a); db(0x79); db(0x00); db(0xf0); db(0xff); db(0xfc); db(0x43); db(0xfa);
3157: db(0x02); db(0xfb); db(0x70); db(0x24); db(0x7a); db(0x00); db(0x4e); db(0xae);
3158: db(0xfd); db(0xd8); db(0x4a); db(0x80); db(0x66); db(0x0c); db(0x43); db(0xfa);
3159: db(0x02); db(0xeb); db(0x70); db(0x00); db(0x7a); db(0x01); db(0x4e); db(0xae);
3160: db(0xfd); db(0xd8); db(0x28); db(0x40); db(0x70); db(0x58); db(0x72); db(0x01);
3161: db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x26); db(0x40); db(0x7e); db(0x54);
3162: db(0x27); db(0xb5); db(0x78); db(0x00); db(0x78); db(0x00); db(0x59); db(0x87);
3163: db(0x64); db(0xf6); db(0x7c); db(0x00); db(0xbc); db(0xad); db(0x01); db(0x0c);
3164: db(0x64); db(0x14); db(0x20); db(0x4b); db(0x48); db(0xe7); db(0x02); db(0x10);
3165: db(0x7e); db(0x01); db(0x61); db(0x00); db(0x00); db(0xc2); db(0x4c); db(0xdf);
3166: db(0x08); db(0x40); db(0x52); db(0x86); db(0x60); db(0xe6); db(0x2c); db(0x78);
3167: db(0x00); db(0x04); db(0x22); db(0x4c); db(0x4e); db(0xae); db(0xfe); db(0x62);
3168: db(0x61); db(0x00); db(0x00); db(0x7c); db(0x2c); db(0x78); db(0x00); db(0x04);
1.1.1.3 root 3169: db(0x4e); db(0xb9); db(0x00); db(0xf0); db(0xff); db(0x80); db(0x72); db(0x03);
3170: db(0x74); db(0xf6); db(0x20); db(0x7c); db(0x00); db(0x20); db(0x00); db(0x00);
3171: db(0x90); db(0x88); db(0x65); db(0x0a); db(0x67); db(0x08); db(0x78); db(0x00);
3172: db(0x22); db(0x44); db(0x4e); db(0xae); db(0xfd); db(0x96); db(0x4c); db(0xdf);
1.1.1.7 root 3173: db(0x7f); db(0xff); db(0x4e); db(0x75); db(0x48); db(0xe7); db(0x00); db(0x20);
3174: db(0x70); db(0x00); db(0x4e); db(0xb9); db(0x00); db(0xf0); db(0xff); db(0x50);
3175: db(0x4a); db(0x80); db(0x67); db(0x3c); db(0x2c); db(0x78); db(0x00); db(0x04);
3176: db(0x70); db(0x02); db(0x4e); db(0xb9); db(0x00); db(0xf0); db(0xff); db(0x50);
3177: db(0x0c); db(0x80); db(0x00); db(0x00); db(0x00); db(0x01); db(0x6d); db(0x1e);
3178: db(0x6e); db(0x06); db(0x4e); db(0xae); db(0xfe); db(0x92); db(0x60); db(0xe8);
3179: db(0x0c); db(0x80); db(0x00); db(0x00); db(0x00); db(0x02); db(0x6e); db(0x08);
3180: db(0x20); db(0x01); db(0x4e); db(0xae); db(0xfe); db(0xbc); db(0x60); db(0xd8);
3181: db(0x4e); db(0xae); db(0xfe); db(0x86); db(0x60); db(0xd2); db(0x70); db(0x04);
3182: db(0x4e); db(0xb9); db(0x00); db(0xf0); db(0xff); db(0x50); db(0x70); db(0x01);
3183: db(0x4c); db(0xdf); db(0x04); db(0x00); db(0x4e); db(0x75); db(0x2c); db(0x78);
3184: db(0x00); db(0x04); db(0x70); db(0x1a); db(0x22); db(0x3c); db(0x00); db(0x01);
3185: db(0x00); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x22); db(0x40);
3186: db(0x41); db(0xfa); db(0x01); db(0xf6); db(0x23); db(0x48); db(0x00); db(0x0a);
3187: db(0x41); db(0xfa); db(0xff); db(0x92); db(0x23); db(0x48); db(0x00); db(0x0e);
3188: db(0x41); db(0xfa); db(0xff); db(0x8a); db(0x23); db(0x48); db(0x00); db(0x12);
3189: db(0x70); db(0x0d); db(0x4e); db(0xee); db(0xff); db(0x58); db(0x2a); db(0x79);
3190: db(0x00); db(0xf0); db(0xff); db(0xfc); db(0x4e); db(0xb9); db(0x00); db(0xf0);
3191: db(0xff); db(0x28); db(0x26); db(0x00); db(0xc0); db(0x85); db(0x66); db(0x00);
3192: db(0xff); db(0x6a); db(0x2c); db(0x4c); db(0x4e); db(0xae); db(0xff); db(0x70);
3193: db(0x26); db(0x40); db(0x4e); db(0xb9); db(0x00); db(0xf0); db(0xff); db(0x20);
3194: db(0x70); db(0x00); db(0x27); db(0x40); db(0x00); db(0x08); db(0x27); db(0x40);
3195: db(0x00); db(0x10); db(0x27); db(0x40); db(0x00); db(0x20); db(0x4a); db(0x83);
3196: db(0x66); db(0x1c); db(0x27); db(0x7c); db(0x00); db(0x00); db(0x0f); db(0xa0);
3197: db(0x00); db(0x14); db(0x43); db(0xfa); db(0xfe); db(0x80); db(0x20); db(0x09);
3198: db(0xe4); db(0x88); db(0x27); db(0x40); db(0x00); db(0x20); db(0x27); db(0x7c);
3199: db(0xff); db(0xff); db(0xff); db(0xff); db(0x00); db(0x24); db(0x4a); db(0x87);
3200: db(0x67); db(0x36); db(0x2c); db(0x78); db(0x00); db(0x04); db(0x70); db(0x14);
3201: db(0x72); db(0x00); db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x22); db(0x40);
3202: db(0x70); db(0x00); db(0x22); db(0x80); db(0x23); db(0x40); db(0x00); db(0x04);
3203: db(0x33); db(0x40); db(0x00); db(0x0e); db(0x30); db(0x3c); db(0x10); db(0xff);
3204: db(0x90); db(0x06); db(0x33); db(0x40); db(0x00); db(0x08); db(0x23); db(0x6d);
3205: db(0x01); db(0x04); db(0x00); db(0x0a); db(0x23); db(0x4b); db(0x00); db(0x10);
3206: db(0x41); db(0xec); db(0x00); db(0x4a); db(0x4e); db(0xee); db(0xfe); db(0xf2);
3207: db(0x20); db(0x4b); db(0x72); db(0x00); db(0x22); db(0x41); db(0x70); db(0xff);
3208: db(0x2c); db(0x4c); db(0x4e); db(0xee); db(0xff); db(0x6a); db(0x2c); db(0x78);
3209: db(0x00); db(0x04); db(0x70); db(0x00); db(0x22); db(0x40); db(0x4e); db(0xae);
3210: db(0xfe); db(0xda); db(0x20); db(0x40); db(0x4b); db(0xe8); db(0x00); db(0x5c);
3211: db(0x43); db(0xfa); db(0x01); db(0x3d); db(0x70); db(0x00); db(0x4e); db(0xae);
3212: db(0xfd); db(0xd8); db(0x24); db(0x40); db(0x20); db(0x3c); db(0x00); db(0x00);
3213: db(0x00); db(0x9d); db(0x22); db(0x3c); db(0x00); db(0x01); db(0x00); db(0x01);
3214: db(0x4e); db(0xae); db(0xff); db(0x3a); db(0x26); db(0x40); db(0x7c); db(0x00);
3215: db(0x26); db(0x86); db(0x27); db(0x46); db(0x00); db(0x04); db(0x27); db(0x46);
3216: db(0x00); db(0x08); db(0x7a); db(0x00); db(0x20); db(0x4d); db(0x4e); db(0xae);
3217: db(0xfe); db(0x80); db(0x20); db(0x4d); db(0x4e); db(0xae); db(0xfe); db(0x8c);
3218: db(0x28); db(0x40); db(0x26); db(0x2c); db(0x00); db(0x0a); db(0x70); db(0x00);
3219: db(0x4e); db(0xb9); db(0x00); db(0xf0); db(0xff); db(0x40); db(0x60); db(0x76);
1.1.1.3 root 3220: db(0x20); db(0x4d); db(0x4e); db(0xae); db(0xfe); db(0x80); db(0x20); db(0x4d);
3221: db(0x4e); db(0xae); db(0xfe); db(0x8c); db(0x28); db(0x40); db(0x26); db(0x2c);
1.1.1.7 root 3222: db(0x00); db(0x0a); db(0x66); db(0x38); db(0x70); db(0x01); db(0x4e); db(0xb9);
3223: db(0x00); db(0xf0); db(0xff); db(0x50); db(0x45); db(0xeb); db(0x00); db(0x04);
3224: db(0x20); db(0x52); db(0x20); db(0x08); db(0x67); db(0xda); db(0x22); db(0x50);
3225: db(0x20); db(0x40); db(0x20); db(0x28); db(0x00); db(0x04); db(0x6a); db(0x16);
3226: db(0x48); db(0xe7); db(0x00); db(0xc0); db(0x28); db(0x68); db(0x00); db(0x0a);
3227: db(0x61); db(0x42); db(0x53); db(0x85); db(0x4c); db(0xdf); db(0x03); db(0x00);
3228: db(0x24); db(0x89); db(0x20); db(0x49); db(0x60); db(0xdc); db(0x24); db(0x48);
3229: db(0x20); db(0x49); db(0x60); db(0xd6); db(0x0c); db(0x85); db(0x00); db(0x00);
3230: db(0x00); db(0x14); db(0x65); db(0x00); db(0x00); db(0x0a); db(0x70); db(0x01);
3231: db(0x29); db(0x40); db(0x00); db(0x04); db(0x60); db(0x0e); db(0x61); db(0x2a);
3232: db(0x4e); db(0xb9); db(0x00); db(0xf0); db(0xff); db(0x30); db(0x4a); db(0x80);
3233: db(0x67); db(0x0c); db(0x52); db(0x85); db(0x28); db(0xab); db(0x00); db(0x04);
3234: db(0x27); db(0x4c); db(0x00); db(0x04); db(0x60); db(0x8a); db(0x28); db(0x43);
3235: db(0x61); db(0x02); db(0x60); db(0x84); db(0x22); db(0x54); db(0x20); db(0x6c);
3236: db(0x00); db(0x04); db(0x29); db(0x4d); db(0x00); db(0x04); db(0x4e); db(0xee);
3237: db(0xfe); db(0x92); db(0x2f); db(0x05); db(0x7a); db(0xfc); db(0x24); db(0x53);
3238: db(0x2e); db(0x0a); db(0x22); db(0x0a); db(0x67); db(0x00); db(0x00); db(0x0c);
1.1.1.3 root 3239: db(0x52); db(0x85); db(0x67); db(0x1e); db(0x22); db(0x4a); db(0x24); db(0x52);
1.1.1.7 root 3240: db(0x60); db(0xf0); db(0x52); db(0x85); db(0x67); db(0x3c); db(0x24); db(0x47);
1.1.1.3 root 3241: db(0x70); db(0x18); db(0x72); db(0x01); db(0x4e); db(0xae); db(0xff); db(0x3a);
3242: db(0x52); db(0x46); db(0x24); db(0x40); db(0x24); db(0x87); db(0x2e); db(0x0a);
3243: db(0x60); db(0xe8); db(0x20); db(0x12); db(0x67); db(0x24); db(0x20); db(0x40);
3244: db(0x20); db(0x10); db(0x67); db(0x1e); db(0x20); db(0x40); db(0x20); db(0x10);
3245: db(0x67); db(0x18); db(0x70); db(0x00); db(0x22); db(0x80); db(0x22); db(0x4a);
3246: db(0x24); db(0x51); db(0x70); db(0x18); db(0x4e); db(0xae); db(0xff); db(0x2e);
1.1.1.7 root 3247: db(0x06); db(0x86); db(0x00); db(0x01); db(0x00); db(0x00); db(0x20); db(0x0a);
1.1.1.3 root 3248: db(0x66); db(0xec); db(0x26); db(0x87); db(0x2a); db(0x1f); db(0x4e); db(0x75);
3249: db(0x55); db(0x41); db(0x45); db(0x20); db(0x66); db(0x69); db(0x6c); db(0x65);
3250: db(0x73); db(0x79); db(0x73); db(0x74); db(0x65); db(0x6d); db(0x00); db(0x64);
3251: db(0x6f); db(0x73); db(0x2e); db(0x6c); db(0x69); db(0x62); db(0x72); db(0x61);
3252: db(0x72); db(0x79); db(0x00); db(0x65); db(0x78); db(0x70); db(0x61); db(0x6e);
3253: db(0x73); db(0x69); db(0x6f); db(0x6e); db(0x2e); db(0x6c); db(0x69); db(0x62);
1.1.1.7 root 3254: db(0x72); db(0x61); db(0x72); db(0x79); db(0x00); db(0x00); db(0x00); db(0x00);
3255: db(0x00); db(0x00); db(0x03); db(0xf2);
1.1 root 3256: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.