+static abi_long do_bsd_readlink(CPUArchState *env, abi_long arg1,
+ abi_long arg2, abi_long arg3)
+{
+ abi_long ret;
+ void *p1, *p2;
+
+ LOCK_PATH(p1, arg1);
+ p2 = lock_user(VERIFY_WRITE, arg2, arg3, 0);
+ if (p2 == NULL) {
+ UNLOCK_PATH(p1, arg1);
+ return -TARGET_EFAULT;
+ }
+#ifdef __FreeBSD__
+ if (strcmp(p1, "/proc/curproc/file") == 0) {
+ CPUState *cpu = env_cpu(env);
+ TaskState *ts = (TaskState *)cpu->opaque;
+ strncpy(p2, ts->bprm->fullpath, arg3);
+ ret = MIN((abi_long)strlen(ts->bprm->fullpath), arg3);
+ } else
+#endif