linux_misc.c (346816) | linux_misc.c (346832) |
---|---|
1/*- 2 * Copyright (c) 2002 Doug Rabson 3 * Copyright (c) 1994-1995 S��ren Schmidt 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 14 unchanged lines hidden (view full) --- 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2002 Doug Rabson 3 * Copyright (c) 1994-1995 S��ren Schmidt 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 14 unchanged lines hidden (view full) --- 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: stable/11/sys/compat/linux/linux_misc.c 346816 2019-04-28 13:19:28Z dchagin $"); | 31__FBSDID("$FreeBSD: stable/11/sys/compat/linux/linux_misc.c 346832 2019-04-28 14:03:32Z dchagin $"); |
32 33#include "opt_compat.h" 34 35#include <sys/param.h> 36#include <sys/blist.h> 37#include <sys/fcntl.h> 38#if defined(__i386__) 39#include <sys/imgact_aout.h> --- 144 unchanged lines hidden (view full) --- 184 /* The following are only present in newer Linux kernels. */ 185 sysinfo.totalbig = 0; 186 sysinfo.freebig = 0; 187 sysinfo.mem_unit = 1; 188 189 return (copyout(&sysinfo, args->info, sizeof(sysinfo))); 190} 191 | 32 33#include "opt_compat.h" 34 35#include <sys/param.h> 36#include <sys/blist.h> 37#include <sys/fcntl.h> 38#if defined(__i386__) 39#include <sys/imgact_aout.h> --- 144 unchanged lines hidden (view full) --- 184 /* The following are only present in newer Linux kernels. */ 185 sysinfo.totalbig = 0; 186 sysinfo.freebig = 0; 187 sysinfo.mem_unit = 1; 188 189 return (copyout(&sysinfo, args->info, sizeof(sysinfo))); 190} 191 |
192#ifdef LINUX_LEGACY_SYSCALLS |
|
192int 193linux_alarm(struct thread *td, struct linux_alarm_args *args) 194{ 195 struct itimerval it, old_it; 196 u_int secs; 197 int error; 198 199#ifdef DEBUG --- 18 unchanged lines hidden (view full) --- 218 KASSERT(error == 0, ("kern_setitimer returns %d", error)); 219 220 if ((old_it.it_value.tv_sec == 0 && old_it.it_value.tv_usec > 0) || 221 old_it.it_value.tv_usec >= 500000) 222 old_it.it_value.tv_sec++; 223 td->td_retval[0] = old_it.it_value.tv_sec; 224 return (0); 225} | 193int 194linux_alarm(struct thread *td, struct linux_alarm_args *args) 195{ 196 struct itimerval it, old_it; 197 u_int secs; 198 int error; 199 200#ifdef DEBUG --- 18 unchanged lines hidden (view full) --- 219 KASSERT(error == 0, ("kern_setitimer returns %d", error)); 220 221 if ((old_it.it_value.tv_sec == 0 && old_it.it_value.tv_usec > 0) || 222 old_it.it_value.tv_usec >= 500000) 223 old_it.it_value.tv_sec++; 224 td->td_retval[0] = old_it.it_value.tv_sec; 225 return (0); 226} |
227#endif |
|
226 227int 228linux_brk(struct thread *td, struct linux_brk_args *args) 229{ 230 struct vmspace *vm = td->td_proc->p_vmspace; 231 vm_offset_t new, old; 232 struct obreak_args /* { 233 char * nsize; --- 253 unchanged lines hidden (view full) --- 487 if (a_out) 488 kmap_free_wakeup(exec_map, (vm_offset_t)a_out, PAGE_SIZE); 489 490 return (error); 491} 492 493#endif /* __i386__ */ 494 | 228 229int 230linux_brk(struct thread *td, struct linux_brk_args *args) 231{ 232 struct vmspace *vm = td->td_proc->p_vmspace; 233 vm_offset_t new, old; 234 struct obreak_args /* { 235 char * nsize; --- 253 unchanged lines hidden (view full) --- 489 if (a_out) 490 kmap_free_wakeup(exec_map, (vm_offset_t)a_out, PAGE_SIZE); 491 492 return (error); 493} 494 495#endif /* __i386__ */ 496 |
497#ifdef LINUX_LEGACY_SYSCALLS |
|
495int 496linux_select(struct thread *td, struct linux_select_args *args) 497{ 498 l_timeval ltv; 499 struct timeval tv0, tv1, utv, *tvp; 500 int error; 501 502#ifdef DEBUG --- 75 unchanged lines hidden (view full) --- 578 579select_out: 580#ifdef DEBUG 581 if (ldebug(select)) 582 printf(LMSG("select_out -> %d"), error); 583#endif 584 return (error); 585} | 498int 499linux_select(struct thread *td, struct linux_select_args *args) 500{ 501 l_timeval ltv; 502 struct timeval tv0, tv1, utv, *tvp; 503 int error; 504 505#ifdef DEBUG --- 75 unchanged lines hidden (view full) --- 581 582select_out: 583#ifdef DEBUG 584 if (ldebug(select)) 585 printf(LMSG("select_out -> %d"), error); 586#endif 587 return (error); 588} |
589#endif |
|
586 587int 588linux_mremap(struct thread *td, struct linux_mremap_args *args) 589{ 590 uintptr_t addr; 591 size_t len; 592 int error = 0; 593 --- 45 unchanged lines hidden (view full) --- 639int 640linux_msync(struct thread *td, struct linux_msync_args *args) 641{ 642 643 return (kern_msync(td, args->addr, args->len, 644 args->fl & ~LINUX_MS_SYNC)); 645} 646 | 590 591int 592linux_mremap(struct thread *td, struct linux_mremap_args *args) 593{ 594 uintptr_t addr; 595 size_t len; 596 int error = 0; 597 --- 45 unchanged lines hidden (view full) --- 643int 644linux_msync(struct thread *td, struct linux_msync_args *args) 645{ 646 647 return (kern_msync(td, args->addr, args->len, 648 args->fl & ~LINUX_MS_SYNC)); 649} 650 |
651#ifdef LINUX_LEGACY_SYSCALLS |
|
647int 648linux_time(struct thread *td, struct linux_time_args *args) 649{ 650 struct timeval tv; 651 l_time_t tm; 652 int error; 653 654#ifdef DEBUG 655 if (ldebug(time)) 656 printf(ARGS(time, "*")); 657#endif 658 659 microtime(&tv); 660 tm = tv.tv_sec; 661 if (args->tm && (error = copyout(&tm, args->tm, sizeof(tm)))) 662 return (error); 663 td->td_retval[0] = tm; 664 return (0); 665} | 652int 653linux_time(struct thread *td, struct linux_time_args *args) 654{ 655 struct timeval tv; 656 l_time_t tm; 657 int error; 658 659#ifdef DEBUG 660 if (ldebug(time)) 661 printf(ARGS(time, "*")); 662#endif 663 664 microtime(&tv); 665 tm = tv.tv_sec; 666 if (args->tm && (error = copyout(&tm, args->tm, sizeof(tm)))) 667 return (error); 668 td->td_retval[0] = tm; 669 return (0); 670} |
671#endif |
|
666 667struct l_times_argv { 668 l_clock_t tms_utime; 669 l_clock_t tms_stime; 670 l_clock_t tms_cutime; 671 l_clock_t tms_cstime; 672}; 673 --- 80 unchanged lines hidden (view full) --- 754 return (copyout(&utsname, args->buf, sizeof(utsname))); 755} 756 757struct l_utimbuf { 758 l_time_t l_actime; 759 l_time_t l_modtime; 760}; 761 | 672 673struct l_times_argv { 674 l_clock_t tms_utime; 675 l_clock_t tms_stime; 676 l_clock_t tms_cutime; 677 l_clock_t tms_cstime; 678}; 679 --- 80 unchanged lines hidden (view full) --- 760 return (copyout(&utsname, args->buf, sizeof(utsname))); 761} 762 763struct l_utimbuf { 764 l_time_t l_actime; 765 l_time_t l_modtime; 766}; 767 |
768#ifdef LINUX_LEGACY_SYSCALLS |
|
762int 763linux_utime(struct thread *td, struct linux_utime_args *args) 764{ 765 struct timeval tv[2], *tvp; 766 struct l_utimbuf lut; 767 char *fname; 768 int error; 769 --- 17 unchanged lines hidden (view full) --- 787 } else 788 tvp = NULL; 789 790 error = kern_utimesat(td, AT_FDCWD, fname, UIO_SYSSPACE, tvp, 791 UIO_SYSSPACE); 792 LFREEPATH(fname); 793 return (error); 794} | 769int 770linux_utime(struct thread *td, struct linux_utime_args *args) 771{ 772 struct timeval tv[2], *tvp; 773 struct l_utimbuf lut; 774 char *fname; 775 int error; 776 --- 17 unchanged lines hidden (view full) --- 794 } else 795 tvp = NULL; 796 797 error = kern_utimesat(td, AT_FDCWD, fname, UIO_SYSSPACE, tvp, 798 UIO_SYSSPACE); 799 LFREEPATH(fname); 800 return (error); 801} |
802#endif |
|
795 | 803 |
804#ifdef LINUX_LEGACY_SYSCALLS |
|
796int 797linux_utimes(struct thread *td, struct linux_utimes_args *args) 798{ 799 l_timeval ltv[2]; 800 struct timeval tv[2], *tvp = NULL; 801 char *fname; 802 int error; 803 --- 16 unchanged lines hidden (view full) --- 820 tvp = tv; 821 } 822 823 error = kern_utimesat(td, AT_FDCWD, fname, UIO_SYSSPACE, 824 tvp, UIO_SYSSPACE); 825 LFREEPATH(fname); 826 return (error); 827} | 805int 806linux_utimes(struct thread *td, struct linux_utimes_args *args) 807{ 808 l_timeval ltv[2]; 809 struct timeval tv[2], *tvp = NULL; 810 char *fname; 811 int error; 812 --- 16 unchanged lines hidden (view full) --- 829 tvp = tv; 830 } 831 832 error = kern_utimesat(td, AT_FDCWD, fname, UIO_SYSSPACE, 833 tvp, UIO_SYSSPACE); 834 LFREEPATH(fname); 835 return (error); 836} |
837#endif |
|
828 829static int 830linux_utimensat_nsec_valid(l_long nsec) 831{ 832 833 if (nsec == LINUX_UTIME_OMIT || nsec == LINUX_UTIME_NOW) 834 return (0); 835 if (nsec >= 0 && nsec <= 999999999) --- 78 unchanged lines hidden (view full) --- 914 error = kern_utimensat(td, dfd, path, UIO_SYSSPACE, timesp, 915 UIO_SYSSPACE, flags); 916 LFREEPATH(path); 917 } 918 919 return (error); 920} 921 | 838 839static int 840linux_utimensat_nsec_valid(l_long nsec) 841{ 842 843 if (nsec == LINUX_UTIME_OMIT || nsec == LINUX_UTIME_NOW) 844 return (0); 845 if (nsec >= 0 && nsec <= 999999999) --- 78 unchanged lines hidden (view full) --- 924 error = kern_utimensat(td, dfd, path, UIO_SYSSPACE, timesp, 925 UIO_SYSSPACE, flags); 926 LFREEPATH(path); 927 } 928 929 return (error); 930} 931 |
932#ifdef LINUX_LEGACY_SYSCALLS |
|
922int 923linux_futimesat(struct thread *td, struct linux_futimesat_args *args) 924{ 925 l_timeval ltv[2]; 926 struct timeval tv[2], *tvp = NULL; 927 char *fname; 928 int error, dfd; 929 --- 16 unchanged lines hidden (view full) --- 946 tv[1].tv_usec = ltv[1].tv_usec; 947 tvp = tv; 948 } 949 950 error = kern_utimesat(td, dfd, fname, UIO_SYSSPACE, tvp, UIO_SYSSPACE); 951 LFREEPATH(fname); 952 return (error); 953} | 933int 934linux_futimesat(struct thread *td, struct linux_futimesat_args *args) 935{ 936 l_timeval ltv[2]; 937 struct timeval tv[2], *tvp = NULL; 938 char *fname; 939 int error, dfd; 940 --- 16 unchanged lines hidden (view full) --- 957 tv[1].tv_usec = ltv[1].tv_usec; 958 tvp = tv; 959 } 960 961 error = kern_utimesat(td, dfd, fname, UIO_SYSSPACE, tvp, UIO_SYSSPACE); 962 LFREEPATH(fname); 963 return (error); 964} |
965#endif |
|
954 955int 956linux_common_wait(struct thread *td, int pid, int *status, 957 int options, struct rusage *ru) 958{ 959 int error, tmpstat; 960 961 error = kern_wait(td, pid, &tmpstat, options, ru); --- 124 unchanged lines hidden (view full) --- 1086 } 1087 error = copyout(&lsi, args->info, sizeof(lsi)); 1088 } 1089 td->td_retval[0] = 0; 1090 1091 return (error); 1092} 1093 | 966 967int 968linux_common_wait(struct thread *td, int pid, int *status, 969 int options, struct rusage *ru) 970{ 971 int error, tmpstat; 972 973 error = kern_wait(td, pid, &tmpstat, options, ru); --- 124 unchanged lines hidden (view full) --- 1098 } 1099 error = copyout(&lsi, args->info, sizeof(lsi)); 1100 } 1101 td->td_retval[0] = 0; 1102 1103 return (error); 1104} 1105 |
1106#ifdef LINUX_LEGACY_SYSCALLS |
|
1094int 1095linux_mknod(struct thread *td, struct linux_mknod_args *args) 1096{ 1097 char *path; 1098 int error; 1099 1100 LCONVPATHCREAT(td, args->path, &path); 1101 --- 32 unchanged lines hidden (view full) --- 1134 1135 default: 1136 error = EINVAL; 1137 break; 1138 } 1139 LFREEPATH(path); 1140 return (error); 1141} | 1107int 1108linux_mknod(struct thread *td, struct linux_mknod_args *args) 1109{ 1110 char *path; 1111 int error; 1112 1113 LCONVPATHCREAT(td, args->path, &path); 1114 --- 32 unchanged lines hidden (view full) --- 1147 1148 default: 1149 error = EINVAL; 1150 break; 1151 } 1152 LFREEPATH(path); 1153 return (error); 1154} |
1155#endif |
|
1142 1143int 1144linux_mknodat(struct thread *td, struct linux_mknodat_args *args) 1145{ 1146 char *path; 1147 int error, dfd; 1148 1149 dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; --- 1400 unchanged lines hidden --- | 1156 1157int 1158linux_mknodat(struct thread *td, struct linux_mknodat_args *args) 1159{ 1160 char *path; 1161 int error, dfd; 1162 1163 dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; --- 1400 unchanged lines hidden --- |