File wolfi.patch of Package fs-uae

diff --git a/src/od-fs/fsdb_host.cpp b/src/od-fs/fsdb_host.cpp
index a37c4584..2aadddd2 100644
--- a/src/od-fs/fsdb_host.cpp
+++ b/src/od-fs/fsdb_host.cpp
@@ -419,8 +419,11 @@ static int fsdb_get_file_info(const char *nname, fsdb_file_info *info)
             write_log("WARNING: fsdb_get_file_info - could not open "
                       "meta file for reading\n");
         }
-        else if (g_fsdb_debug) {
-            write_log("fsdb_get_file_info - no .uaem file\n");
+        else {
+            if (g_fsdb_debug) {
+                write_log("fsdb_get_file_info - no .uaem file\n");
+            }
+            error = 1; // signal caller that no .uaem file exists
         }
     }
     else {
@@ -552,6 +555,21 @@ static int fsdb_get_file_info(const char *nname, fsdb_file_info *info)
         info->mode |= A_FIBF_DELETE;
         if (! uae_deterministic_mode()) {
             // FIXME: remove WRITE and DELETE if file is not writable
+            struct fs_stat buf;
+            if (fs_stat(nname, &buf) != 0) {
+                if (g_fsdb_debug) {
+                    write_log("- error stating %s (%d)\n", nname, errno);
+                }
+            }
+            if (!(buf.mode & S_IRUSR))
+                info->mode ^= A_FIBF_READ;
+            if (!(buf.mode & S_IWUSR))
+            {
+                info->mode ^= A_FIBF_WRITE;
+//                info->mode ^= A_FIBF_DELETE; // DELETE is actually possible also for read-only files, as it only needs write access to the directory, not the file itself
+            }
+            if (!(buf.mode & S_IXUSR))
+                info->mode ^= A_FIBF_EXECUTE; // might cause problems because data files are usually non-executable on Linux; e-uae does use the x flag for this however
         }
     }
 
@@ -630,15 +648,6 @@ int fsdb_set_file_info(const char *nname, fsdb_file_info *info)
             need_metadata_file |= WF_ARCHIVE;
         }
         /* check for bits NOT set */
-        if ((g_uaem_flags & WF_READ) && !(info->mode & A_FIBF_READ)) {
-            need_metadata_file |= WF_READ;
-        }
-        if ((g_uaem_flags & WF_WRITE) && !(info->mode & A_FIBF_WRITE)) {
-            need_metadata_file |= WF_WRITE;
-        }
-        if ((g_uaem_flags & WF_EXECUTE) && !(info->mode & A_FIBF_EXECUTE)) {
-            need_metadata_file |= WF_EXECUTE;
-        }
         if ((g_uaem_flags & WF_DELETE) && !(info->mode & A_FIBF_DELETE)) {
             need_metadata_file |= WF_DELETE;
         }
@@ -644,6 +659,39 @@ int fsdb_set_file_info(const char *nname, fsdb_file_info *info)
         }
     }
 
+// probably better to add a function to fsemu, that allows to set the permissions on the host file
+    struct fs_stat buf;
+    int res = fs_stat(nname, &buf);
+    if (res == 0)
+    {
+        if (info->mode & A_FIBF_READ)
+            buf.mode |= S_IRUSR;
+        else if (buf.mode & S_IRUSR)
+            buf.mode ^= S_IRUSR;
+        if (info->mode & A_FIBF_WRITE)
+            buf.mode |= S_IWUSR;
+        else if (buf.mode & S_IWUSR)
+            buf.mode ^= S_IWUSR;
+        if (info->mode & A_FIBF_EXECUTE)
+            buf.mode |= S_IXUSR;
+        else if (buf.mode & S_IXUSR)
+            buf.mode ^= S_IXUSR;
+        res = chmod(nname, buf.mode);
+    }
+    if (res != 0)
+    {
+        // something failed so try to write the flags to .uaem instead
+        if ((g_uaem_flags & WF_READ) && !(info->mode & A_FIBF_READ)) {
+            need_metadata_file |= WF_READ;
+        }
+        if ((g_uaem_flags & WF_WRITE) && !(info->mode & A_FIBF_WRITE)) {
+            need_metadata_file |= WF_WRITE;
+        }
+        if ((g_uaem_flags & WF_EXECUTE) && !(info->mode & A_FIBF_EXECUTE)) {
+            need_metadata_file |= WF_EXECUTE;
+        }
+    }
+
     struct mytimeval mtv;
     amiga_to_timeval(&mtv, info->days, info->mins, info->ticks, 50);
     mtv.tv_sec -= fs_get_local_time_offset(mtv.tv_sec);
@@ -888,12 +936,13 @@ int fsdb_fill_file_attrs(a_inode *base, a_inode *aino)
         write_log("fsdb_fill_file_attrs nname is %s\n", aino->nname);
     }
     fsdb_file_info info;
-    fsdb_get_file_info(aino->nname, &info);
+    int err=fsdb_get_file_info(aino->nname, &info);
     if (!info.type) {
         // file does not exist
         return 0;
     }
     aino->dir = info.type == 2;
+    if (err) return 1; // .uaem file could not be opened/read so don't modify mode/comment
     aino->amigaos_mode = filesys_parse_mask(info.mode);
     if (info.comment) {
         aino->comment = nname_to_aname(info.comment, 1);
diff --git a/src/fsdb.cpp b/src/fsdb.cpp
index a37c4584..2aadddd2 100644
--- a/src/fsdb.cpp
+++ b/src/fsdb.cpp
@@ -176,8 +176,8 @@ static a_inode *aino_from_buf (a_inode *base, uae_u8 *buf, long off)
 	xfree (s);
 	buf += 257;
 	aino->comment = *buf != '\0' ? au ((char*)buf) : 0;
-	fsdb_fill_file_attrs (base, aino);
 	aino->amigaos_mode = mode;
+	fsdb_fill_file_attrs (base, aino);
 	aino->has_dbentry = 1;
 	aino->dirty = 0;
 	aino->db_offset = off;
diff --git a/share/fs-uae/input/default_keyboard.conf b/share/fs-uae/input/default_keyboard.conf
index a37c4584..2aadddd2 100644
--- a/share/fs-uae/input/default_keyboard.conf
+++ b/share/fs-uae/input/default_keyboard.conf
@@ -9,6 +9,7 @@
 key_down = down
 key_rctrl = 1
 key_ralt = 1
+key_rshift = 2
 
 [cd32]
 key_left = left
openSUSE Build Service is sponsored by