--- uae/src/filesys.c 2018/04/24 16:47:32 1.1.1.7 +++ uae/src/filesys.c 2018/04/24 16:48:50 1.1.1.8 @@ -1864,6 +1864,10 @@ action_fh_from_lock (Unit *unit, dpacket : (mode & A_FIBF_WRITE) == 0 ? O_RDONLY : O_RDWR)); + /* the files on CD really can have the write-bit set. */ + if (unit->ui.readonly) + openmode = O_RDONLY; + fd = open (aino->nname, openmode | O_BINARY, 0777); if (fd < 0) { @@ -2178,7 +2182,7 @@ action_change_mode (Unit *unit, dpacket /* will be EXCLUSIVE_LOCK/SHARED_LOCK if CHANGE_LOCK, * or MODE_OLDFILE/MODE_NEWFILE/MODE_READWRITE if CHANGE_FH */ long mode = GET_PCK_ARG3 (packet); - uaecptr fh; + unsigned long uniq; a_inode *a = NULL, *olda = NULL; uae_u32 err = 0; TRACE(("ACTION_CHANGE_MODE(0x%lx,%d,%d)\n",object,type,mode)); @@ -2195,8 +2199,20 @@ action_change_mode (Unit *unit, dpacket CHANGE_FH? */ if (type == CHANGE_FH) mode = (mode == 1006 ? -1 : -2); - fh = (type == CHANGE_LOCK ? get_long (object + 4) : object); - a = lookup_aino (unit, get_long (object + 4)); + + if (type == CHANGE_LOCK) + uniq = get_long (object + 4); + else { + Key *k = lookup_key (unit, object); + if (!k) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_FOUND); + return; + } + uniq = k->aino->uniq; + } + a = lookup_aino (unit, uniq); + if (! a) err = ERROR_INVALID_LOCK; else { @@ -2224,9 +2240,9 @@ action_change_mode (Unit *unit, dpacket } static void -action_parent_common (Unit *unit, dpacket packet, uaecptr fh) +action_parent_common (Unit *unit, dpacket packet, unsigned long uniq) { - a_inode *olda = lookup_aino (unit, fh); + a_inode *olda = lookup_aino (unit, uniq); if (olda == 0) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_INVALID_LOCK); @@ -2251,15 +2267,13 @@ action_parent_common (Unit *unit, dpacke static void action_parent_fh (Unit *unit, dpacket packet) { - uaecptr fh = GET_PCK_ARG1 (packet) << 2; - TRACE(("ACTION_PARENT_FH(0x%lx)\n",fh)); - - if (! fh) { + Key *k = lookup_key (unit, GET_PCK_ARG1 (packet)); + if (!k) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_FOUND); return; } - action_parent_common (unit, packet, fh); + action_parent_common (unit, packet, k->aino->uniq); } static void