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