Changeset 1910
- Timestamp:
- Apr 25, 2005, 5:58:57 AM (20 years ago)
- Location:
- trunk/src/emx
- Files:
-
- 7 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/ChangeLog.LIBC
-
Property cvs2svn:cvs-rev
changed from
1.32
to1.33
r1909 r1910 1 1 /* $Id$ */ 2 3 2005-04-24: knut st. osmundsen <bird-gccos2-spam@anduin.net> 4 - libc: 5 o Fixed bug in getfsstate(). (df from coreutils works now!) 6 o Implemented process priority management. Added nice(), setpriority() 7 and getpriority() in the process. 8 o Added process enumeration and access function to sharedpm. 2 9 3 10 2005-04-23: knut st. osmundsen <bird-gccos2-spam@anduin.net> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/InnoTekLIBC/backend.h
-
Property cvs2svn:cvs-rev
changed from
1.18
to1.19
r1909 r1910 789 789 int __libc_Back_processSetGidAll(gid_t rgid, gid_t egid, gid_t svgid); 790 790 791 /** 792 * Gets the most favourable priority of a process, group of processes 793 * or all processed owned by a user. 794 * 795 * @returns 0 on success. 796 * @returns Negative error code (errno.h) on failure. 797 * @param iWhich PRIO_PROCESS, PRIO_PGRP, or PRIO_USER. 798 * @param idWho Id of the type specified by iWhich. 0 means the current process/pgrp/user. 799 * @param piPrio Where to store the priority. 800 */ 801 int __libc_Back_processGetPriority(int iWhich, id_t idWho, int *piPrio); 802 803 /** 804 * Sets the priority of a process, a group of processes 805 * or all processed owned by a user. 806 * 807 * @returns 0 on success. 808 * @returns Negative error code (errno.h) on failure. 809 * @param iWhich PRIO_PROCESS, PRIO_PGRP, or PRIO_USER. 810 * @param idWho Id of the type specified by iWhich. 0 means the current process/pgrp/user. 811 * @param iPrio The new priority. 812 */ 813 int __libc_Back_processSetPriority(int iWhich, id_t idWho, int iPrio); 814 791 815 792 816 /** @} */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/InnoTekLIBC/sharedpm.h
-
Property cvs2svn:cvs-rev
changed from
1.19
to1.20
r1909 r1910 316 316 /** User & Group 317 317 * @{ */ 318 /** 28 - User id . */318 /** 28 - User id (also called Real User id). */ 319 319 uid_t uid; 320 320 /** 32 - Effective user id. */ … … 322 322 /** 36 - Saved user id. */ 323 323 uid_t svuid; 324 /** 40 - Group id . */324 /** 40 - Group id (also called Real Group id). */ 325 325 gid_t gid; 326 326 /** 44 - Effecive group id. */ … … 392 392 /** @} */ 393 393 394 /** 180 - Per Process Sockets Reference Counters. */394 /** 180 - Per Process Sockets Reference Counters. (Data is process local.) */ 395 395 uint16_t *pacTcpipRefs; 396 397 /** 184 - Reserved pool pointer field with default value 0. */ 398 unsigned auReserved[56 - 46]; 399 400 401 /** 224 - Number of possible pointers to shared memory starting at pvInherit. 396 /** 184 - The Process priority (unix). */ 397 int iNice; 398 /** 188 - Reserved fields with default value 0. */ 399 unsigned auReserved[56 - 47]; 400 401 402 /** 224 - Number of possible pointers to shared memory starting at pInherit. 402 403 * This means we can extend the structure with pointers for as long as we 403 404 * want and still have older LIBC versions cleanup the mess. */ … … 645 646 646 647 /** 648 * Process enumeration callback function. 649 * 650 * @returns 0 to continue the enumeration. 651 * @returns Non-zero to stop the enumeration. The enumeration 652 * api will return this same value. 653 * 654 * @param pProcess The current process. 655 * @param pvUser The user argument. 656 * @remark It is *not* allowed to terminate the thread or process, do long jumps 657 * or anything else which causes the enumeration function not to release 658 * the lock. 659 * It is not allowed to do expensive stuff either as it will harm other 660 * processes in the system which want to access the shared process facility! 661 */ 662 typedef int __LIBC_FNSPNENUM(__LIBC_PSPMPROCESS pProcess, void *pvUser); 663 /** Pointer to an process enumeration callback function. */ 664 typedef __LIBC_FNSPNENUM *__LIBC_PFNSPNENUM; 665 666 /** 667 * Enumerates all alive processes in a group. 668 * 669 * @returns 0 on success. 670 * @returns -ESRCH if the process group wasn't found. 671 * @returns -EINVAL if pgrp is negative. 672 * @returns Whatever non-zero value the pfnCallback function returns to stop the enumeration. 673 * 674 * @param pgrp The process group id. 0 is an alias for the process group the caller belongs to. 675 * @param pfnCallback Callback function. 676 * @param pvUser User argument to the callback. 677 */ 678 int __libc_spmEnumProcessesByPGrp(pid_t pgrp, __LIBC_PFNSPNENUM pfnCallback, void *pvUser); 679 680 /** 681 * Enumerates all alive processes owned by a user. 682 * 683 * @returns 0 on success. 684 * @returns -ESRCH if the process group wasn't found. 685 * @returns -EINVAL if uid is negative. 686 * @returns Whatever non-zero value the pfnCallback function returns to stop the enumeration. 687 * 688 * @param uid The process user id. 689 * @param pfnCallback Callback function. 690 * @param pvUser User argument to the callback. 691 */ 692 int __libc_spmEnumProcessesByUser(uid_t uid, __LIBC_PFNSPNENUM pfnCallback, void *pvUser); 693 694 /** 647 695 * Release reference to the given process. 648 696 * … … 652 700 */ 653 701 int __libc_spmRelease(__LIBC_PSPMPROCESS pProcess); 702 703 /** 704 * Checks if the calling process can see the specfied one. 705 * 706 * @returns 0 if it can see it. 707 * @returns -ESRCH (or other approriate error code) if it cannot. 708 * 709 * @param pProcess The process in question. 710 */ 711 int __libc_spmCanSee(__LIBC_PSPMPROCESS pProcess); 712 713 /** 714 * Checks if we are a system-wide super user. 715 * 716 * @returns 0 if we are. 717 * @returns -EPERM if we aren't. 718 */ 719 int __libc_spmIsSuperUser(void); 720 721 /** 722 * Checks if the caller can modify the specified process. 723 * 724 * @returns 0 if we can modify it. 725 * @returns -EPERM if we cannot modify it. 726 * @param pProcess The process in question. 727 */ 728 int __libc_spmCanModify(__LIBC_PSPMPROCESS pProcess); 654 729 655 730 /** … … 691 766 * Identificators which can be obtained using __libc_spmGetId(). 692 767 */ 693 typedef enum __LIBC_SPMI d768 typedef enum __LIBC_SPMID 694 769 { 695 770 __LIBC_SPMID_PID = 0, -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/sys/resource.h
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1909 r1910 37 37 /** @file 38 38 * FreeBSD 5.1 39 * @changed bird: get/setpriority takes id_t not int according to SuS. 39 40 */ 40 41 … … 156 157 157 158 __BEGIN_DECLS 158 int getpriority(int, int);159 int getpriority(int, /*int*/ id_t); /* bird: SuS uses id_t */ 159 160 int getrlimit(int, struct rlimit *); 160 161 int getrusage(int, struct rusage *); 161 int setpriority(int, int, int);162 int setpriority(int, /*int*/ id_t, int); /* bird: SuS uses id_t */ 162 163 int setrlimit(int, const struct rlimit *); 163 164 __END_DECLS -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/unistd.h
-
Property cvs2svn:cvs-rev
changed from
1.27
to1.28
r1909 r1910 448 448 int lchown(const char *, uid_t, gid_t); 449 449 int lockf(int, int, off_t); 450 /** @todo int nice(int); */ 450 int nice(int); 451 451 ssize_t pread(int, void *, size_t, off_t); 452 452 ssize_t pwrite(int, const void *, size_t, off_t); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/libc.def
-
Property cvs2svn:cvs-rev
changed from
1.102
to1.103
r1909 r1910 1495 1495 "__nl_explode_name" @1501 1496 1496 "__nl_normalize_codeset" @1502 1497 ; april coding continues... 1497 1498 "___fbufsize" @1503 1498 1499 "___fpending" @1504 1500 "___libc_Back_processGetPriority" @1505 1501 "___libc_Back_processSetPriority" @1506 1502 "__std_getpriority" @1507 1503 "__std_setpriority" @1508 1504 "__std_nice" @1509 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/sharedpm.c
-
Property cvs2svn:cvs-rev
changed from
1.27
to1.28
r1909 r1910 612 612 * Validate input. 613 613 */ 614 if (pid < =0)614 if (pid < 0) 615 615 { 616 616 errno = EINVAL; 617 617 LIBCLOG_RETURN_P(NULL); 618 618 } 619 620 /* 621 * Fast path for our selves. 622 */ 623 if (!pid || gpSPMSelf->pid == pid) 624 LIBCLOG_RETURN_P(gpSPMSelf); 619 625 620 626 /* … … 665 671 * Validate input. 666 672 */ 667 if (enmState >= __LIBC_PROCSTATE_MAX || pid < =0)673 if (enmState >= __LIBC_PROCSTATE_MAX || pid < 0) 668 674 { 669 675 errno = EINVAL; … … 672 678 673 679 /* 680 * Fast path for our selves. 681 */ 682 if (!pid || gpSPMSelf->pid == pid) 683 LIBCLOG_RETURN_P(gpSPMSelf->enmState == enmState ? gpSPMSelf : NULL); 684 685 /* 674 686 * Request mutex. 675 687 */ … … 694 706 spmReleaseMutex(&RegRec); 695 707 LIBCLOG_RETURN_P(pProcess); 708 } 709 710 711 /** 712 * Enumerates all alive processes in a group. 713 * 714 * @returns 0 on success. 715 * @returns -ESRCH if the process group wasn't found. 716 * @returns -EINVAL if pgrp is negative. 717 * @returns Whatever non-zero value the pfnCallback function returns to stop the enumeration. 718 * 719 * @param pgrp The process group id. 0 is an alias for the process group the caller belongs to. 720 * @param pfnCallback Callback function. 721 * @param pvUser User argument to the callback. 722 */ 723 int __libc_spmEnumProcessesByPGrp(pid_t pgrp, __LIBC_PFNSPNENUM pfnCallback, void *pvUser) 724 { 725 LIBCLOG_ENTER("pgrp=%d pfnCallback=%p pvUser=%p\n", pgrp, (void *)pfnCallback, pvUser); 726 __LIBC_SPMXCPTREGREC RegRec; 727 __LIBC_PSPMPROCESS pProcess; 728 int rc; 729 730 /* 731 * Validate input. 732 */ 733 if (pgrp < 0) 734 LIBCLOG_RETURN_P(-EINVAL); 735 736 /* 737 * Request mutex. 738 */ 739 rc = spmRequestMutex(&RegRec); 740 if (rc) 741 LIBCLOG_RETURN_P(rc); 742 743 /* resolve self reference. */ 744 if (!pgrp) 745 pgrp = gpSPMSelf->pgrp; 746 747 /* 748 * Enumerate the processes. 749 */ 750 rc = -ESRCH; 751 for (pProcess = gpSPMHdr->apHeads[__LIBC_PROCSTATE_ALIVE]; pProcess ; pProcess = pProcess->pNext) 752 { 753 if ( pProcess->pgrp == pgrp 754 && pProcess->enmState == __LIBC_PROCSTATE_ALIVE) 755 { 756 pProcess->cReferences++; 757 rc = pfnCallback(pProcess, pvUser); 758 pProcess->cReferences--; 759 if (rc) 760 break; 761 } 762 } 763 764 /* 765 * Release mutex and return. 766 */ 767 spmReleaseMutex(&RegRec); 768 LIBCLOG_RETURN_P(rc); 769 } 770 771 772 /** 773 * Enumerates all alive processes owned by a user. 774 * 775 * @returns 0 on success. 776 * @returns -ESRCH if the process group wasn't found. 777 * @returns -EINVAL if uid is negative. 778 * @returns Whatever non-zero value the pfnCallback function returns to stop the enumeration. 779 * 780 * @param uid The process user id. 781 * @param pfnCallback Callback function. 782 * @param pvUser User argument to the callback. 783 */ 784 int __libc_spmEnumProcessesByUser(uid_t uid, __LIBC_PFNSPNENUM pfnCallback, void *pvUser) 785 { 786 LIBCLOG_ENTER("uid=%d pfnCallback=%p pvUser=%p\n", uid, (void *)pfnCallback, pvUser); 787 __LIBC_SPMXCPTREGREC RegRec; 788 __LIBC_PSPMPROCESS pProcess; 789 int rc; 790 791 /* 792 * Validate input. 793 */ 794 if (uid < 0) 795 LIBCLOG_RETURN_P(-EINVAL); 796 797 /* 798 * Request mutex. 799 */ 800 rc = spmRequestMutex(&RegRec); 801 if (rc) 802 LIBCLOG_RETURN_P(rc); 803 804 /* 805 * Enumerate the processes. 806 */ 807 rc = -ESRCH; 808 for (pProcess = gpSPMHdr->apHeads[__LIBC_PROCSTATE_ALIVE]; pProcess ; pProcess = pProcess->pNext) 809 { 810 if ( pProcess->euid == uid 811 && pProcess->enmState == __LIBC_PROCSTATE_ALIVE) 812 { 813 pProcess->cReferences++; 814 rc = pfnCallback(pProcess, pvUser); 815 pProcess->cReferences--; 816 if (rc) 817 break; 818 } 819 } 820 821 /* 822 * Release mutex and return. 823 */ 824 spmReleaseMutex(&RegRec); 825 LIBCLOG_RETURN_P(rc); 696 826 } 697 827 … … 742 872 spmReleaseMutex(&RegRec); 743 873 LIBCLOG_RETURN_INT(0); 874 } 875 876 877 /** 878 * Checks if the calling process can see the specfied one. 879 * 880 * @returns 0 if it can see it. 881 * @returns -ESRCH (or other approriate error code) if it cannot. 882 * 883 * @param pProcess The process in question. 884 */ 885 int __libc_spmCanSee(__LIBC_PSPMPROCESS pProcess) 886 { 887 return 0; 888 } 889 890 891 /** 892 * Checks if we are a system-wide super user. 893 * 894 * @returns 0 if we are. 895 * @returns -EPERM if we aren't. 896 */ 897 int __libc_spmIsSuperUser(void) 898 { 899 if (gpSPMSelf->euid == 0) 900 return 0; 901 return -EPERM; 902 } 903 904 905 /** 906 * Checks if the caller can modify the specified process. 907 * 908 * @returns 0 if we can modify it. 909 * @returns -EPERM if we cannot modify it. 910 * @param pProcess The process in question. 911 */ 912 int __libc_spmCanModify(__LIBC_PSPMPROCESS pProcess) 913 { 914 if (!gpSPMSelf->euid) 915 return 0; 916 uid_t euid = pProcess->euid; 917 if ( euid == gpSPMSelf->euid 918 || euid == gpSPMSelf->uid) 919 return 0; 920 return -EPERM; 744 921 } 745 922 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.