Skip to contentSkip to conversation

Add uselib syscall

PATCH In review Riku Voipio 3 participants 3 messages Sep 19, 2008 – Sep 21, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add uselib syscall

---
 linux-user/syscall.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
linux-user/syscall.c +10 -1
index 6b38d8a..8b8262a 100644
@@ -282,6 +282,7 @@ extern int flock(int, int);
 extern int setfsuid(int);
 extern int setfsgid(int);
 extern int setgroups(int, gid_t *);
+extern int uselib(const char*);
 
 #define ERRNO_TABLE_SIZE 1200
 
@@ -4313,7 +4314,15 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
 #endif
 #ifdef TARGET_NR_uselib
     case TARGET_NR_uselib:
-        goto unimplemented;
+        {
+            if(!(p = lock_user_string(arg1))) {
+                ret = -TARGET_EFAULT;
+                goto efault;
+            }
+            ret = get_errno(uselib(path(p)));
+            unlock_user(p, arg1, 0);
+        }
+        break;
 #endif
 #ifdef TARGET_NR_swapon
     case TARGET_NR_swapon:
Signature · 5 lines
1.5.6.5


-- 
"rm -rf" only sounds scary if you don't have backups
#1 lore raw
Quoted 25 lines · Riku Voipio
---
 linux-user/syscall.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
linux-user/syscall.c +3 -1
index 6b38d8a..8b8262a 100644
@@ -282,6 +282,7 @@ extern int flock(int, int);
 extern int setfsuid(int);
 extern int setfsgid(int);
 extern int setgroups(int, gid_t *);
+extern int uselib(const char*);
 
 #define ERRNO_TABLE_SIZE 1200
 
@@ -4313,7 +4314,15 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
 #endif
 #ifdef TARGET_NR_uselib
     case TARGET_NR_uselib:
-        goto unimplemented;
+        {
+            if(!(p = lock_user_string(arg1))) {

linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 4328

Quoted 10 lines
linux-user/syscall.c +7 -0
+                ret = -TARGET_EFAULT;
+                goto efault;
+            }
+            ret = get_errno(uselib(path(p)));
+            unlock_user(p, arg1, 0);
+        }
+        break;
 #endif
 #ifdef TARGET_NR_swapon
     case TARGET_NR_swapon:

Looks good for me. Added to my patchset.

Quoted 8 lines
Signature · 5 lines
1.5.6.5


-- 
"rm -rf" only sounds scary if you don't have backups
Signature · 3 lines
Regards,  Kirill A. Shutemov
 + Belarus, Minsk
 + ALT Linux Team, http://www.altlinux.com/
#2 lore raw
In reply to Riku Voipio

linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 4325

Quoted 11 lines

case TARGET_NR_uselib:

linux-user/syscall.c +9 -1
-        goto unimplemented;
+        {
+            if(!(p = lock_user_string(arg1))) {
+                ret = -TARGET_EFAULT;
+                goto efault;
+            }
+            ret = get_errno(uselib(path(p)));
+            unlock_user(p, arg1, 0);
+        }
+        break;

I'm pretty sure this is wrong. The last thing we want to be doing is loading a host library.

Paul