From 20e66415abeb3fec26bdbd0c220fb926593ab135 Mon Sep 17 00:00:00 2001 From: Apple Date: Fri, 6 Jun 2003 17:28:09 +0000 Subject: [PATCH] system_cmds-258.tar.gz --- APPLE_LICENSE | 695 +++--- Makefile | 8 +- ac.tproj/ac.c | 21 +- accton.tproj/accton.c | 21 +- arch.tproj/arch.c | 21 +- at.tproj/at.1 | 29 +- at.tproj/at.c | 21 +- at.tproj/at.h | 21 +- at.tproj/panic.c | 21 +- at.tproj/panic.h | 21 +- at.tproj/parsetime.c | 21 +- at.tproj/parsetime.h | 21 +- at.tproj/pathnames.h | 21 +- at.tproj/perm.c | 21 +- at.tproj/perm.h | 21 +- at.tproj/privs.h | 21 +- atrun.tproj/atrun.c | 21 +- atrun.tproj/atrun.h | 21 +- chkpasswd.tproj/Makefile | 4 +- chkpasswd.tproj/ds_passwd.c | 302 +++ chkpasswd.tproj/file_passwd.c | 21 +- chkpasswd.tproj/netinfo_passwd.c | 21 +- chkpasswd.tproj/nis_passwd.c | 21 +- chkpasswd.tproj/passwd.c | 31 +- chkpasswd.tproj/stringops.c | 23 +- chkpasswd.tproj/stringops.h | 21 +- chpass.tproj/Makefile | 4 +- chpass.tproj/Makefile.postamble | 10 + chpass.tproj/chpass.1 | 343 ++- chpass.tproj/chpass.c | 21 +- chpass.tproj/chpass.h | 21 +- chpass.tproj/edit.c | 21 +- chpass.tproj/field.c | 21 +- chpass.tproj/pathnames.h | 21 +- chpass.tproj/pw_copy.c | 21 +- chpass.tproj/pw_copy.h | 21 +- chpass.tproj/table.c | 21 +- chpass.tproj/util.c | 21 +- dmesg.tproj/dmesg.c | 21 +- dp_notify_lib/Makefile.postamble | 2 +- dynamic_pager.tproj/Makefile | 2 +- dynamic_pager.tproj/Makefile.postamble | 2 +- dynamic_pager.tproj/dynamic_pager.c | 275 +-- fastboot.tproj/Makefile | 41 - fastboot.tproj/Makefile.dist | 12 - fastboot.tproj/Makefile.postamble | 134 -- fastboot.tproj/Makefile.preamble | 132 -- fastboot.tproj/PB.project | 44 - fastboot.tproj/fastboot.8 | 69 - fastboot.tproj/fastboot.sh | 38 - fastboot.tproj/fasthalt.sh | 38 - fs_usage.tproj/fs_usage.1 | 137 +- fs_usage.tproj/fs_usage.c | 729 ++++++- getty.tproj/extern.h | 21 +- getty.tproj/gettytab.h | 21 +- getty.tproj/init.c | 21 +- getty.tproj/main.c | 25 +- getty.tproj/pathnames.h | 21 +- getty.tproj/subr.c | 21 +- halt.tproj/Makefile | 48 - halt.tproj/Makefile.dist | 9 - halt.tproj/Makefile.preamble | 3 - halt.tproj/PB.project | 37 - halt.tproj/halt.8 | 86 - halt.tproj/halt.c | 180 -- hostinfo.tproj/hostinfo.c | 21 +- init.tproj/init.c | 21 +- init.tproj/pathnames.h | 21 +- iostat.tproj/Makefile.postamble | 113 +- iostat.tproj/Makefile.preamble | 3 +- iostat.tproj/iostat.8 | 2 +- iostat.tproj/iostat.c | 21 +- kdump.tproj/kdump.c | 21 +- kdump.tproj/syscalls.c | 23 +- kgmon.tproj/kgmon.c | 21 +- ktrace.tproj/ktrace.c | 21 +- ktrace.tproj/subr.c | 21 +- latency.tproj/latency.1 | 63 +- latency.tproj/latency.c | 32 +- login.tproj/klogin.c | 21 +- login.tproj/login.1 | 2 +- login.tproj/login.c | 30 +- login.tproj/pathnames.h | 21 +- mach_init.tproj/bootstrap.c | 101 +- mach_init.tproj/bootstrap.defs | 23 +- mach_init.tproj/bootstrap_internal.h | 25 +- mach_init.tproj/error_log.c | 21 +- mach_init.tproj/error_log.h | 21 +- mach_init.tproj/lists.c | 65 +- mach_init.tproj/lists.h | 21 +- mach_init.tproj/mach_init.8 | 7 +- mach_init.tproj/rpc_services.c | 27 +- makekey.tproj/makekey.c | 21 +- mkfile.tproj/mkfile.c | 21 +- nvram.tproj/nvram.c | 72 +- passwd.tproj/Makefile | 4 +- passwd.tproj/ds_passwd.c | 412 ++++ passwd.tproj/file_passwd.c | 22 +- passwd.tproj/netinfo_passwd.c | 21 +- passwd.tproj/nis_passwd.c | 21 +- passwd.tproj/passwd.c | 46 +- passwd.tproj/stringops.c | 23 +- passwd.tproj/stringops.h | 21 +- pwd_mkdb.tproj/pw_scan.c | 45 +- pwd_mkdb.tproj/pw_scan.h | 21 +- pwd_mkdb.tproj/pwd_mkdb.c | 21 +- reboot.tproj/Makefile.postamble | 7 +- reboot.tproj/reboot.8 | 67 +- reboot.tproj/reboot.c | 184 +- {top.tproj => sa.tproj}/Makefile | 15 +- {top.tproj => sa.tproj}/Makefile.postamble | 6 +- {top.tproj => sa.tproj}/Makefile.preamble | 1 + {top.tproj => sa.tproj}/PB.project | 14 +- sa.tproj/extern.h | 97 + sa.tproj/main.c | 556 +++++ sa.tproj/pathnames.h | 35 + sa.tproj/pdb.c | 424 ++++ sa.tproj/sa.8 | 237 ++ sa.tproj/usrdb.c | 288 +++ sc_usage.tproj/sc_usage.1 | 74 +- sc_usage.tproj/sc_usage.c | 66 +- sc_usage.tproj/trace.codes | 92 +- shutdown.tproj/pathnames.h | 21 +- shutdown.tproj/shutdown.8 | 123 +- shutdown.tproj/shutdown.c | 310 +-- sync.tproj/sync.c | 21 +- sysctl.tproj/sysctl.c | 71 +- top.tproj/top.1 | 194 -- top.tproj/top.c | 2271 -------------------- update.tproj/update.c | 21 +- vipw.tproj/Makefile.postamble | 4 + vipw.tproj/pw_util.c | 21 +- vipw.tproj/pw_util.h | 21 +- vipw.tproj/vipw.8 | 1 - vipw.tproj/vipw.c | 21 +- vm_stat.tproj/vm_stat.1 | 5 +- vm_stat.tproj/vm_stat.c | 21 +- zdump.tproj/zdump.c | 21 +- zic.tproj/ialloc.c | 21 +- zic.tproj/private.h | 21 +- zic.tproj/scheck.c | 21 +- zic.tproj/tzfile.h | 21 +- zic.tproj/zic.c | 21 +- 143 files changed, 5443 insertions(+), 5738 deletions(-) create mode 100644 chkpasswd.tproj/ds_passwd.c delete mode 100644 fastboot.tproj/Makefile delete mode 100644 fastboot.tproj/Makefile.dist delete mode 100644 fastboot.tproj/Makefile.postamble delete mode 100644 fastboot.tproj/Makefile.preamble delete mode 100644 fastboot.tproj/PB.project delete mode 100644 fastboot.tproj/fastboot.8 delete mode 100644 fastboot.tproj/fastboot.sh delete mode 100644 fastboot.tproj/fasthalt.sh delete mode 100644 halt.tproj/Makefile delete mode 100644 halt.tproj/Makefile.dist delete mode 100644 halt.tproj/Makefile.preamble delete mode 100644 halt.tproj/PB.project delete mode 100644 halt.tproj/halt.8 delete mode 100644 halt.tproj/halt.c create mode 100644 passwd.tproj/ds_passwd.c rename {top.tproj => sa.tproj}/Makefile (65%) rename {top.tproj => sa.tproj}/Makefile.postamble (97%) rename {top.tproj => sa.tproj}/Makefile.preamble (99%) rename {top.tproj => sa.tproj}/PB.project (67%) create mode 100644 sa.tproj/extern.h create mode 100644 sa.tproj/main.c create mode 100644 sa.tproj/pathnames.h create mode 100644 sa.tproj/pdb.c create mode 100644 sa.tproj/sa.8 create mode 100644 sa.tproj/usrdb.c delete mode 100644 top.tproj/top.1 delete mode 100644 top.tproj/top.c diff --git a/APPLE_LICENSE b/APPLE_LICENSE index fe81a60..e7aa7d0 100644 --- a/APPLE_LICENSE +++ b/APPLE_LICENSE @@ -1,344 +1,349 @@ -APPLE PUBLIC SOURCE LICENSE -Version 2.0 - August 6, 2003 + APPLE PUBLIC SOURCE LICENSE + Version 1.0 - March 16, 1999 Please read this License carefully before downloading this software. -By downloading or using this software, you are agreeing to be bound by -the terms of this License. If you do not or cannot agree to the terms -of this License, please do not download or use the software. - -1. General; Definitions. This License applies to any program or other -work which Apple Computer, Inc. ("Apple") makes publicly available and -which contains a notice placed by Apple identifying such program or -work as "Original Code" and stating that it is subject to the terms of -this Apple Public Source License version 2.0 ("License"). As used in -this License: - -1.1 "Applicable Patent Rights" mean: (a) in the case where Apple is -the grantor of rights, (i) claims of patents that are now or hereafter -acquired, owned by or assigned to Apple and (ii) that cover subject -matter contained in the Original Code, but only to the extent -necessary to use, reproduce and/or distribute the Original Code -without infringement; and (b) in the case where You are the grantor of -rights, (i) claims of patents that are now or hereafter acquired, -owned by or assigned to You and (ii) that cover subject matter in Your -Modifications, taken alone or in combination with Original Code. - -1.2 "Contributor" means any person or entity that creates or -contributes to the creation of Modifications. - -1.3 "Covered Code" means the Original Code, Modifications, the -combination of Original Code and any Modifications, and/or any -respective portions thereof. - -1.4 "Externally Deploy" means: (a) to sublicense, distribute or -otherwise make Covered Code available, directly or indirectly, to -anyone other than You; and/or (b) to use Covered Code, alone or as -part of a Larger Work, in any way to provide a service, including but -not limited to delivery of content, through electronic communication -with a client other than You. - -1.5 "Larger Work" means a work which combines Covered Code or portions -thereof with code not governed by the terms of this License. - -1.6 "Modifications" mean any addition to, deletion from, and/or change -to, the substance and/or structure of the Original Code, any previous -Modifications, the combination of Original Code and any previous -Modifications, and/or any respective portions thereof. When code is -released as a series of files, a Modification is: (a) any addition to -or deletion from the contents of a file containing Covered Code; -and/or (b) any new file or other representation of computer program -statements that contains any part of Covered Code. - -1.7 "Original Code" means (a) the Source Code of a program or other -work as originally made available by Apple under this License, -including the Source Code of any updates or upgrades to such programs -or works made available by Apple under this License, and that has been -expressly identified by Apple as such in the header file(s) of such -work; and (b) the object code compiled from such Source Code and -originally made available by Apple under this License. - -1.8 "Source Code" means the human readable form of a program or other -work that is suitable for making modifications to it, including all -modules it contains, plus any associated interface definition files, -scripts used to control compilation and installation of an executable -(object code). - -1.9 "You" or "Your" means an individual or a legal entity exercising -rights under this License. For legal entities, "You" or "Your" -includes any entity which controls, is controlled by, or is under -common control with, You, where "control" means (a) the power, direct -or indirect, to cause the direction or management of such entity, -whether by contract or otherwise, or (b) ownership of fifty percent -(50%) or more of the outstanding shares or beneficial ownership of -such entity. - -2. Permitted Uses; Conditions & Restrictions. Subject to the terms -and conditions of this License, Apple hereby grants You, effective on -the date You accept this License and download the Original Code, a -world-wide, royalty-free, non-exclusive license, to the extent of -Apple's Applicable Patent Rights and copyrights covering the Original -Code, to do the following: - -2.1 Unmodified Code. You may use, reproduce, display, perform, -internally distribute within Your organization, and Externally Deploy -verbatim, unmodified copies of the Original Code, for commercial or -non-commercial purposes, provided that in each instance: - -(a) You must retain and reproduce in all copies of Original Code the -copyright and other proprietary notices and disclaimers of Apple as -they appear in the Original Code, and keep intact all notices in the -Original Code that refer to this License; and - -(b) You must include a copy of this License with every copy of Source -Code of Covered Code and documentation You distribute or Externally -Deploy, and You may not offer or impose any terms on such Source Code -that alter or restrict this License or the recipients' rights -hereunder, except as permitted under Section 6. - -2.2 Modified Code. You may modify Covered Code and use, reproduce, -display, perform, internally distribute within Your organization, and -Externally Deploy Your Modifications and Covered Code, for commercial -or non-commercial purposes, provided that in each instance You also -meet all of these conditions: - -(a) You must satisfy all the conditions of Section 2.1 with respect to -the Source Code of the Covered Code; - -(b) You must duplicate, to the extent it does not already exist, the -notice in Exhibit A in each file of the Source Code of all Your -Modifications, and cause the modified files to carry prominent notices -stating that You changed the files and the date of any change; and - -(c) If You Externally Deploy Your Modifications, You must make -Source Code of all Your Externally Deployed Modifications either -available to those to whom You have Externally Deployed Your -Modifications, or publicly available. Source Code of Your Externally -Deployed Modifications must be released under the terms set forth in -this License, including the license grants set forth in Section 3 -below, for as long as you Externally Deploy the Covered Code or twelve -(12) months from the date of initial External Deployment, whichever is -longer. You should preferably distribute the Source Code of Your -Externally Deployed Modifications electronically (e.g. download from a -web site). - -2.3 Distribution of Executable Versions. In addition, if You -Externally Deploy Covered Code (Original Code and/or Modifications) in -object code, executable form only, You must include a prominent -notice, in the code itself as well as in related documentation, -stating that Source Code of the Covered Code is available under the -terms of this License with information on how and where to obtain such -Source Code. - -2.4 Third Party Rights. You expressly acknowledge and agree that -although Apple and each Contributor grants the licenses to their -respective portions of the Covered Code set forth herein, no -assurances are provided by Apple or any Contributor that the Covered -Code does not infringe the patent or other intellectual property -rights of any other entity. Apple and each Contributor disclaim any -liability to You for claims brought by any other entity based on -infringement of intellectual property rights or otherwise. As a -condition to exercising the rights and licenses granted hereunder, You -hereby assume sole responsibility to secure any other intellectual -property rights needed, if any. For example, if a third party patent -license is required to allow You to distribute the Covered Code, it is -Your responsibility to acquire that license before distributing the -Covered Code. - -3. Your Grants. In consideration of, and as a condition to, the -licenses granted to You under this License, You hereby grant to any -person or entity receiving or distributing Covered Code under this -License a non-exclusive, royalty-free, perpetual, irrevocable license, -under Your Applicable Patent Rights and other intellectual property -rights (other than patent) owned or controlled by You, to use, -reproduce, display, perform, modify, sublicense, distribute and -Externally Deploy Your Modifications of the same scope and extent as -Apple's licenses under Sections 2.1 and 2.2 above. - -4. Larger Works. You may create a Larger Work by combining Covered -Code with other code not governed by the terms of this License and -distribute the Larger Work as a single product. In each such instance, -You must make sure the requirements of this License are fulfilled for -the Covered Code or any portion thereof. - -5. Limitations on Patent License. Except as expressly stated in -Section 2, no other patent rights, express or implied, are granted by -Apple herein. Modifications and/or Larger Works may require additional -patent licenses from Apple which Apple may grant in its sole -discretion. - -6. Additional Terms. You may choose to offer, and to charge a fee for, -warranty, support, indemnity or liability obligations and/or other -rights consistent with the scope of the license granted herein -("Additional Terms") to one or more recipients of Covered Code. -However, You may do so only on Your own behalf and as Your sole -responsibility, and not on behalf of Apple or any Contributor. You -must obtain the recipient's agreement that any such Additional Terms -are offered by You alone, and You hereby agree to indemnify, defend -and hold Apple and every Contributor harmless for any liability -incurred by or claims asserted against Apple or such Contributor by -reason of any such Additional Terms. - -7. Versions of the License. Apple may publish revised and/or new -versions of this License from time to time. Each version will be given -a distinguishing version number. Once Original Code has been published -under a particular version of this License, You may continue to use it -under the terms of that version. You may also choose to use such -Original Code under the terms of any subsequent version of this -License published by Apple. No one other than Apple has the right to -modify the terms applicable to Covered Code created under this -License. - -8. NO WARRANTY OR SUPPORT. The Covered Code may contain in whole or in -part pre-release, untested, or not fully tested works. The Covered -Code may contain errors that could cause failures or loss of data, and -may be incomplete or contain inaccuracies. You expressly acknowledge -and agree that use of the Covered Code, or any portion thereof, is at -Your sole and entire risk. THE COVERED CODE IS PROVIDED "AS IS" AND -WITHOUT WARRANTY, UPGRADES OR SUPPORT OF ANY KIND AND APPLE AND -APPLE'S LICENSOR(S) (COLLECTIVELY REFERRED TO AS "APPLE" FOR THE -PURPOSES OF SECTIONS 8 AND 9) AND ALL CONTRIBUTORS EXPRESSLY DISCLAIM -ALL WARRANTIES AND/OR CONDITIONS, EXPRESS OR IMPLIED, INCLUDING, BUT -NOT LIMITED TO, THE IMPLIED WARRANTIES AND/OR CONDITIONS OF -MERCHANTABILITY, OF SATISFACTORY QUALITY, OF FITNESS FOR A PARTICULAR -PURPOSE, OF ACCURACY, OF QUIET ENJOYMENT, AND NONINFRINGEMENT OF THIRD -PARTY RIGHTS. APPLE AND EACH CONTRIBUTOR DOES NOT WARRANT AGAINST -INTERFERENCE WITH YOUR ENJOYMENT OF THE COVERED CODE, THAT THE -FUNCTIONS CONTAINED IN THE COVERED CODE WILL MEET YOUR REQUIREMENTS, -THAT THE OPERATION OF THE COVERED CODE WILL BE UNINTERRUPTED OR -ERROR-FREE, OR THAT DEFECTS IN THE COVERED CODE WILL BE CORRECTED. NO -ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY APPLE, AN APPLE -AUTHORIZED REPRESENTATIVE OR ANY CONTRIBUTOR SHALL CREATE A WARRANTY. -You acknowledge that the Covered Code is not intended for use in the -operation of nuclear facilities, aircraft navigation, communication -systems, or air traffic control machines in which case the failure of -the Covered Code could lead to death, personal injury, or severe -physical or environmental damage. - -9. LIMITATION OF LIABILITY. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO -EVENT SHALL APPLE OR ANY CONTRIBUTOR BE LIABLE FOR ANY INCIDENTAL, -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING -TO THIS LICENSE OR YOUR USE OR INABILITY TO USE THE COVERED CODE, OR -ANY PORTION THEREOF, WHETHER UNDER A THEORY OF CONTRACT, WARRANTY, -TORT (INCLUDING NEGLIGENCE), PRODUCTS LIABILITY OR OTHERWISE, EVEN IF -APPLE OR SUCH CONTRIBUTOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES AND NOTWITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE OF ANY -REMEDY. SOME JURISDICTIONS DO NOT ALLOW THE LIMITATION OF LIABILITY OF -INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS LIMITATION MAY NOT APPLY -TO YOU. In no event shall Apple's total liability to You for all -damages (other than as may be required by applicable law) under this -License exceed the amount of fifty dollars ($50.00). - -10. Trademarks. This License does not grant any rights to use the -trademarks or trade names "Apple", "Apple Computer", "Mac", "Mac OS", -"QuickTime", "QuickTime Streaming Server" or any other trademarks, -service marks, logos or trade names belonging to Apple (collectively -"Apple Marks") or to any trademark, service mark, logo or trade name -belonging to any Contributor. You agree not to use any Apple Marks in -or as part of the name of products derived from the Original Code or -to endorse or promote products derived from the Original Code other -than as expressly permitted by and in strict compliance at all times -with Apple's third party trademark usage guidelines which are posted -at http://www.apple.com/legal/guidelinesfor3rdparties.html. - -11. Ownership. Subject to the licenses granted under this License, -each Contributor retains all rights, title and interest in and to any -Modifications made by such Contributor. Apple retains all rights, -title and interest in and to the Original Code and any Modifications -made by or on behalf of Apple ("Apple Modifications"), and such Apple -Modifications will not be automatically subject to this License. Apple -may, at its sole discretion, choose to license such Apple -Modifications under this License, or on different terms from those -contained in this License or may choose not to license them at all. +By downloading and using this software, you are agreeing to be bound +by the terms of this License. If you do not or cannot agree to the +terms of this License, please do not download or use the software. + +1. General; Definitions. This License applies to any program or other + work which Apple Computer, Inc. ("Apple") publicly announces as + subject to this Apple Public Source License and which contains a + notice placed by Apple identifying such program or work as "Original + Code" and stating that it is subject to the terms of this Apple + Public Source License version 1.0 (or subsequent version thereof), + as it may be revised from time to time by Apple ("License"). As + used in this License: + +1.1 "Applicable Patents" mean: (a) in the case where Apple is the + grantor of rights, (i) patents or patent applications that are now + or hereafter acquired, owned by or assigned to Apple and (ii) whose + claims cover subject matter contained in the Original Code, but only + to the extent necessary to use, reproduce and/or distribute the + Original Code without infringement; and (b) in the case where You + are the grantor of rights, (i) patents and patent applications that + are now or hereafter acquired, owned by or assigned to You and (ii) + whose claims cover subject matter in Your Modifications, taken alone + or in combination with Original Code. + +1.2 "Covered Code" means the Original Code, Modifications, the + combination of Original Code and any Modifications, and/or any + respective portions thereof. + +1.3 "Deploy" means to use, sublicense or distribute Covered Code other + than for Your internal research and development (R&D), and includes + without limitation, any and all internal use or distribution of + Covered Code within Your business or organization except for R&D + use, as well as direct or indirect sublicensing or distribution of + Covered Code by You to any third party in any form or manner. + +1.4 "Larger Work" means a work which combines Covered Code or portions + thereof with code not governed by the terms of this License. + +1.5 "Modifications" mean any addition to, deletion from, and/or change + to, the substance and/or structure of Covered Code. When code is + released as a series of files, a Modification is: (a) any addition + to or deletion from the contents of a file containing Covered Code; + and/or (b) any new file or other representation of computer program + statements that contains any part of Covered Code. + +1.6 "Original Code" means the Source Code of a program or other work + as originally made available by Apple under this License, including + the Source Code of any updates or upgrades to such programs or works + made available by Apple under this License, and that has been + expressly identified by Apple as such in the header file(s) of such + work. + +1.7 "Source Code" means the human readable form of a program or other + work that is suitable for making modifications to it, including all + modules it contains, plus any associated interface definition files, + scripts used to control compilation and installation of an + executable (object code). + +1.8 "You" or "Your" means an individual or a legal entity exercising + rights under this License. For legal entities, "You" or "Your" + includes any entity which controls, is controlled by, or is under + common control with, You, where "control" means (a) the power, + direct or indirect, to cause the direction or management of such + entity, whether by contract or otherwise, or (b) ownership of fifty + percent (50%) or more of the outstanding shares or beneficial + ownership of such entity. + +2. Permitted Uses; Conditions & Restrictions. Subject to the terms + and conditions of this License, Apple hereby grants You, effective + on the date You accept this License and download the Original Code, + a world-wide, royalty-free, non-exclusive license, to the extent of + Apple's Applicable Patents and copyrights covering the Original + Code, to do the following: + +2.1 You may use, copy, modify and distribute Original Code, with or + without Modifications, solely for Your internal research and + development, provided that You must in each instance: + +(a) retain and reproduce in all copies of Original Code the copyright +and other proprietary notices and disclaimers of Apple as they appear +in the Original Code, and keep intact all notices in the Original Code +that refer to this License; + +(b) include a copy of this License with every copy of Source Code of +Covered Code and documentation You distribute, and You may not offer +or impose any terms on such Source Code that alter or restrict this +License or the recipients' rights hereunder, except as permitted under +Section 6; and + +(c) completely and accurately document all Modifications that you have +made and the date of each such Modification, designate the version of +the Original Code you used, prominently include a file carrying such +information with the Modifications, and duplicate the notice in +Exhibit A in each file of the Source Code of all such Modifications. + +2.2 You may Deploy Covered Code, provided that You must in each + instance: + +(a) satisfy all the conditions of Section 2.1 with respect to the +Source Code of the Covered Code; + +(b) make all Your Deployed Modifications publicly available in Source +Code form via electronic distribution (e.g. download from a web site) +under the terms of this License and subject to the license grants set +forth in Section 3 below, and any additional terms You may choose to +offer under Section 6. You must continue to make the Source Code of +Your Deployed Modifications available for as long as you Deploy the +Covered Code or twelve (12) months from the date of initial +Deployment, whichever is longer; + +(c) must notify Apple and other third parties of how to obtain Your +Deployed Modifications by filling out and submitting the required +information found at +http://www.apple.com/publicsource/modifications.html; and + +(d) if you Deploy Covered Code in object code, executable form only, +include a prominent notice, in the code itself as well as in related +documentation, stating that Source Code of the Covered Code is +available under the terms of this License with information on how and +where to obtain such Source Code. + +3. Your Grants. In consideration of, and as a condition to, the + licenses granted to You under this License: + +(a) You hereby grant to Apple and all third parties a non-exclusive, +royalty-free license, under Your Applicable Patents and other +intellectual property rights owned or controlled by You, to use, +reproduce, modify, distribute and Deploy Your Modifications of the +same scope and extent as Apple's licenses under Sections 2.1 and 2.2; +and + +(b) You hereby grant to Apple and its subsidiaries a non-exclusive, +worldwide, royalty-free, perpetual and irrevocable license, under Your +Applicable Patents and other intellectual property rights owned or +controlled by You, to use, reproduce, execute, compile, display, +perform, modify or have modified (for Apple and/or its subsidiaries), +sublicense and distribute Your Modifications, in any form, through +multiple tiers of distribution. + +4. Larger Works. You may create a Larger Work by combining Covered + Code with other code not governed by the terms of this License and + distribute the Larger Work as a single product. In each such + instance, You must make sure the requirements of this License are + fulfilled for the Covered Code or any portion thereof. + +5. Limitations on Patent License. Except as expressly stated in + Section 2, no other patent rights, express or implied, are granted + by Apple herein. Modifications and/or Larger Works may require + additional patent licenses from Apple which Apple may grant in its + sole discretion. + +6. Additional Terms. You may choose to offer, and to charge a fee + for, warranty, support, indemnity or liability obligations and/or + other rights consistent with the scope of the license granted herein + ("Additional Terms") to one or more recipients of Covered + Code. However, You may do so only on Your own behalf and as Your + sole responsibility, and not on behalf of Apple. You must obtain the + recipient's agreement that any such Additional Terms are offered by + You alone, and You hereby agree to indemnify, defend and hold Apple + harmless for any liability incurred by or claims asserted against + Apple by reason of any such Additional Terms. + +7. Versions of the License. Apple may publish revised and/or new + versions of this License from time to time. Each version will be + given a distinguishing version number. Once Original Code has been + published under a particular version of this License, You may + continue to use it under the terms of that version. You may also + choose to use such Original Code under the terms of any subsequent + version of this License published by Apple. No one other than Apple + has the right to modify the terms applicable to Covered Code created + under this License. + +8. NO WARRANTY OR SUPPORT. The Original Code may contain in whole or + in part pre-release, untested, or not fully tested works. The + Original Code may contain errors that could cause failures or loss + of data, and may be incomplete or contain inaccuracies. You + expressly acknowledge and agree that use of the Original Code, or + any portion thereof, is at Your sole and entire risk. THE ORIGINAL + CODE IS PROVIDED "AS IS" AND WITHOUT WARRANTY, UPGRADES OR SUPPORT + OF ANY KIND AND APPLE AND APPLE'S LICENSOR(S) (FOR THE PURPOSES OF + SECTIONS 8 AND 9, APPLE AND APPLE'S LICENSOR(S) ARE COLLECTIVELY + REFERRED TO AS "APPLE") EXPRESSLY DISCLAIM ALL WARRANTIES AND/OR + CONDITIONS, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES AND/OR CONDITIONS OF MERCHANTABILITY OR + SATISFACTORY QUALITY AND FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT OF THIRD PARTY RIGHTS. APPLE DOES NOT WARRANT THAT + THE FUNCTIONS CONTAINED IN THE ORIGINAL CODE WILL MEET YOUR + REQUIREMENTS, OR THAT THE OPERATION OF THE ORIGINAL CODE WILL BE + UNINTERRUPTED OR ERROR-FREE, OR THAT DEFECTS IN THE ORIGINAL CODE + WILL BE CORRECTED. NO ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN + BY APPLE OR AN APPLE AUTHORIZED REPRESENTATIVE SHALL CREATE A + WARRANTY OR IN ANY WAY INCREASE THE SCOPE OF THIS WARRANTY. You + acknowledge that the Original Code is not intended for use in the + operation of nuclear facilities, aircraft navigation, communication + systems, or air traffic control machines in which case the failure + of the Original Code could lead to death, personal injury, or severe + physical or environmental damage. + +9. Liability. + +9.1 Infringement. If any of the Original Code becomes the subject of + a claim of infringement ("Affected Original Code"), Apple may, at + its sole discretion and option: (a) attempt to procure the rights + necessary for You to continue using the Affected Original Code; (b) + modify the Affected Original Code so that it is no longer + infringing; or (c) terminate Your rights to use the Affected + Original Code, effective immediately upon Apple's posting of a + notice to such effect on the Apple web site that is used for + implementation of this License. + +9.2 LIMITATION OF LIABILITY. UNDER NO CIRCUMSTANCES SHALL APPLE BE + LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL + DAMAGES ARISING OUT OF OR RELATING TO THIS LICENSE OR YOUR USE OR + INABILITY TO USE THE ORIGINAL CODE, OR ANY PORTION THEREOF, WHETHER + UNDER A THEORY OF CONTRACT, WARRANTY, TORT (INCLUDING NEGLIGENCE), + PRODUCTS LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF + THE POSSIBILITY OF SUCH DAMAGES AND NOTWITHSTANDING THE FAILURE OF + ESSENTIAL PURPOSE OF ANY REMEDY. In no event shall Apple's total + liability to You for all damages under this License exceed the + amount of fifty dollars ($50.00). + +10. Trademarks. This License does not grant any rights to use the + trademarks or trade names "Apple", "Apple Computer", "Mac OS X", + "Mac OS X Server" or any other trademarks or trade names belonging + to Apple (collectively "Apple Marks") and no Apple Marks may be + used to endorse or promote products derived from the Original Code + other than as permitted by and in strict compliance at all times + with Apple's third party trademark usage guidelines which are + posted at http://www.apple.com/legal/guidelinesfor3rdparties.html. + +11. Ownership. Apple retains all rights, title and interest in and to + the Original Code and any Modifications made by or on behalf of + Apple ("Apple Modifications"), and such Apple Modifications will + not be automatically subject to this License. Apple may, at its + sole discretion, choose to license such Apple Modifications under + this License, or on different terms from those contained in this + License or may choose not to license them at all. Apple's + development, use, reproduction, modification, sublicensing and + distribution of Covered Code will not be subject to this License. 12. Termination. -12.1 Termination. This License and the rights granted hereunder will -terminate: +12.1 Termination. This License and the rights granted hereunder will + terminate: (a) automatically without notice from Apple if You fail to comply with any term(s) of this License and fail to cure such breach within 30 -days of becoming aware of such breach; - -(b) immediately in the event of the circumstances described in Section -13.5(b); or - -(c) automatically without notice from Apple if You, at any time during -the term of this License, commence an action for patent infringement -against Apple; provided that Apple did not first commence -an action for patent infringement against You in that instance. - -12.2 Effect of Termination. Upon termination, You agree to immediately -stop any further use, reproduction, modification, sublicensing and -distribution of the Covered Code. All sublicenses to the Covered Code -which have been properly granted prior to termination shall survive -any termination of this License. Provisions which, by their nature, -should remain in effect beyond the termination of this License shall -survive, including but not limited to Sections 3, 5, 8, 9, 10, 11, -12.2 and 13. No party will be liable to any other for compensation, -indemnity or damages of any sort solely as a result of terminating -this License in accordance with its terms, and termination of this -License will be without prejudice to any other right or remedy of -any party. - -13. Miscellaneous. - -13.1 Government End Users. The Covered Code is a "commercial item" as -defined in FAR 2.101. Government software and technical data rights in -the Covered Code include only those rights customarily provided to the -public as defined in this License. This customary commercial license -in technical data and software is provided in accordance with FAR -12.211 (Technical Data) and 12.212 (Computer Software) and, for -Department of Defense purchases, DFAR 252.227-7015 (Technical Data -- -Commercial Items) and 227.7202-3 (Rights in Commercial Computer -Software or Computer Software Documentation). Accordingly, all U.S. -Government End Users acquire Covered Code with only those rights set -forth herein. - -13.2 Relationship of Parties. This License will not be construed as -creating an agency, partnership, joint venture or any other form of -legal association between or among You, Apple or any Contributor, and -You will not represent to the contrary, whether expressly, by -implication, appearance or otherwise. - -13.3 Independent Development. Nothing in this License will impair -Apple's right to acquire, license, develop, have others develop for -it, market and/or distribute technology or products that perform the -same or similar functions as, or otherwise compete with, -Modifications, Larger Works, technology or products that You may -develop, produce, market or distribute. - -13.4 Waiver; Construction. Failure by Apple or any Contributor to -enforce any provision of this License will not be deemed a waiver of -future enforcement of that or any other provision. Any law or -regulation which provides that the language of a contract shall be -construed against the drafter will not apply to this License. - -13.5 Severability. (a) If for any reason a court of competent -jurisdiction finds any provision of this License, or portion thereof, -to be unenforceable, that provision of the License will be enforced to -the maximum extent permissible so as to effect the economic benefits -and intent of the parties, and the remainder of this License will -continue in full force and effect. (b) Notwithstanding the foregoing, -if applicable law prohibits or restricts You from fully and/or -specifically complying with Sections 2 and/or 3 or prevents the -enforceability of either of those Sections, this License will -immediately terminate and You must immediately discontinue any use of -the Covered Code and destroy all copies of it that are in your -possession or control. - -13.6 Dispute Resolution. Any litigation or other dispute resolution -between You and Apple relating to this License shall take place in the -Northern District of California, and You and Apple hereby consent to -the personal jurisdiction of, and venue in, the state and federal -courts within that District with respect to this License. The -application of the United Nations Convention on Contracts for the -International Sale of Goods is expressly excluded. - -13.7 Entire Agreement; Governing Law. This License constitutes the -entire agreement between the parties with respect to the subject -matter hereof. This License shall be governed by the laws of the -United States and the State of California, except that body of -California law concerning conflicts of law. +days of becoming aware of such breach; (b) immediately in the event of +the circumstances described in Sections 9.1 and/or 13.6(b); or (c) +automatically without notice from Apple if You, at any time during the +term of this License, commence an action for patent infringement +against Apple. + +12.2 Effect of Termination. Upon termination, You agree to + immediately stop any further use, reproduction, modification and + distribution of the Covered Code, or Affected Original Code in the + case of termination under Section 9.1, and to destroy all copies of + the Covered Code or Affected Original Code (in the case of + termination under Section 9.1) that are in your possession or + control. All sublicenses to the Covered Code which have been + properly granted prior to termination shall survive any termination + of this License. Provisions which, by their nature, should remain + in effect beyond the termination of this License shall survive, + including but not limited to Sections 3, 5, 8, 9, 10, 11, 12.2 and + 13. Neither party will be liable to the other for compensation, + indemnity or damages of any sort solely as a result of terminating + this License in accordance with its terms, and termination of this + License will be without prejudice to any other right or remedy of + either party. + +13. Miscellaneous. + +13.1 Export Law Assurances. You may not use or otherwise export or + re-export the Original Code except as authorized by United States + law and the laws of the jurisdiction in which the Original Code was + obtained. In particular, but without limitation, the Original Code + may not be exported or re-exported (a) into (or to a national or + resident of) any U.S. embargoed country or (b) to anyone on the + U.S. Treasury Department's list of Specially Designated Nationals + or the U.S. Department of Commerce's Table of Denial Orders. By + using the Original Code, You represent and warrant that You are not + located in, under control of, or a national or resident of any such + country or on any such list. + +13.2 Government End Users. The Covered Code is a "commercial item" as + defined in FAR 2.101. Government software and technical data + rights in the Covered Code include only those rights customarily + provided to the public as defined in this License. This customary + commercial license in technical data and software is provided in + accordance with FAR 12.211 (Technical Data) and 12.212 (Computer + Software) and, for Department of Defense purchases, DFAR + 252.227-7015 (Technical Data -- Commercial Items) and 227.7202-3 + (Rights in Commercial Computer Software or Computer Software + Documentation). Accordingly, all U.S. Government End Users acquire + Covered Code with only those rights set forth herein. + +13.3 Relationship of Parties. This License will not be construed as + creating an agency, partnership, joint venture or any other form of + legal association between You and Apple, and You will not represent + to the contrary, whether expressly, by implication, appearance or + otherwise. + +13.4 Independent Development. Nothing in this License will impair + Apple's right to acquire, license, develop, have others develop for + it, market and/or distribute technology or products that perform + the same or similar functions as, or otherwise compete with, + Modifications, Larger Works, technology or products that You may + develop, produce, market or distribute. + +13.5 Waiver; Construction. Failure by Apple to enforce any provision + of this License will not be deemed a waiver of future enforcement + of that or any other provision. Any law or regulation which + provides that the language of a contract shall be construed against + the drafter will not apply to this License. + +13.6 Severability. (a) If for any reason a court of competent + jurisdiction finds any provision of this License, or portion + thereof, to be unenforceable, that provision of the License will be + enforced to the maximum extent permissible so as to effect the + economic benefits and intent of the parties, and the remainder of + this License will continue in full force and effect. (b) + Notwithstanding the foregoing, if applicable law prohibits or + restricts You from fully and/or specifically complying with + Sections 2 and/or 3 or prevents the enforceability of either of + those Sections, this License will immediately terminate and You + must immediately discontinue any use of the Covered Code and + destroy all copies of it that are in your possession or control. + +13.7 Dispute Resolution. Any litigation or other dispute resolution + between You and Apple relating to this License shall take place in + the Northern District of California, and You and Apple hereby + consent to the personal jurisdiction of, and venue in, the state + and federal courts within that District with respect to this + License. The application of the United Nations Convention on + Contracts for the International Sale of Goods is expressly + excluded. + +13.8 Entire Agreement; Governing Law. This License constitutes the + entire agreement between the parties with respect to the subject + matter hereof. This License shall be governed by the laws of the + United States and the State of California, except that body of + California law concerning conflicts of law. Where You are located in the province of Quebec, Canada, the following clause applies: The parties hereby confirm that they have requested @@ -346,22 +351,20 @@ that this License and all related documents be drafted in English. Les parties ont exige que le present contrat et tous les documents connexes soient rediges en anglais. -EXHIBIT A. +EXHIBIT A. -"Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights -Reserved. - -This file contains Original Code and/or Modifications of Original Code -as defined in and that are subject to the Apple Public Source License -Version 2.0 (the 'License'). You may not use this file except in -compliance with the License. Please obtain a copy of the License at -http://www.opensource.apple.com/apsl/ and read it before using this -file. +"Portions Copyright (c) 1999 Apple Computer, Inc. All Rights +Reserved. This file contains Original Code and/or Modifications of +Original Code as defined in and that are subject to the Apple Public +Source License Version 1.0 (the 'License'). You may not use this file +except in compliance with the License. Please obtain a copy of the +License at http://www.apple.com/publicsource and read it before using +this file. The Original Code and all software distributed under the License are distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. -Please see the License for the specific language governing rights and -limitations under the License." +FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the +License for the specific language governing rights and limitations +under the License." diff --git a/Makefile b/Makefile index e567192..a635afc 100644 --- a/Makefile +++ b/Makefile @@ -14,17 +14,17 @@ PROJECT_TYPE = Aggregate TOOLS = dynamic_pager.tproj ac.tproj accton.tproj arch.tproj at.tproj\ atrun.tproj chkpasswd.tproj chpass.tproj dmesg.tproj\ - getty.tproj halt.tproj hostinfo.tproj init.tproj iostat.tproj\ + getty.tproj hostinfo.tproj init.tproj iostat.tproj\ kgmon.tproj ktrace.tproj login.tproj mach_init.tproj\ makekey.tproj mkfile.tproj nvram.tproj passwd.tproj\ - pwd_mkdb.tproj reboot.tproj shutdown.tproj sync.tproj\ + pwd_mkdb.tproj reboot.tproj sa.tproj shutdown.tproj sync.tproj\ sysctl.tproj update.tproj vipw.tproj zic.tproj zdump.tproj\ - vm_stat.tproj zprint.tproj top.tproj latency.tproj\ + vm_stat.tproj zprint.tproj latency.tproj\ sc_usage.tproj fs_usage.tproj kdump.tproj LIBRARIES = dp_notify_lib -LEGACIES = fastboot.tproj nologin.tproj pagesize.tproj +LEGACIES = nologin.tproj pagesize.tproj OTHERSRCS = Makefile.preamble Makefile README.rtf APPLE_LICENSE diff --git a/ac.tproj/ac.c b/ac.tproj/ac.c index 249b80a..f23915c 100644 --- a/ac.tproj/ac.c +++ b/ac.tproj/ac.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/accton.tproj/accton.c b/accton.tproj/accton.c index 40ec198..723c336 100644 --- a/accton.tproj/accton.c +++ b/accton.tproj/accton.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/arch.tproj/arch.c b/arch.tproj/arch.c index 7b5d5dc..0e140fe 100644 --- a/arch.tproj/arch.c +++ b/arch.tproj/arch.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/at.tproj/at.1 b/at.tproj/at.1 index f8869ca..47c2591 100644 --- a/at.tproj/at.1 +++ b/at.tproj/at.1 @@ -27,7 +27,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $Id: at.1,v 1.1.1.1 1999/05/02 04:21:18 wsanchez Exp $ +.\" $Id: at.1,v 1.3 2003/06/05 17:13:32 eseidel Exp $ .\" .Dd December 5, 1993 .Dt "AT" 1 @@ -55,6 +55,25 @@ .Op Fl f Ar file .Op Fl m .Ar time +.Sh NOTE +.Nm at , +.Nm batch , +.Nm atq , +.Nm atrm +are all disabled by default on Mac OS X. +Each of these commands depend on the execution of +.Xr atrun 8 +which has been disabled due to power management concerns. +Those who would like to use these commands, must first re-enable +.Nm /usr/libexec/atrun +by removing the leading '#' from the line +.Bd -literal +#*/5 * * * * root /usr/libexec/atrun +.Ed +in the file +.Pa /etc/crontab . +.Pa /etc/crontab +must be edited by root. .Sh DESCRIPTION The .Nm at @@ -75,9 +94,10 @@ listed. .It Nm atrm Deletes jobs. .It Nm batch -executes commands when system load levels permit. -In other words, it executes the commands when the load -average drops below a specified level. +Executes commands when system load levels drop below a user-specifed threshold. +The load threshold for batch jobs is specifed +as an argument when executing +.Xr atrun 8 . .El .Pp For both @@ -124,6 +144,7 @@ Reads the job from rather than the standard input. .It Fl v Shows completed but not yet deleted jobs in the queue. +.El .Sh TIME SPECIFICATION .Nm At allows some moderately complex time specifications. diff --git a/at.tproj/at.c b/at.tproj/at.c index e5ce512..0caf2d1 100644 --- a/at.tproj/at.c +++ b/at.tproj/at.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/at.tproj/at.h b/at.tproj/at.h index a107751..117a547 100644 --- a/at.tproj/at.h +++ b/at.tproj/at.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/at.tproj/panic.c b/at.tproj/panic.c index b4d8b76..839a54c 100644 --- a/at.tproj/panic.c +++ b/at.tproj/panic.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/at.tproj/panic.h b/at.tproj/panic.h index 5f40a37..dda9212 100644 --- a/at.tproj/panic.h +++ b/at.tproj/panic.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/at.tproj/parsetime.c b/at.tproj/parsetime.c index 582dce5..46811fa 100644 --- a/at.tproj/parsetime.c +++ b/at.tproj/parsetime.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/at.tproj/parsetime.h b/at.tproj/parsetime.h index ef334a1..c2e792b 100644 --- a/at.tproj/parsetime.h +++ b/at.tproj/parsetime.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/at.tproj/pathnames.h b/at.tproj/pathnames.h index 209135f..daf1edc 100644 --- a/at.tproj/pathnames.h +++ b/at.tproj/pathnames.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/at.tproj/perm.c b/at.tproj/perm.c index a2df820..0a5ba30 100644 --- a/at.tproj/perm.c +++ b/at.tproj/perm.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/at.tproj/perm.h b/at.tproj/perm.h index 30fb0ca..8d14b37 100644 --- a/at.tproj/perm.h +++ b/at.tproj/perm.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/at.tproj/privs.h b/at.tproj/privs.h index 5e6b226..ae37877 100644 --- a/at.tproj/privs.h +++ b/at.tproj/privs.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/atrun.tproj/atrun.c b/atrun.tproj/atrun.c index 0634fb2..f9e31bd 100644 --- a/atrun.tproj/atrun.c +++ b/atrun.tproj/atrun.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/atrun.tproj/atrun.h b/atrun.tproj/atrun.h index ef281f2..af24723 100644 --- a/atrun.tproj/atrun.h +++ b/atrun.tproj/atrun.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chkpasswd.tproj/Makefile b/chkpasswd.tproj/Makefile index 1c335d1..1d74f6a 100644 --- a/chkpasswd.tproj/Makefile +++ b/chkpasswd.tproj/Makefile @@ -14,7 +14,7 @@ PROJECT_TYPE = Tool HFILES = stringops.h -CFILES = nis_passwd.c file_passwd.c netinfo_passwd.c passwd.c\ +CFILES = ds_passwd.c nis_passwd.c file_passwd.c netinfo_passwd.c passwd.c\ stringops.c OTHERSRCS = Makefile.preamble Makefile Makefile.postamble @@ -26,7 +26,7 @@ MAKEFILE = tool.make NEXTSTEP_INSTALLDIR = /usr/libexec WINDOWS_INSTALLDIR = /usr/bin PDO_UNIX_INSTALLDIR = /usr/bin -LIBS = +LIBS = /System/Library/Frameworks/DirectoryService.framework/Versions/A/DirectoryService DEBUG_LIBS = $(LIBS) PROF_LIBS = $(LIBS) diff --git a/chkpasswd.tproj/ds_passwd.c b/chkpasswd.tproj/ds_passwd.c new file mode 100644 index 0000000..29c18d9 --- /dev/null +++ b/chkpasswd.tproj/ds_passwd.c @@ -0,0 +1,302 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1998 by Apple Computer, Inc. + * Portions Copyright (c) 1988 by Sun Microsystems, Inc. + * Portions Copyright (c) 1988 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +// password server can store 511 characters + a terminator. +#define kMaxPassword 512 + +#define SaySorryAndBail() {status = -1; break;} + +//------------------------------------------------------------------------------------- +// ds_check_passwd +//------------------------------------------------------------------------------------- + +int ds_check_passwd(char *uname, char *domain) +{ + char *p = NULL; + tDirReference dsRef = 0; + tDataBuffer *tDataBuff = NULL; + tDirNodeReference nodeRef = 0; + long status = eDSNoErr; + tContextData context = NULL; + unsigned long nodeCount = 0; + unsigned long attrIndex = 0; + tDataList *nodeName = NULL; + tAttributeEntryPtr pAttrEntry = NULL; + tDataList *pRecName = NULL; + tDataList *pRecType = NULL; + tDataList *pAttrType = NULL; + unsigned long recCount = 0; + tRecordEntry *pRecEntry = NULL; + tAttributeListRef attrListRef = 0; + char *pUserLocation = NULL; + char *pUserName = NULL; + tAttributeValueListRef valueRef = 0; + tAttributeValueEntry *pValueEntry = NULL; + tDataList *pUserNode = NULL; + tDirNodeReference userNodeRef = 0; + tDataBuffer *pStepBuff = NULL; + tDataNode *pAuthType = NULL; + unsigned long uiCurr = 0; + unsigned long uiLen = 0; + + do + { + if (uname == NULL) + SaySorryAndBail(); + + printf("Checking password for %s.\n", uname); + p = getpass("Password:"); + if ( p == NULL ) + SaySorryAndBail(); + + status = dsOpenDirService( &dsRef ); + if ( status != eDSNoErr ) + SaySorryAndBail(); + + tDataBuff = dsDataBufferAllocate( dsRef, 4096 ); + if (tDataBuff == NULL) + SaySorryAndBail(); + + if ( domain != NULL ) + { + nodeName = dsBuildFromPath( dsRef, domain, "/" ); + if ( nodeName == NULL ) break; + + // find + status = dsFindDirNodes( dsRef, tDataBuff, nodeName, eDSiExact, &nodeCount, &context ); + } + else + { + // find on search node + status = dsFindDirNodes( dsRef, tDataBuff, NULL, eDSSearchNodeName, &nodeCount, &context ); + } + + if ( status != eDSNoErr ) + SaySorryAndBail(); + + if ( nodeCount < 1 ) + SaySorryAndBail(); + + status = dsGetDirNodeName( dsRef, tDataBuff, 1, &nodeName ); + if (status != eDSNoErr) + SaySorryAndBail(); + + status = dsOpenDirNode( dsRef, nodeName, &nodeRef ); + dsDataListDeallocate( dsRef, nodeName ); + free( nodeName ); + nodeName = NULL; + if (status != eDSNoErr) + SaySorryAndBail(); + + pRecName = dsBuildListFromStrings( dsRef, uname, NULL ); + pRecType = dsBuildListFromStrings( dsRef, kDSStdRecordTypeUsers, NULL ); + pAttrType = dsBuildListFromStrings( dsRef, kDSNAttrMetaNodeLocation, kDSNAttrRecordName, NULL ); + + recCount = 1; + status = dsGetRecordList( nodeRef, tDataBuff, pRecName, eDSExact, pRecType, + pAttrType, 0, &recCount, &context ); + if ( status != eDSNoErr || recCount == 0 ) + SaySorryAndBail(); + + status = dsGetRecordEntry( nodeRef, tDataBuff, 1, &attrListRef, &pRecEntry ); + if ( status != eDSNoErr ) + SaySorryAndBail(); + + for ( attrIndex = 1; (attrIndex <= pRecEntry->fRecordAttributeCount) && (status == eDSNoErr); attrIndex++ ) + { + status = dsGetAttributeEntry( nodeRef, tDataBuff, attrListRef, attrIndex, &valueRef, &pAttrEntry ); + if ( status == eDSNoErr && pAttrEntry != NULL ) + { + if ( strcmp( pAttrEntry->fAttributeSignature.fBufferData, kDSNAttrMetaNodeLocation ) == 0 ) + { + status = dsGetAttributeValue( nodeRef, tDataBuff, 1, valueRef, &pValueEntry ); + if ( status == eDSNoErr && pValueEntry != NULL ) + { + pUserLocation = (char *) calloc( pValueEntry->fAttributeValueData.fBufferLength + 1, sizeof(char) ); + memcpy( pUserLocation, pValueEntry->fAttributeValueData.fBufferData, pValueEntry->fAttributeValueData.fBufferLength ); + } + } + else + if ( strcmp( pAttrEntry->fAttributeSignature.fBufferData, kDSNAttrRecordName ) == 0 ) + { + status = dsGetAttributeValue( nodeRef, tDataBuff, 1, valueRef, &pValueEntry ); + if ( status == eDSNoErr && pValueEntry != NULL ) + { + pUserName = (char *) calloc( pValueEntry->fAttributeValueData.fBufferLength + 1, sizeof(char) ); + memcpy( pUserName, pValueEntry->fAttributeValueData.fBufferData, pValueEntry->fAttributeValueData.fBufferLength ); + } + } + + if ( pValueEntry != NULL ) + dsDeallocAttributeValueEntry( dsRef, pValueEntry ); + pValueEntry = NULL; + + dsDeallocAttributeEntry( dsRef, pAttrEntry ); + pAttrEntry = NULL; + dsCloseAttributeValueList( valueRef ); + valueRef = 0; + } + } + + pUserNode = dsBuildFromPath( dsRef, pUserLocation, "/" ); + status = dsOpenDirNode( dsRef, pUserNode, &userNodeRef ); + if ( status != eDSNoErr ) + SaySorryAndBail(); + + pStepBuff = dsDataBufferAllocate( dsRef, 128 ); + + pAuthType = dsDataNodeAllocateString( dsRef, kDSStdAuthNodeNativeClearTextOK ); + uiCurr = 0; + + // User name + uiLen = strlen( pUserName ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), &uiLen, sizeof( unsigned long ) ); + uiCurr += sizeof( unsigned long ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), pUserName, uiLen ); + uiCurr += uiLen; + + // pw + uiLen = strlen( p ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), &uiLen, sizeof( unsigned long ) ); + uiCurr += sizeof( unsigned long ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), p, uiLen ); + uiCurr += uiLen; + + tDataBuff->fBufferLength = uiCurr; + + status = dsDoDirNodeAuth( userNodeRef, pAuthType, 1, tDataBuff, pStepBuff, NULL ); + + } + while ( 0 ); + + // clean up + if (tDataBuff != NULL) { + memset(tDataBuff, 0, tDataBuff->fBufferSize); + dsDataBufferDeAllocate( dsRef, tDataBuff ); + tDataBuff = NULL; + } + + if (pStepBuff != NULL) { + dsDataBufferDeAllocate( dsRef, pStepBuff ); + pStepBuff = NULL; + } + if (pUserLocation != NULL ) { + free(pUserLocation); + pUserLocation = NULL; + } + if (pRecName != NULL) { + dsDataListDeallocate( dsRef, pRecName ); + free( pRecName ); + pRecName = NULL; + } + if (pRecType != NULL) { + dsDataListDeallocate( dsRef, pRecType ); + free( pRecType ); + pRecType = NULL; + } + if (pAttrType != NULL) { + dsDataListDeallocate( dsRef, pAttrType ); + free( pAttrType ); + pAttrType = NULL; + } + if (nodeRef != 0) { + dsCloseDirNode(nodeRef); + nodeRef = 0; + } + if (dsRef != 0) { + dsCloseDirService(dsRef); + dsRef = 0; + } + + if ( status != eDSNoErr ) + { + errno = EACCES; + fprintf(stderr, "Sorry\n"); + exit(1); + } + + return 0; +} + + + + + + \ No newline at end of file diff --git a/chkpasswd.tproj/file_passwd.c b/chkpasswd.tproj/file_passwd.c index 083c111..51fc8c1 100644 --- a/chkpasswd.tproj/file_passwd.c +++ b/chkpasswd.tproj/file_passwd.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chkpasswd.tproj/netinfo_passwd.c b/chkpasswd.tproj/netinfo_passwd.c index e04f723..762f00d 100644 --- a/chkpasswd.tproj/netinfo_passwd.c +++ b/chkpasswd.tproj/netinfo_passwd.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chkpasswd.tproj/nis_passwd.c b/chkpasswd.tproj/nis_passwd.c index a1227eb..89b0411 100644 --- a/chkpasswd.tproj/nis_passwd.c +++ b/chkpasswd.tproj/nis_passwd.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chkpasswd.tproj/passwd.c b/chkpasswd.tproj/passwd.c index f422f05..2115573 100644 --- a/chkpasswd.tproj/passwd.c +++ b/chkpasswd.tproj/passwd.c @@ -3,28 +3,28 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ #define INFO_NETINFO 0 #define INFO_FILE 1 #define INFO_NIS 2 +#define INFO_DIRECTORYSERVICES 3 #ifndef __SLICK__ #define _PASSWD_FILE "/etc/master.passwd" @@ -51,6 +51,7 @@ static int literal = 0; extern int file_check_passwd(char *, char *); extern int netinfo_check_passwd(char *, char *); extern int nis_check_passwd(char *, char *); +extern int ds_check_passwd(char *, char *); void checkpasswd(char *name, char *old_pw) @@ -86,10 +87,12 @@ usage() fprintf(stderr, " netinfo\n"); fprintf(stderr, " file\n"); fprintf(stderr, " nis\n"); + fprintf(stderr, " opendirectory\n"); fprintf(stderr, "for netinfo, location may be a domain name or server/tag\n"); fprintf(stderr, "for file, location may be a file name (%s is the default)\n", _PASSWD_FILE); fprintf(stderr, "for nis, location may be a NIS domainname\n"); + fprintf(stderr, "for opendirectory, location may be a directory node name\n"); fprintf(stderr, "if -c is specified, the password you supply is compared\n"); fprintf(stderr, "verbatim without first being crypted\n"); exit(1); @@ -102,7 +105,7 @@ main(int argc, char *argv[]) int i, infosystem; struct passwd *pw; - infosystem = INFO_NETINFO; + infosystem = INFO_DIRECTORYSERVICES; user = NULL; locn = NULL; @@ -124,6 +127,7 @@ main(int argc, char *argv[]) else if (!strcmp(argv[i], "nis")) infosystem = INFO_NIS; else if (!strcmp(argv[i], "YP")) infosystem = INFO_NIS; else if (!strcmp(argv[i], "yp")) infosystem = INFO_NIS; + else if (!strcasecmp(argv[i], "opendirectory")) infosystem = INFO_DIRECTORYSERVICES; else { fprintf(stderr, "unknown info system \"%s\"\n", argv[i]); @@ -166,6 +170,9 @@ main(int argc, char *argv[]) case INFO_NIS: nis_check_passwd(user, locn); break; + case INFO_DIRECTORYSERVICES: + ds_check_passwd(user, locn); + break; } exit(0); diff --git a/chkpasswd.tproj/stringops.c b/chkpasswd.tproj/stringops.c index 18a9e82..fcf861d 100644 --- a/chkpasswd.tproj/stringops.c +++ b/chkpasswd.tproj/stringops.c @@ -3,29 +3,28 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ #import #import #import -#import +#import #import "stringops.h" char *copyString(char *s) diff --git a/chkpasswd.tproj/stringops.h b/chkpasswd.tproj/stringops.h index 34f9b4f..417a167 100644 --- a/chkpasswd.tproj/stringops.h +++ b/chkpasswd.tproj/stringops.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chpass.tproj/Makefile b/chpass.tproj/Makefile index b0d8d24..4fa59cb 100644 --- a/chpass.tproj/Makefile +++ b/chpass.tproj/Makefile @@ -12,11 +12,11 @@ NAME = chpass PROJECTVERSION = 2.8 PROJECT_TYPE = Tool -HFILES = chpass.h pathnames.h pw_copy.h +HFILES = chpass.h pathnames.h pw_copy.h pw_scan.h pw_util.h CFILES = chpass.c edit.c field.c pw_copy.c table.c util.c -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble chpass.1\ +OTHERSRCS = Makefile.preamble Makefile Makefile.postamble chpass.1 \ Makefile.dist diff --git a/chpass.tproj/Makefile.postamble b/chpass.tproj/Makefile.postamble index 7b6db99..2630582 100644 --- a/chpass.tproj/Makefile.postamble +++ b/chpass.tproj/Makefile.postamble @@ -1,9 +1,19 @@ VPATH += :../pwd_mkdb.tproj:../vipw.tproj INSTALL_AS_USER = root +INSTALL_AS_GROUP = wheel INSTALL_PERMISSIONS =4555 #CHFLAGS = /usr/bin/chflags after_install:: + install -o $(INSTALL_AS_USER) -m 755 -d $(DSTROOT)/usr/share/man/man1 + install -o $(INSTALL_AS_USER) -m 644 -c chpass.1 \ + $(DSTROOT)/usr/share/man/man1 + $(LN) -s chpass.1 $(DSTROOT)/usr/share/man/man1/chfn.1 + $(LN) -s chpass.1 $(DSTROOT)/usr/share/man/man1/chsh.1 + chown $(INSTALL_AS_USER):$(INSTALL_AS_GROUP) \ + $(DSTROOT)/usr/share/man/man1/chfn.1 + chown $(INSTALL_AS_USER):$(INSTALL_AS_GROUP) \ + $(DSTROOT)/usr/share/man/man1/chsh.1 $(LN) -f $(INSTALLED_PRODUCTS) $(DSTROOT)$(INSTALLDIR)/chfn $(LN) -f $(INSTALLED_PRODUCTS) $(DSTROOT)$(INSTALLDIR)/chsh # $(CHFLAGS) schg $(DSTROOT)$(INSTALLDIR)/$(NAME) diff --git a/chpass.tproj/chpass.1 b/chpass.tproj/chpass.1 index 1a40905..69840c2 100644 --- a/chpass.tproj/chpass.1 +++ b/chpass.tproj/chpass.1 @@ -30,47 +30,82 @@ .\" SUCH DAMAGE. .\" .\" @(#)chpass.1 8.2 (Berkeley) 12/30/93 +.\" $FreeBSD: src/usr.bin/chpass/chpass.1,v 1.34 2002/12/24 13:41:47 ru Exp $ .\" .Dd December 30, 1993 .Dt CHPASS 1 .Os .Sh NAME -.Nm chpass +.Nm chpass , +.Nm chfn , +.Nm chsh , .Nd add or change user database information .Sh SYNOPSIS -chpass +.Nm +.Op Fl a Ar list +.Op Fl p Ar encpass +.Op Fl e Ar expiretime +.Op Fl s Ar newshell +.Op user +.Pp +.Nm +.Op Fl oly .Op Fl a Ar list +.Op Fl p Ar encpass +.Op Fl e Ar expiretime .Op Fl s Ar newshell +.Op Fl d Ar domain +.Op Fl h Ar host .Op user .Sh DESCRIPTION -.Nm Chpass +The +.Nm +utility allows editing of the user database information associated with .Ar user or, by default, the current user. +.Pp +The +.Nm chfn , +and +.Nm chsh +utilities behave identically to +.Nm . +(There is only one program.) +.Pp The information is formatted and supplied to an editor for changes. .Pp Only the information that the user is allowed to change is displayed. .Pp The options are as follows: -.Bl -tag -width Ds +.Bl -tag -width indent .It Fl a The super-user is allowed to directly supply a user database entry, in the format specified by .Xr passwd 5 , as an argument. -This argument must be a colon (``:'') separated list of all the +This argument must be a colon +.Pq Dq \&: +separated list of all the user database fields, although they may be empty. -.It Fl s -The -.Fl s -option attempts to change the user's shell to +.It Fl p +The super-user is allowed to directly supply an encrypted password field, +in the format used by +.Xr crypt 3 , +as an argument. +.It Fl e Ar expiretime +Change the account expire time. +This option is used to set the expire time +from a script as if it was done in the interactive editor. +.It Fl s Ar newshell +Attempt to change the user's shell to .Ar newshell . .El .Pp Possible display items are as follows: .Pp -.Bl -tag -width "Home Directory:" -compact -offset indent +.Bl -tag -width "Other Information:" -compact -offset indent .It Login: user's login name .It Password: @@ -79,24 +114,30 @@ user's encrypted password user's login .It Gid: user's login group +.It Class: +user's general classification .It Change: password change time .It Expire: account expiration time -.It Class: -user's general classification +.It Full Name: +user's real name +.It Office Location: +user's office location (1) +.It Office Phone: +user's office phone (1) +.It Home Phone: +user's home phone (1) +.It Other Information: +any locally defined parameters for user (1) .It Home Directory: user's home directory .It Shell: user's login shell -.It Full Name: -user's real name -.It Location: -user's normal location -.It Home Phone: -user's home phone -.It Office Phone: -user's office phone +.Pp +.It NOTE(1) - +In the actual master.passwd file, these fields are comma-delimited +fields embedded in the FullName field. .El .Pp The @@ -123,13 +164,22 @@ entries, and that one by random selection. The .Ar group field is the group that the user will be placed in at login. -Since BSD supports multiple groups (see +Since +.Bx +supports multiple groups (see .Xr groups 1 ) this field currently has little special meaning. This field may be filled in with either a number or a group name (see .Xr group 5 ) . .Pp The +.Ar class +field references class descriptions in +.Pa /etc/login.conf +and is typically used to initialize the user's system resource limits +when they login. +.Pp +The .Ar change field is the date by which the password must be changed. .Pp @@ -141,7 +191,9 @@ Both the .Ar change and .Ar expire -fields should be entered in the form ``month day year'' where +fields should be entered in the form +.Dq month day year +where .Ar month is the month name (the first three characters are sufficient), .Ar day @@ -149,16 +201,26 @@ is the day of the month, and .Ar year is the year. .Pp -The -.Ar class -field is currently unused. In the near future it will be a key to -a -.Xr termcap 5 -style database of user attributes. +Five fields are available for storing the user's +.Ar full name , office location , +.Ar work +and +.Ar home telephone +numbers and finally +.Ar other information +which is a single comma delimited string to represent any additional +gcos fields (typically used for site specific user information). +Note that +.Xr finger 1 +will display the office location and office phone together under the +heading +.Ar Office: . .Pp The user's .Ar home directory -is the full UNIX path name where the user +is the full +.Ux +path name where the user will be placed at login. .Pp The @@ -175,44 +237,235 @@ shell. Non-standard is defined as a shell not found in .Pa /etc/shells . .Pp -The last four fields are for storing the user's -.Ar full name , office location , -and -.Ar home -and -.Ar work telephone -numbers. -.Pp Once the information has been verified, -.Nm chpass +.Nm uses .Xr pwd_mkdb 8 to update the user database. .Sh ENVIRONMENT The .Xr vi 1 -editor will be used unless the environment variable EDITOR is set to +editor will be used unless the environment variable +.Ev EDITOR +is set to an alternate editor. When the editor terminates, the information is re-read and used to update the user database itself. Only the user, or the super-user, may edit the information associated with the user. +.Pp +See +.Xr pwd_mkdb 8 +for an explanation of the impact of setting the +.Ev PW_SCAN_BIG_IDS +environment variable. +.Sh NIS INTERACTION +The +.Nm +utility can also be used in conjunction with NIS, however some restrictions +apply. +Currently, +.Nm +can only make changes to the NIS passwd maps through +.Xr rpc.yppasswdd 8 , +which normally only permits changes to a user's password, shell and GECOS +fields. +Except when invoked by the super-user on the NIS master server, +.Nm +(and, similarly, +.Xr passwd 1 ) +cannot use the +.Xr rpc.yppasswdd 8 +server to change other user information or +add new records to the NIS passwd maps. +Furthermore, +.Xr rpc.yppasswdd 8 +requires password authentication before it will make any +changes. +The only user allowed to submit changes without supplying +a password is the super-user on the NIS master server; all other users, +including those with root privileges on NIS clients (and NIS slave +servers) must enter a password. +(The super-user on the NIS master is allowed to bypass these restrictions +largely for convenience: a user with root access +to the NIS master server already has the privileges required to make +updates to the NIS maps, but editing the map source files by hand can +be cumbersome. +.Pp +Note: these exceptions only apply when the NIS master server is a +.Fx +system). +.Pp +Consequently, except where noted, the following restrictions apply when +.Nm +is used with NIS: +.Bl -enum -offset indent +.It +.Em "Only the shell and GECOS information may be changed" . +All other +fields are restricted, even when +.Nm +is invoked by the super-user. +While support for +changing other fields could be added, this would lead to +compatibility problems with other NIS-capable systems. +Even though the super-user may supply data for other fields +while editing an entry, the extra information (other than the +password -- see below) will be silently discarded. +.Pp +Exception: the super-user on the NIS master server is permitted to +change any field. +.Pp +.It +.Em "Password authentication is required" . +The +.Nm +utility will prompt for the user's NIS password before effecting +any changes. +If the password is invalid, all changes will be +discarded. +.Pp +Exception: the super-user on the NIS master server is allowed to +submit changes without supplying a password. +(The super-user may +choose to turn off this feature using the +.Fl o +flag, described below.) +.It +.Em "Adding new records to the local password database is discouraged" . +The +.Nm +utility will allow the administrator to add new records to the +local password database while NIS is enabled, but this can lead to +some confusion since the new records are appended to the end of +the master password file, usually after the special NIS '+' entries. +The administrator should use +.Xr vipw 8 +to modify the local password +file when NIS is running. +.Pp +The super-user on the NIS master server is permitted to add new records +to the NIS password maps, provided the +.Xr rpc.yppasswdd 8 +server has been started with the +.Fl a +flag to permitted additions (it refuses them by default). +The +.Nm +utility tries to update the local password database by default; to update the +NIS maps instead, invoke chpass with the +.Fl y +flag. +.It +.Em "Password changes are not permitted". +Users should use +.Xr passwd 1 +or +.Xr yppasswd 1 +to change their NIS passwords. +The super-user is allowed to specify +a new password (even though the +.Dq Password: +field does not show +up in the editor template, the super-user may add it back by hand), +but even the super-user must supply the user's original password +otherwise +.Xr rpc.yppasswdd 8 +will refuse to update the NIS maps. +.Pp +Exception: the super-user on the NIS master server is permitted to +change a user's NIS password with +.Nm . +.El +.Pp +There are also a few extra option flags that are available when +.Nm +is compiled with NIS support: +.Bl -tag -width indent +.It Fl l +Force +.Nm +to modify the local copy of a user's password +information in the even that a user exists in both +the local and NIS databases. +.It Fl y +Opposite effect of +.Fl l . +This flag is largely redundant since +.Nm +operates on NIS entries by default if NIS is enabled. +.It Fl d Ar domain +Specify a particular NIS domain. +The +.Nm +utility uses the system domain name by default, as set by the +.Xr domainname 1 +utility. +The +.Fl d +option can be used to override a default, or to specify a domain +when the system domain name is not set. +.It Fl h Ar host +Specify the name or address of an NIS server to query. +Normally, +.Nm +will communicate with the NIS master host specified in the +.Pa master.passwd +or +.Pa passwd +maps. +On hosts that have not been configured as NIS clients, there is +no way for the program to determine this information unless the user +provides the hostname of a server. +Note that the specified hostname need +not be that of the NIS master server; the name of any server, master or +slave, in a given NIS domain will do. +.Pp +When using the +.Fl d +option, the hostname defaults to +.Dq localhost . +The +.Fl h +option can be used in conjunction with the +.Fl d +option, in which case the user-specified hostname will override +the default. +.Pp +.It Fl o +Force the use of RPC-based updates when communicating with +.Xr rpc.yppasswdd 8 +.Pq Dq old-mode . +When invoked by the super-user on the NIS master server, +.Nm +allows unrestricted changes to the NIS passwd maps using dedicated, +non-RPC-based mechanism (in this case, a +.Ux +domain socket). The +.Fl o +flag can be used to force +.Nm +to use the standard update mechanism instead. +This option is provided +mainly for testing purposes. +.El .Sh FILES .Bl -tag -width /etc/master.passwd -compact .It Pa /etc/master.passwd -The user database +the user database .It Pa /etc/passwd -A Version 7 format password file +a Version 7 format password file .It Pa /etc/chpass.XXXXXX -Temporary copy of the password file +temporary copy of the password file .It Pa /etc/shells -The list of approved shells +the list of approved shells .El .Sh SEE ALSO -.Xr login 1 , .Xr finger 1 , +.Xr login 1 , .Xr passwd 1 , .Xr getusershell 3 , +.Xr login.conf 5 , .Xr passwd 5 , .Xr pwd_mkdb 8 , .Xr vipw 8 @@ -227,5 +480,5 @@ User information should (and eventually will) be stored elsewhere. .Sh HISTORY The .Nm -command appeared in +utility appeared in .Bx 4.3 Reno . diff --git a/chpass.tproj/chpass.c b/chpass.tproj/chpass.c index 96b3d80..8068511 100644 --- a/chpass.tproj/chpass.c +++ b/chpass.tproj/chpass.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chpass.tproj/chpass.h b/chpass.tproj/chpass.h index 59c6706..99209d2 100644 --- a/chpass.tproj/chpass.h +++ b/chpass.tproj/chpass.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chpass.tproj/edit.c b/chpass.tproj/edit.c index e6a16ca..0b9e3d2 100644 --- a/chpass.tproj/edit.c +++ b/chpass.tproj/edit.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chpass.tproj/field.c b/chpass.tproj/field.c index 275e712..2fc07ba 100644 --- a/chpass.tproj/field.c +++ b/chpass.tproj/field.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chpass.tproj/pathnames.h b/chpass.tproj/pathnames.h index 6f0a0bc..03c43a3 100644 --- a/chpass.tproj/pathnames.h +++ b/chpass.tproj/pathnames.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chpass.tproj/pw_copy.c b/chpass.tproj/pw_copy.c index d30b56f..64ddc9f 100644 --- a/chpass.tproj/pw_copy.c +++ b/chpass.tproj/pw_copy.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chpass.tproj/pw_copy.h b/chpass.tproj/pw_copy.h index c71c067..4a742ac 100644 --- a/chpass.tproj/pw_copy.h +++ b/chpass.tproj/pw_copy.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chpass.tproj/table.c b/chpass.tproj/table.c index 8971086..dbae702 100644 --- a/chpass.tproj/table.c +++ b/chpass.tproj/table.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/chpass.tproj/util.c b/chpass.tproj/util.c index 74fd386..c4dd4d3 100644 --- a/chpass.tproj/util.c +++ b/chpass.tproj/util.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/dmesg.tproj/dmesg.c b/dmesg.tproj/dmesg.c index 321c40a..10d5cae 100644 --- a/dmesg.tproj/dmesg.c +++ b/dmesg.tproj/dmesg.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/dp_notify_lib/Makefile.postamble b/dp_notify_lib/Makefile.postamble index 0e1fe3c..76afa21 100644 --- a/dp_notify_lib/Makefile.postamble +++ b/dp_notify_lib/Makefile.postamble @@ -99,7 +99,7 @@ INSTALLDIR = /usr/local/lib # owned by the top-level Makefile API and no context has been set up for where # derived files should go. # -MIGFLAGS = -traditional-cpp -R -untyped -DNO_DIRECT_RPC -I$(SRCROOT) +MIGFLAGS = -no-cpp-precomp -R -untyped -DNO_DIRECT_RPC -I$(SRCROOT) MIG = $(NEXT_ROOT)/usr/bin/mig backing_store_alerts_server.c: \ diff --git a/dynamic_pager.tproj/Makefile b/dynamic_pager.tproj/Makefile index b406af1..6bc4214 100644 --- a/dynamic_pager.tproj/Makefile +++ b/dynamic_pager.tproj/Makefile @@ -28,7 +28,7 @@ DEBUG_LIBS = $(LIBS) PROF_LIBS = $(LIBS) -NEXTSTEP_PB_CFLAGS = -traditional-cpp -DNO_DIRECT_RPC +NEXTSTEP_PB_CFLAGS = -no-cpp-precomp -DNO_DIRECT_RPC NEXTSTEP_BUILD_OUTPUT_DIR = /tmp/$(USER)/BUILD diff --git a/dynamic_pager.tproj/Makefile.postamble b/dynamic_pager.tproj/Makefile.postamble index 18e890b..aedcab1 100644 --- a/dynamic_pager.tproj/Makefile.postamble +++ b/dynamic_pager.tproj/Makefile.postamble @@ -103,7 +103,7 @@ SRC_ROOT = $(SRCROOT) # owned by the top-level Makefile API and no context has been set up for where # derived files should go. # -MIGFLAGS = -traditional-cpp -R -untyped -DNO_DIRECT_RPC +MIGFLAGS = -no-cpp-precomp -R -untyped -DNO_DIRECT_RPC MIG = $(NEXT_ROOT)/usr/bin/mig default_pager_alerts_server.c : backing_store_alerts.c \ diff --git a/dynamic_pager.tproj/dynamic_pager.c b/dynamic_pager.tproj/dynamic_pager.c index c168eab..e4d1cda 100644 --- a/dynamic_pager.tproj/dynamic_pager.c +++ b/dynamic_pager.tproj/dynamic_pager.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -36,41 +35,22 @@ #include #include - -/* - * HI_WATER_DEFAULT set to this funny value to - * match the size that the low space application - * is asking for... need to keep MINIMUM_SIZE - * above this value. - */ -#define HI_WATER_DEFAULT 40000000 -#define MINIMUM_SIZE (1024 * 1024 * 64) -#define MAXIMUM_SIZE (1024 * 1024 * 1024) - -#define MAX_LIMITS 8 - - -struct limit { - unsigned int size; - unsigned int low_water; -} limits[MAX_LIMITS]; - - int debug = 0; -int max_valid = 0; int file_count = 0; -unsigned int hi_water; -unsigned int local_hi_water; +int low_water = 0; +int hi_water = 0; +int local_hi_water = 0; +int size = 20000000; int priority = 0; -int options = 0; +int options = 0; char fileroot[512]; /* global parameters for application notification option */ mach_port_t trigger_port = MACH_PORT_NULL; mach_port_t notify_port = MACH_PORT_NULL; -unsigned int notify_high = 0; -unsigned int bs_recovery; +int notify_high = 0; +int bs_recovery; /* void setprof __P((struct kvmvars *kvp, int state)); @@ -172,14 +152,7 @@ backing_store_triggers(dynamic_pager, hi_wat, flags, port) int flags; mach_port_t port; { - int cur_limits; - - if (file_count > max_valid) - cur_limits = max_valid; - else - cur_limits = file_count; - - if((hi_wat + limits[cur_limits].size) > limits[cur_limits].low_water) + if((hi_wat + size) > low_water) return KERN_FAILURE; /* let ipc system clean up port */ /* If there was a previous registration, throw it away */ @@ -209,60 +182,24 @@ default_pager_space_alert(alert_port, flags) { char subfile[512]; FILE *file_ptr; - off_t filesize; + off_t filesize = size; int error; kern_return_t ret; - int cur_limits; - unsigned int cur_size; - unsigned int notifications; - if(flags & HI_WAT_ALERT) { - +/* printf("HI WAT ALERT!!\n"); */ file_count++; - - if (file_count > max_valid) - cur_limits = max_valid; - else - cur_limits = file_count; - - cur_size = limits[cur_limits].size; - filesize = cur_size; - - /* - * because the LO_WAT threshold changes relative to - * the size of the swap file we're creating - * we need to reset the LO_WAT_ALERT threshold each - * time we create a new swap file - */ - if (limits[cur_limits].low_water) - notifications = HI_WAT_ALERT | LO_WAT_ALERT; - else - notifications = HI_WAT_ALERT; - sprintf(subfile, "%s%d", fileroot, file_count); file_ptr = fopen(subfile, "w+"); fchmod(fileno(file_ptr), (mode_t)01600); error = fcntl(fileno(file_ptr), F_SETSIZE, &filesize); if(error) { - error = ftruncate(fileno(file_ptr), filesize); + error = ftruncate(fileno(file_ptr), (off_t)size); } fclose(file_ptr); - if(error == -1) { unlink(subfile); file_count--; - - if (file_count > max_valid) - cur_limits = max_valid; - else - cur_limits = file_count; - - if (limits[cur_limits].low_water) - notifications = HI_WAT_ALERT | LO_WAT_ALERT; - else - notifications = HI_WAT_ALERT; - local_hi_water = local_hi_water>>2; if(notify_high >= (local_hi_water)) { if(notify_port != MACH_PORT_NULL) { @@ -276,7 +213,8 @@ default_pager_space_alert(alert_port, flags) notify_high = 0; } } - macx_triggers(local_hi_water, limits[cur_limits].low_water, notifications, alert_port); + macx_triggers(local_hi_water, + low_water, HI_WAT_ALERT, alert_port); } else { if(hi_water < notify_high) { if(local_hi_water < notify_high) { @@ -289,22 +227,10 @@ default_pager_space_alert(alert_port, flags) } local_hi_water = hi_water; } - ret = macx_swapon(subfile, flags, cur_size, priority); - + ret = macx_swapon(subfile, flags, size, priority); if(ret) { unlink(subfile); file_count--; - - if (file_count > max_valid) - cur_limits = max_valid; - else - cur_limits = file_count; - - if (limits[cur_limits].low_water) - notifications = HI_WAT_ALERT | LO_WAT_ALERT; - else - notifications = HI_WAT_ALERT; - local_hi_water = local_hi_water>>2; if(notify_high >= (local_hi_water)) { if(notify_port != MACH_PORT_NULL) { @@ -320,8 +246,9 @@ default_pager_space_alert(alert_port, flags) notify_high = 0; } } - macx_triggers(local_hi_water, limits[cur_limits].low_water, notifications, alert_port); - } else if(bs_recovery <= cur_size) { + macx_triggers(local_hi_water, + low_water, HI_WAT_ALERT, alert_port); + } else if(bs_recovery <= size) { if((bs_recovery != 0) && (notify_port)) { backing_store_alert(notify_port, LO_WAT_ALERT); @@ -332,11 +259,14 @@ default_pager_space_alert(alert_port, flags) bs_recovery = 0; } } else - bs_recovery = bs_recovery-cur_size; + bs_recovery = bs_recovery-size; } - macx_triggers(local_hi_water, limits[cur_limits].low_water, notifications, alert_port); + + macx_triggers(local_hi_water, + low_water, HI_WAT_ALERT, alert_port); } if(flags & LO_WAT_ALERT) { +/* Turn into a logged message printf("LO WAT ALERT!!\n"); */ sprintf(subfile, "%s%d", fileroot, file_count); if(hi_water < notify_high) { local_hi_water = notify_high; @@ -350,26 +280,11 @@ default_pager_space_alert(alert_port, flags) notify_high = 0; bs_recovery = 0; } - if((error = macx_swapoff(subfile, flags)) == 0) { - + if(macx_swapoff(subfile, flags) == 0) { unlink(subfile); file_count--; - - if (file_count > max_valid) - cur_limits = max_valid; - else - cur_limits = file_count; - } else { - if (file_count > max_valid) - cur_limits = max_valid; - else - cur_limits = file_count; } - /* - * only need to reset the LO_WAT_ALERT... the HI_WAT size is fixed, - * it doesn't change even if the swap file size shrinks or grows - */ - macx_triggers(local_hi_water, limits[cur_limits].low_water, LO_WAT_ALERT, alert_port); + macx_triggers(local_hi_water, low_water, LO_WAT_ALERT, alert_port); } return KERN_SUCCESS; } @@ -406,12 +321,11 @@ paging_setup(flags, size, priority, low, high) fchmod(fileno(file_ptr), (mode_t)01600); error = fcntl(fileno(file_ptr), F_SETSIZE, &filesize); if(error) { - error = ftruncate(fileno(file_ptr), filesize); + error = ftruncate(fileno(file_ptr), (off_t)size); } fclose(file_ptr); macx_swapon(subfile, flags, size, priority); - if(hi_water) { mach_msg_type_name_t poly; @@ -427,9 +341,9 @@ paging_setup(flags, size, priority, low, high) mach_port_extract_right(mach_task_self(), trigger_port, MACH_MSG_TYPE_MAKE_SEND, &trigger_port, &poly); macx_triggers(high, low, HI_WAT_ALERT, trigger_port); - if(low) { - macx_triggers(high, low, LO_WAT_ALERT, trigger_port); + macx_triggers(high, + low, LO_WAT_ALERT, trigger_port); } /* register control port for applications wishing to */ /* get backing store notifications or change dynamic */ @@ -437,7 +351,7 @@ paging_setup(flags, size, priority, low, high) set_dp_control_port(mach_host_self(), trigger_port); wait_on_paging_trigger(trigger_port); } - exit(0); + exit(0); } int main(int argc, char **argv) @@ -446,18 +360,10 @@ main(int argc, char **argv) extern int optind; char default_filename[] = "/private/var/vm/swapfile"; int ch; - int variable_sized = 1; seteuid(getuid()); strcpy(fileroot, default_filename); - limits[0].size = 20000000; - limits[0].low_water = 0; - - hi_water = 0; - local_hi_water = 0; - - while ((ch = getopt(argc, argv, "F:L:H:S:P:O:")) != EOF) { switch((char)ch) { @@ -466,16 +372,13 @@ main(int argc, char **argv) break; case 'L': - variable_sized = 0; - limits[0].low_water = atoi(optarg); + low_water = atoi(optarg); break; case 'H': - variable_sized = 0; hi_water = atoi(optarg); break; case 'S': - variable_sized = 0; - limits[0].size = atoi(optarg); + size = atoi(optarg); break; case 'P': priority = atoi(optarg); @@ -487,127 +390,13 @@ main(int argc, char **argv) exit(1); } } - - if (variable_sized) { - static char tmp[1024]; - struct statfs sfs; - char *q; - int i; - int mib[4]; - size_t len; - unsigned int size; - u_int64_t memsize; - u_int64_t fs_limit; - - /* - * if we get here, then none of the following options were specified... -L, H, or -S - * drop into a new mode that scales the size of the swap file based on how much free - * space is left on the volume being used for swap and the amount of physical ram - * installed on the system... - * basically, we'll pick a maximum size that doesn't exceed the following limits... - * 1/4 the remaining free space of the swap volume - * the size of phsyical ram - * MAXIMUM_SIZE - currently set to 1 Gbyte... - * once we have the maximum, we'll create a list of sizes and low_water limits - * we'll start with 2 files of MINIMUM_SIZE - currently 64 Mbytes... - * subsequent entries will double in size up to the calculated maximum... the low_water - * limit will be the sum of the current file size and the previous file size for each entry... - * as we add or delete files, we'll use the current file_count as an index into this - * table... if it's beyond the table size, we'll use the last entry - * the table entry will determine the size of the file to be created and the new low_water mark... - * the high_water mark is set to HI_WATER_DEFAULT which must be smaller than MINIMUM_SIZE... - * currently it is set to 40,000,000 to match the size being requested by the application - * monitoring low space conditions... having it set to the same size keeps us from creating - * an additional swap file when it really isn't necessary - */ - - /* - * get rid of the filename at the end of the swap file specification - * we only want the portion of the pathname that should already exist - */ - strcpy(tmp, fileroot); - if (q = strrchr(tmp, '/')) - *q = 0; - - if (statfs(tmp, &sfs) != -1) { - /* - * limit the maximum size of a swap file to 1/4 the free - * space available on the filesystem where the swap files - * are to reside - */ - fs_limit = ((u_int64_t)sfs.f_bfree * (u_int64_t)sfs.f_bsize) / 4; - - } else { - (void)fprintf(stderr, "usage: swap directory must exist\n"); - exit(1); - } - mib[0] = CTL_HW; - mib[1] = HW_MEMSIZE; - len = sizeof(u_int64_t); - - if (sysctl(mib, 2, &memsize, &len, NULL, 0) < 0) { - /* - * if the sysctl fails for some reason - * use the starting size as the default - */ - memsize = MINIMUM_SIZE; - } - if (memsize > fs_limit) - /* - * clip based on filesystem space available - */ - memsize = fs_limit; - - /* - * further limit the maximum size of a swap file - */ - if (memsize > MAXIMUM_SIZE) - memsize = MAXIMUM_SIZE; - - size = MINIMUM_SIZE; - - /* - * start small and work our way up to the maximum - * sized allowed... this way, we don't tie up too - * much disk space if we never do any real paging - */ - for (max_valid = 0, i = 0; i < MAX_LIMITS; i++) { - limits[i].size = size; - - if (i == 0) - limits[i].low_water = size * 2; - else { - if ((limits[i - 1].size / 2) > HI_WATER_DEFAULT) - limits[i].low_water = size + (limits[i - 1].size / 2); - else - limits[i].low_water = size + limits[i - 1].size; - } - if (size >= memsize) - break; - - if (i) { - /* - * make the first 2 files the same size - */ - size = size * 2; - } - max_valid++; - } - if (max_valid >= MAX_LIMITS) - max_valid = MAX_LIMITS - 1; - - hi_water = HI_WATER_DEFAULT; - } local_hi_water = hi_water; - - if((limits[0].low_water != 0) && (limits[0].low_water <= (limits[0].size + hi_water))) { + if((low_water != 0) && (low_water <= (size + hi_water))) { (void)fprintf(stderr, "usage: low water trigger must be larger than size + hi_water\n"); exit(1); } argc -= optind; argv += optind; - - paging_setup(0, limits[0].size, priority, limits[0].low_water, hi_water); - + paging_setup(0, size, priority, low_water, hi_water); return (0); } diff --git a/fastboot.tproj/Makefile b/fastboot.tproj/Makefile deleted file mode 100644 index d38af02..0000000 --- a/fastboot.tproj/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = fastboot - -PROJECTVERSION = 2.6 -PROJECT_TYPE = Legacy -LANGUAGE = English - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble Makefile.dist\ - fastboot.8 fastboot.sh fasthalt.sh - - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = common.make -NEXTSTEP_INSTALLDIR = /sbin -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_BUILD_OUTPUT_DIR = /$(USER)/BUILD - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/fastboot.tproj/Makefile.dist b/fastboot.tproj/Makefile.dist deleted file mode 100644 index 9504f79..0000000 --- a/fastboot.tproj/Makefile.dist +++ /dev/null @@ -1,12 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/5/93 - -MAN8= fastboot.0 -MLINKS= fastboot.8 fasthalt.8 - -beforeinstall: - install -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ - ${.CURDIR}/fastboot.sh ${DESTDIR}${BINDIR}/fastboot - install -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ - ${.CURDIR}/fasthalt.sh ${DESTDIR}${BINDIR}/fasthalt - -.include diff --git a/fastboot.tproj/Makefile.postamble b/fastboot.tproj/Makefile.postamble deleted file mode 100644 index a98f3d1..0000000 --- a/fastboot.tproj/Makefile.postamble +++ /dev/null @@ -1,134 +0,0 @@ -############################################################################### -# NeXT Makefile.postamble -# Copyright 1996, NeXT Software, Inc. -# -# This Makefile is used for configuring the standard app makefiles associated -# with ProjectBuilder. -# -# Use this template to set attributes for a project, sub-project, bundle, or -# palette. Each node in the project's tree of sub-projects and bundles -# should have it's own Makefile.preamble and Makefile.postamble. Additional -# rules (e.g., after_install) that are defined by the developer should be -# defined in this file. -# -############################################################################### -# -# Here are the variables exported by the common "app" makefiles that can be -# used in any customizations you make to the template below: -# -# PRODUCT_ROOT - Name of the directory to which resources are copied. -# OFILE_DIR - Directory into which .o object files are generated. -# (Note that this name is calculated based on the target -# architectures specified in Project Builder). -# DERIVED_SRC_DIR - Directory used for all other derived files -# ALL_CFLAGS - All the flags passed to the cc(1) driver for compilations -# -# NAME - name of application, bundle, subproject, palette, etc. -# LANGUAGE - langage in which the project is written (default "English") -# LOCAL_RESOURCES - localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES - non-localized resources of project -# PROJECTVERSION - version of ProjectBuilder project (NS3.X = 1.1, NS4.0 = 2.0) -# ICONSECTIONS - Specifies icon sections when linking executable -# -# CLASSES - Class implementation files in project. -# HFILES - Header files in project. -# MFILES - Other Objective-C source files in project. -# CFILES - Other C source files in project. -# PSWFILES - .psw files in the project -# PSWMFILES - .pswm files in the project -# SUBPROJECTS - Subprojects of this project -# BUNDLES - Bundle subprojects of this project -# OTHERSRCS - Other miscellaneous sources of this project -# OTHERLINKED - Source files not matching a standard source extention -# -# LIBS - Libraries to link with when making app target -# DEBUG_LIBS - Libraries to link with when making debug target -# PROF_LIBS - Libraries to link with when making profile target -# OTHERLINKEDOFILES - Other relocatable files to (always) link in. -# -# APP_MAKEFILE_DIR - Directory in which to find generic set of Makefiles -# MAKEFILEDIR - Directory in which to find $(MAKEFILE) -# MAKEFILE - Top level mechanism Makefile (e.g., app.make, bundle.make) -# INSTALLDIR - Directory app will be installed into by 'install' target -# -############################################################################### - - -# Change defaults assumed by the standard makefiles here. Edit the -# following default values as appropriate. (Note that if no Makefile.postamble -# exists, these values will have defaults set in common.make). - -# Versioning of frameworks, libraries, bundles, and palettes: -#CURRENTLY_ACTIVE_VERSION = YES - # Set to "NO" to produce a compatibility binary -#DEPLOY_WITH_VERSION_NAME = A - # This should be incremented as your API changes. -#COMPATIBILITY_PROJECT_VERSION = 1 - # This should be incremented as your API grows. -#CURRENT_PROJECT_VERSION = 1 - # Defaults to using the "vers_string" hack. - -# Some compiler flags can be easily overridden here, but onlytake effect at -# the top-level: -#OPTIMIZATION_CFLAG = -O -#DEBUG_SYMBOLS_CFLAG = -g -#WARNING_CFLAGS = -Wmost -#DEBUG_BUILD_CFLAGS = -DDEBUG -#PROFILE_BUILD_CFLAGS = -pg -DPROFILE - -# This definition will suppress stripping of debug symbols when an executable -# is installed. By default it is YES. -# STRIP_ON_INSTALL = NO - -# Flags passed to yacc -#YFLAGS = -d - -# Library and Framework projects only: -# 1. If you want something other than the default .dylib name, override it here -#DYLIB_INSTALL_NAME = lib$(NAME).dylib - -# 2. If you want to change the -install_name flag from the absolute path to the development area, change it here. One good choice is the installation directory. Another one might be none at all. -#DYLIB_INSTALL_DIR = $(INSTALLDIR) - -# Ownership and permissions of files installed by 'install' target -#INSTALL_AS_USER = root - # User/group ownership -#INSTALL_AS_GROUP = wheel - # (probably want to set both of these) -#INSTALL_PERMISSIONS = - # If set, 'install' chmod's executable to this - -# Options to strip for various project types. Note: -S strips debugging symbols -# (executables can be stripped down further with -x or, if they load no bundles, with no -# options at all). -#APP_STRIP_OPTS = -S -#TOOL_STRIP_OPTS = -S -#LIBRARY_STRIP_OPTS = -S - # for .a archives -#DYNAMIC_STRIP_OPTS = -S - # for bundles and shared libraries - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. "Official" -# user-defined rules are: -# * before_install -# * after_install -# * after_installhdrs -# You should avoid redefining things like "install" or "app", as they are -# owned by the top-level Makefile API and no context has been set up for where -# derived files should go. -# -# Note: on MS Windows, executables, have an extension, so rules and dependencies -# for generated tools should use $(EXECUTABLE_EXT) on the end. - -fastboot: fastboot.sh - $(CP) fastboot.sh ${SYM_DIR}/fastboot - -fasthalt: fasthalt.sh - $(CP) fasthalt.sh ${SYM_DIR}/fasthalt - -after_install:: - $(CP) -p ${SYM_DIR}/fastboot $(DSTROOT)$(INSTALLDIR)/fastboot - $(CHMOD) 555 $(DSTROOT)$(INSTALLDIR)/fastboot - $(CP) -p ${SYM_DIR}/fasthalt $(DSTROOT)$(INSTALLDIR)/fasthalt - $(CHMOD) 555 $(DSTROOT)$(INSTALLDIR)/fasthalt diff --git a/fastboot.tproj/Makefile.preamble b/fastboot.tproj/Makefile.preamble deleted file mode 100644 index 4ad2338..0000000 --- a/fastboot.tproj/Makefile.preamble +++ /dev/null @@ -1,132 +0,0 @@ -############################################################################### -# NeXT Makefile.preamble -# Copyright 1996, NeXT Software, Inc. -# -# This Makefile is used for configuring the standard app makefiles associated -# with ProjectBuilder. -# -# Use this template to set attributes for a project. Each node in a project -# tree of sub-projects, tools, etc. should have its own Makefile.preamble and -# Makefile.postamble. -# -############################################################################### -## Configure the flags passed to $(CC) here. These flags will also be -## inherited by all nested sub-projects and bundles. Put your -I, -D, -U, and -## -L flags in ProjectBuilder's Build Options inspector if at all possible. -## To change the default flags that get passed to ${CC} -## (e.g. change -O to -O2), see Makefile.postamble. - -# Flags passed to compiler (in addition to -g, -O, etc) -OTHER_CFLAGS = -# Flags passed to ld (in addition to -ObjC, etc.) -OTHER_LDFLAGS = -# Flags passed to libtool when building libraries -OTHER_LIBTOOL_FLAGS = -# For ordering named sections on NEXTSTEP (see ld(1)) -SECTORDER_FLAGS = - -# If you do not want any headers exported before compilations begin, -# uncomment the following line. This can be a big time saver. -#SKIP_EXPORTING_HEADERS = YES - -# Stuff related to exporting headers from this project that isn't already -# handled by PB. -OTHER_PUBLIC_HEADERS = -OTHER_PROJECT_HEADERS = -OTHER_PRIVATE_HEADERS = - -# Set these two macros if you want a precomp to be built as part of -# installation. The cc -precomp will be run in the public header directory -# on the specified public header files with the specified additional flags. -PUBLIC_PRECOMPILED_HEADERS = -PUBLIC_PRECOMPILED_HEADERS_CFLAGS = - -# Set this for library projects if you want to publish header files. If your -# app or tool project exports headers Don't -# include $(DSTROOT); this is added for you automatically. -PUBLIC_HEADER_DIR = -PRIVATE_HEADER_DIR = - -# If, in a subproject, you want to append to the parent's PUBLIC_HEADER_DIR# -# (say, to add a subdirectory like "/sys"), you can use: -PUBLIC_HEADER_DIR_SUFFIX = -PRIVATE_HEADER_DIR_SUFFIX = - -# Set this for dynamic library projects on platforms where code which references -# a dynamic library must link against an import library (i.e., Windows NT) -# Don't include $(DSTROOT); this is added for you automatically. -IMPORT_LIBRARY_DIR = - -# Additional (non-localized) resources for this project, which can be generated -OTHER_RESOURCES = - -# Uncomment this to produce a static archive-style (.a) library -#LIBRARY_STYLE = STATIC - -# Set this to YES if you don't want a final libtool call for a library/framework. -BUILD_OFILES_LIST_ONLY = - -# Additional relocatables to be linked into this project -OTHER_OFILES = -# Additional libraries to link against -OTHER_LIBS = -# To include a version string, project source must exist in a directory named -# $(NAME).%d[.%d][.%d] and the following line must be uncommented. -# OTHER_GENERATED_OFILES = $(VERS_OFILE) - -## Configure how things get built here. Additional dependencies, source files, -## derived files, and build order should be specified here. - -# Other dependencies of this project -OTHER_PRODUCT_DEPENDS = -# Built *before* building subprojects/bundles -OTHER_INITIAL_TARGETS = -# Other source files maintained by .pre/postamble -OTHER_SOURCEFILES = -# Additional files to be removed by `make clean' -OTHER_GARBAGE = - -# Targets to build before installation -OTHER_INSTALL_DEPENDS = - -# More obscure flags you might want to set for pswrap, yacc, lex, etc. -PSWFLAGS = -YFLAGS = -LFLAGS = - -## Delete this line if you want fast and loose cleans that will not remove -## things like precomps and user-defined OTHER_GARBAGE in subprojects. -CLEAN_ALL_SUBPROJECTS = YES - -## Add more obscure source files here to cause them to be automatically -## processed by the appropriate tool. Note that these files should also be -## added to "Supporting Files" in ProjectBuilder. The desired .o files that -## result from these files should also be added to OTHER_OFILES above so they -## will be linked in. - -# .msg files that should have msgwrap run on them -MSGFILES = -# .defs files that should have mig run on them -DEFSFILES = -# .mig files (no .defs files) that should have mig run on them -MIGFILES = -# .x files that should have rpcgen run on them -RPCFILES = - -## Add additional Help directories here (add them to the project as "Other -## Resources" in Project Builder) so that they will be compressed into .store -## files and copied into the app wrapper. If the help directories themselves -## need to also be in the app wrapper, then a cp command will need to be added -## in an after_install target. -OTHER_HELP_DIRS = - -# After you have saved your project using the 4.0 PB, you will automatically -# start using the makefiles in $(SYSTEM_DEVELOPER_DIR)/Makefiles/project. If you should -# need to revert back to the old 3.3 Makefile behavior, override MAKEFILEDIR to -# be $(SYSTEM_DEVELOPER_DIR)/Makefiles/app. - -# Don't add more rules here unless you want the first one to be the default -# target for make! Put all your targets in Makefile.postamble. - --include ../Makefile.include -OTHER_INITIAL_TARGETS = fastboot fasthalt diff --git a/fastboot.tproj/PB.project b/fastboot.tproj/PB.project deleted file mode 100644 index fd4d82c..0000000 --- a/fastboot.tproj/PB.project +++ /dev/null @@ -1,44 +0,0 @@ -{ - APPCLASS = NSApplication; - FILESTABLE = { - H_FILES = (); - OTHER_SOURCES = ( - Makefile.preamble, - Makefile, - Makefile.postamble, - Makefile.dist, - fastboot.8, - fastboot.sh, - fasthalt.sh - ); - }; - LANGUAGE = English; - LOCALIZABLE_FILES = {}; - NEXTSTEP_BUILDDIR = ""; - NEXTSTEP_BUILDTOOL = /bin/make; - NEXTSTEP_COMPILEROPTIONS = ""; - NEXTSTEP_INSTALLDIR = "# Set in Makefile"; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_LINKEROPTIONS = ""; - NEXTSTEP_MAINNIB = fastboot; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDDIR = ""; - PDO_UNIX_BUILDTOOL = /bin/make; - PDO_UNIX_COMPILEROPTIONS = ""; - PDO_UNIX_INSTALLDIR = "# Set in Makefile"; - PDO_UNIX_JAVA_COMPILER = "$(NEXTDEV_BIN)/javac"; - PDO_UNIX_LINKEROPTIONS = ""; - PDO_UNIX_MAINNIB = fastboot; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = fastboot; - PROJECTTYPE = Legacy; - PROJECTVERSION = 2.8; - WINDOWS_BUILDDIR = ""; - WINDOWS_BUILDTOOL = /bin/make; - WINDOWS_COMPILEROPTIONS = ""; - WINDOWS_INSTALLDIR = "# Set in Makefile"; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_LINKEROPTIONS = ""; - WINDOWS_MAINNIB = fastboot; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/fastboot.tproj/fastboot.8 b/fastboot.tproj/fastboot.8 deleted file mode 100644 index 2f6ac82..0000000 --- a/fastboot.tproj/fastboot.8 +++ /dev/null @@ -1,69 +0,0 @@ -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)fastboot.8 8.1 (Berkeley) 6/5/93 -.\" -.Dd June 5, 1993 -.Dt FASTBOOT 8 -.Os BSD 4.2 -.Sh NAME -.Nm fastboot , -.Nm fasthalt -.Nd "reboot/halt the system without checking the disks" -.Sh SYNOPSIS -.Nm fastboot -.Op Ar boot-options -.Nm fasthalt -.Op Ar halt-options -.Sh DESCRIPTION -.Nm Fastboot -and -.Nm fasthalt -are shell scripts which reboot and halt the system without -checking the file systems. This is done by creating a -file -.Pa /fastboot , -then invoking the -.Xr reboot -program. The system startup script, -.Pa /etc/rc , -looks for this file and, if present, skips the normal -invocation of -.Xr fsck 8 . -.Sh SEE ALSO -.Xr halt 8 , -.Xr reboot 8 , -.Xr rc 8 -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.2 . diff --git a/fastboot.tproj/fastboot.sh b/fastboot.tproj/fastboot.sh deleted file mode 100644 index 852ec4a..0000000 --- a/fastboot.tproj/fastboot.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 1985, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# @(#)fastboot.sh 8.1 (Berkeley) 6/5/93 -# - -cp /dev/null /fastboot -/sbin/reboot $* diff --git a/fastboot.tproj/fasthalt.sh b/fastboot.tproj/fasthalt.sh deleted file mode 100644 index c8e381f..0000000 --- a/fastboot.tproj/fasthalt.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# @(#)fasthalt.sh 8.1 (Berkeley) 6/5/93 -# - -cp /dev/null /fastboot -/sbin/halt $* diff --git a/fs_usage.tproj/fs_usage.1 b/fs_usage.tproj/fs_usage.1 index dd06a83..cbe57b9 100644 --- a/fs_usage.tproj/fs_usage.1 +++ b/fs_usage.tproj/fs_usage.1 @@ -1,35 +1,38 @@ - .\" Copyright (c) 2000, Apple Computer, Inc. All rights reserved. .\" -.Dd November 26, 2001 +.Dd November 7, 2002 .Dt FS_USAGE 1 .Os "Mac OS X" .Sh NAME .Nm fs_usage -.Nd reports system calls and page faults related to filesystem activity -in real-time. +.Nd report system calls and page faults related to filesystem activity in +real-time .Sh SYNOPSIS -.Nm fs_usage [-e] [-w] [ pid|cmd [pid|cmd] ...] +.Nm fs_usage [-e] [-w] [-f mode] [ pid|cmd [pid|cmd] ...] .Sh DESCRIPTION +The .Nm fs_usage -presents an ongoing display of system call usage -information pertaining to filesystem activity. By default -this includes all system processes except the running -fs_usage process, -Terminal, telnetd, sshd, rlogind, tcsh, csh and sh. -These defaults can be overridden such that output is limited to -include or exclude a list of processes specified by the user. +utility presents an ongoing display of system call usage information +pertaining to filesystem activity. +It requires root privileges due to the kernel tracing facility it uses to +operate. +By default the activity monitored includes all system processes except the +running +.Nm fs_usage +process, Terminal, telnetd, sshd, rlogind, tcsh, csh and sh. +These defaults can be overridden such that output is limited to include or +exclude a list of processes specified by the user. .Pp The output presented by .Nm fs_usage is formatted according to the size of your window. A narrow window will display fewer columns of data. -Use a wide window for maximum data display. You may -override the window formatting restrictions by -forcing a wide display with the +Use a wide window for maximum data display. +You may override the window formatting restrictions by forcing a wide display +with the .Fl w -option. In this case, the data displayed will wrap -when the window is not wide enough. +option. +In this case, the data displayed will wrap when the window is not wide enough. .Pp The options are as follows: .Bl -tag -width Ds @@ -37,45 +40,60 @@ The options are as follows: Specifying the .Fl e option generates output that excludes sampling -of the running fs_usage tool. If a list of -process ids or commands is also given, then -those processes are also excluded from the sampled -output. +of the running fs_usage tool. +If a list of process ids or commands is also given, then those processes are +also excluded from the sampled output. .It Fl w Specifying the .Fl w -option forces a wider, more detailed output, -regardless of the window size. +option forces a wider, more detailed output, regardless of the window size. +.It Fl f +Specifying the +.Fl f +option turns on output filtering based on the +.Pa mode +provided. +By default no filtering occurs. +The supported modes are: +.Pp +.Pa network +Only network related output is displayed. +.Pp +.Pa filesys +Only file system related output is displayed. .It pid | cmd -The sampled data can be limited to a list of process -ids or commands. When a command name is given, all -processes with that name will be sampled. Using the +The sampled data can be limited to a list of process ids or commands. +When a command name is given, all processes with that name will be sampled. +Using the .Fl e -option has the opposite effect, excluding sampled data -relating to the given list of process ids or commands. +option has the opposite effect, excluding sampled data relating to the given +list of process ids or commands. .El .Pp -If you set the DYLD_IMAGE_SUFFIX environment variable -to "_debug", then an application will use -the debug version of all libraries including the -Carbon FileManager. See dyld(1). When -fs_usage is run against a Carbon Application launched -in this environment, then the high level Carbon FileManager -calls will be displayed bracketing the system calls that they -are built on. +If you set the DYLD_IMAGE_SUFFIX environment variable to +.Dq Li _debug , +then an application will use the debug version of all libraries including the +Carbon FileManager. +See +.Xr dyld 1 . +When +.Nm fs_usage +is run against a Carbon Application launched in this environment, then the +high level Carbon FileManager calls will be displayed bracketing the system +calls that they are built on. .Pp The data columns displayed are as follows: -.Bl -tag -width TIME_INTERVALWWWW -compact +.Bl -tag -width Ds .Pp .It TIMESTAMP -TOD when call occurred. Wide mode will -have millisecond granularity. +TOD when call occurred. +Wide mode will have millisecond granularity. .It CALL -the name of the filesystem call, page-in, page-out or physical disk access. +The name of the network or filesystem related call, page-in, page-out or physical disk access. .It FILE DESCRIPTOR -Of the form F=x, x is a file descriptor. Depending -on the type of system call, this will be either -an input value or a return value. +Of the form F=x, x is a file descriptor. +Depending on the type of system call, this will be either an input value or a +return value. .It BYTE COUNT Of the form B=x, x is the number of bytes requested by the call. .It [ERRNO] @@ -83,31 +101,34 @@ On error, the errno is displayed in brackets. .It PATHNAME Pathname of the file accessed (up to the last 28 bytes). .It FAULT ADDRESS -Of the form A=0xnnnnnnnn, where 0xnnnnnnnn is the -address being faulted. +Of the form A=0xnnnnnnnn, where 0xnnnnnnnn is the address being faulted. .It DISK BLOCK NUMBER -Of the form D=0xnnnnnnnn, where 0xnnnnnnnn is the block number -of the physical disk block being read or written. +Of the form D=0xnnnnnnnn, where 0xnnnnnnnn is the block number of the physical +disk block being read or written. +.It SELECT RETURN +Of the form S=x, x is the number of ready descriptors returned by the select() +system call. +If S=0, the time limit expired. .It TIME INTERVAL(W) The elapsed time spent in the system call. -A 'W' after the elapsed time indicates -the process was scheduled out during -this file activity. In this case, the elapsed -time includes the wait time. +A +.Sq Li W +after the elapsed time indicates the process was scheduled out during this file +activity. +In this case, the elapsed time includes the wait time. .It PROCESS NAME The process that made the system call. .El .Pp .Sh SAMPLE USAGE .Pp -fs_usage -w telnetd +fs_usage -w -f filesys Mail .Pp .Nm fs_usage -will report file system usage data for all -instances of processes named telnetd. Maximum -data output will be displayed in the window. +will display file system related data for all instances of processes named Mail. +Maximum data output will be displayed in the window. .Sh SEE ALSO -.Xr top 1 -.Xr sc_usage 1 -.Xr latency 1 +.Xr top 1 , +.Xr sc_usage 1 , +.Xr latency 1 , .Xr dyld 1 diff --git a/fs_usage.tproj/fs_usage.c b/fs_usage.tproj/fs_usage.c index 36f48e3..62ffde9 100644 --- a/fs_usage.tproj/fs_usage.c +++ b/fs_usage.tproj/fs_usage.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ @@ -92,6 +91,7 @@ char *lookup_name(); struct th_info { int in_filemgr; int thread; + int pid; int type; int arg1; int arg2; @@ -118,6 +118,17 @@ int select_pid_mode = 0; /* Flag set indicates that output is restricted int one_good_pid = 0; /* Used to fail gracefully when bad pids given */ +char *arguments = 0; +int argmax = 0; + +/* + * Network only or filesystem only output filter + * Default of zero means report all activity - no filtering + */ +#define FILESYS_FILTER 0x01 +#define NETWORK_FILTER 0x02 +#define DEFAULT_DO_NOT_FILTER 0x0 +int filter_mode = DEFAULT_DO_NOT_FILTER; #define NFS_DEV -1 @@ -153,7 +164,16 @@ void free_diskio(); void print_diskio(); void format_print(); char *find_disk_name(); - +void cache_disk_names(); +int ReadSegAddrTable(); +void mark_thread_waited(int); +int check_filter_mode(struct th_info *, int, int, int); +void fs_usage_fd_set(unsigned int, unsigned int); +int fs_usage_fd_isset(unsigned int, unsigned int); +void fs_usage_fd_clear(unsigned int, unsigned int); +void init_arguments_buffer(); +int get_real_command_name(int, char *, int); +void create_map_entry(int, int, char *); #define DBG_ZERO_FILL_FAULT 1 #define DBG_PAGEIN_FAULT 2 @@ -161,6 +181,7 @@ char *find_disk_name(); #define DBG_CACHE_HIT_FAULT 4 #define TRACE_DATA_NEWTHREAD 0x07000004 +#define TRACE_DATA_EXEC 0x07000008 #define TRACE_STRING_NEWTHREAD 0x07010004 #define TRACE_STRING_EXEC 0x07010008 @@ -199,10 +220,19 @@ char *find_disk_name(); #define MSC_map_fd 0x010c00ac + +// Network related codes #define BSC_recvmsg 0x040C006C #define BSC_sendmsg 0x040C0070 #define BSC_recvfrom 0x040C0074 +#define BSC_accept 0x040C0078 +#define BSC_select 0x040C0174 +#define BSC_socket 0x040C0184 +#define BSC_connect 0x040C0188 +#define BSC_bind 0x040C01A0 +#define BSC_listen 0x040C01A8 #define BSC_sendto 0x040C0214 +#define BSC_socketpair 0x040C021C #define BSC_read 0x040C000C #define BSC_write 0x040C0010 @@ -219,10 +249,12 @@ char *find_disk_name(); #define BSC_chflags 0x040C0088 #define BSC_fchflags 0x040C008C #define BSC_sync 0x040C0090 +#define BSC_dup 0x040C00A4 #define BSC_revoke 0x040C00E0 #define BSC_symlink 0x040C00E4 #define BSC_readlink 0x040C00E8 -#define BSC_chroot 0x040C00F4 +#define BSC_chroot 0x040C00F4 +#define BSC_dup2 0x040C0168 #define BSC_fsync 0x040C017C #define BSC_readv 0x040C01E0 #define BSC_writev 0x040C01E4 @@ -360,10 +392,26 @@ int mib[6]; size_t needed; char *my_buffer; -kbufinfo_t bufinfo = {0, 0, 0, 0}; +kbufinfo_t bufinfo = {0, 0, 0, 0, 0}; int total_threads = 0; -kd_threadmap *mapptr = 0; +kd_threadmap *mapptr = 0; /* pointer to list of threads */ + +/* defines for tracking file descriptor state */ +#define FS_USAGE_FD_SETSIZE 256 /* Initial number of file descriptors per + thread that we will track */ + +#define FS_USAGE_NFDBITS (sizeof (unsigned long) * 8) +#define FS_USAGE_NFDBYTES(n) (((n) / FS_USAGE_NFDBITS) * sizeof (unsigned long)) + +typedef struct { + unsigned int fd_valid; /* set if this is a valid entry */ + unsigned int fd_thread; + unsigned int fd_setsize; /* this is a bit count */ + unsigned long *fd_setptr; /* file descripter bitmap */ +} fd_threadmap; + +fd_threadmap *fdmapptr = 0; /* pointer to list of threads for fd tracking */ int trace_enabled = 0; int set_remove_flag = 1; @@ -421,12 +469,15 @@ void sigwinch() } int -exit_usage(myname) { +exit_usage(char *myname) { - fprintf(stderr, "Usage: %s [-e] [-w] [pid | cmd [pid | cmd]....]\n", myname); + fprintf(stderr, "Usage: %s [-e] [-w] [-f mode] [pid | cmd [pid | cmd]....]\n", myname); fprintf(stderr, " -e exclude the specified list of pids from the sample\n"); fprintf(stderr, " and exclude fs_usage by default\n"); fprintf(stderr, " -w force wider, detailed, output\n"); + fprintf(stderr, " -f Output is filtered based on the mode provided\n"); + fprintf(stderr, " mode = \"network\" Show only network related output\n"); + fprintf(stderr, " mode = \"filesys\" Show only file system related output\n"); fprintf(stderr, " pid selects process(s) to sample\n"); fprintf(stderr, " cmd selects process(s) matching command string to sample\n"); fprintf(stderr, "\n%s will handle a maximum list of %d pids.\n\n", myname, MAX_PIDS); @@ -436,7 +487,7 @@ exit_usage(myname) { exit(1); } - +int main(argc, argv) int argc; char *argv[]; @@ -466,8 +517,9 @@ main(argc, argv) myname++; } } + - while ((ch = getopt(argc, argv, "ew")) != EOF) { + while ((ch = getopt(argc, argv, "ewf:")) != EOF) { switch(ch) { case 'e': exclude_pids = 1; @@ -475,9 +527,16 @@ main(argc, argv) break; case 'w': wideflag = 1; - if (columns < MAX_WIDE_MODE_COLS) + if ((uint)columns < MAX_WIDE_MODE_COLS) columns = MAX_WIDE_MODE_COLS; break; + case 'f': + if (!strcmp(optarg, "network")) + filter_mode |= NETWORK_FILTER; + else if (!strcmp(optarg, "filesys")) + filter_mode |= FILESYS_FILTER; + break; + default: exit_usage(myname); } @@ -566,6 +625,7 @@ main(argc, argv) set_enable(1); getdivisor(); + init_arguments_buffer(); /* main loop */ @@ -623,6 +683,7 @@ struct th_info *find_thread(int thread, int type) { } +void mark_thread_waited(int thread) { struct th_info *ti; @@ -827,6 +888,7 @@ sample_sc() for (i = 0; i < cur_max; i++) { th_state[i].thread = 0; + th_state[i].pid = 0; th_state[i].pathptr = (long *)0; th_state[i].pathname[0] = 0; } @@ -844,7 +906,10 @@ sample_sc() int debugid, thread; int type, n; long *sargptr; - unsigned long long now; + uint64_t now; + long long l_usecs; + int secs; + long curr_time; struct th_info *ti; struct diskio *dio; void enter_syscall(); @@ -855,8 +920,20 @@ sample_sc() debugid = kd[i].debugid; type = kd[i].debugid & DBG_FUNC_MASK; - now = (((unsigned long long)kd[i].timestamp.tv_sec) << 32) | - (unsigned long long)((unsigned int)(kd[i].timestamp.tv_nsec)); + now = kd[i].timestamp; + + if (i == 0) + { + /* + * Compute bias seconds after each trace buffer read. + * This helps resync timestamps with the system clock + * in the event of a system sleep. + */ + l_usecs = (long long)(now / divisor); + secs = l_usecs / 1000000; + curr_time = time((long *)0); + bias_secs = curr_time - secs; + } switch (type) { @@ -888,7 +965,7 @@ sample_sc() case P_WrDataAsyncDone: case P_PgInAsyncDone: case P_PgOutAsyncDone: - if (dio = complete_diskio(kd[i].arg1, kd[i].arg4, kd[i].arg3, thread, (double)now)) { + if ((dio = complete_diskio(kd[i].arg1, kd[i].arg4, kd[i].arg3, thread, (double)now))) { print_diskio(dio); free_diskio(dio); } @@ -896,7 +973,7 @@ sample_sc() case TRACE_DATA_NEWTHREAD: - + for (n = 0, ti = th_state; ti < &th_state[MAX_THREADS]; ti++, n++) { if (ti->thread == 0) break; @@ -908,6 +985,7 @@ sample_sc() ti->thread = thread; ti->child_thread = kd[i].arg1; + ti->pid = kd[i].arg2; continue; case TRACE_STRING_NEWTHREAD: @@ -915,16 +993,44 @@ sample_sc() continue; if (ti->child_thread == 0) continue; - create_map_entry(ti->child_thread, (char *)&kd[i].arg1); + create_map_entry(ti->child_thread, ti->pid, (char *)&kd[i].arg1); if (ti == &th_state[cur_max - 1]) cur_max--; ti->child_thread = 0; ti->thread = 0; + ti->pid = 0; continue; + + case TRACE_DATA_EXEC: + + for (n = 0, ti = th_state; ti < &th_state[MAX_THREADS]; ti++, n++) { + if (ti->thread == 0) + break; + } + if (ti == &th_state[MAX_THREADS]) + continue; + if (n >= cur_max) + cur_max = n + 1; + + ti->thread = thread; + ti->pid = kd[i].arg1; + continue; case TRACE_STRING_EXEC: - create_map_entry(thread, (char *)&kd[i].arg1); + if ((ti = find_thread(thread, 0)) == (struct th_info *)0) + { + /* this is for backwards compatibility */ + create_map_entry(thread, 0, (char *)&kd[i].arg1); + } + else + { + create_map_entry(thread, ti->pid, (char *)&kd[i].arg1); + if (ti == &th_state[cur_max - 1]) + cur_max--; + ti->thread = 0; + ti->pid = 0; + } continue; case BSC_exit: @@ -1206,7 +1312,7 @@ sample_sc() else if (kd[i].arg2 == DBG_CACHE_HIT_FAULT) exit_syscall("CACHE_HIT", thread, type, 0, kd[i].arg1, 0, 2, (double)now); else { - if (ti = find_thread(thread, type)) { + if ((ti = find_thread(thread, type))) { if (ti == &th_state[cur_max - 1]) cur_max--; ti->thread = 0; @@ -1221,7 +1327,7 @@ sample_sc() case BSC_mmap: exit_syscall("mmap", thread, type, kd[i].arg1, kd[i].arg2, 0, 0, (double)now); break; - + case BSC_recvmsg: exit_syscall("recvmsg", thread, type, kd[i].arg1, kd[i].arg2, 1, 1, (double)now); break; @@ -1234,10 +1340,38 @@ sample_sc() exit_syscall("recvfrom", thread, type, kd[i].arg1, kd[i].arg2, 1, 1, (double)now); break; + case BSC_accept: + exit_syscall("accept", thread, type, kd[i].arg1, kd[i].arg2, 2, 0, (double)now); + break; + + case BSC_select: + exit_syscall("select", thread, type, kd[i].arg1, kd[i].arg2, 0, 8, (double)now); + break; + + case BSC_socket: + exit_syscall("socket", thread, type, kd[i].arg1, kd[i].arg2, 2, 0, (double)now); + break; + + case BSC_connect: + exit_syscall("connect", thread, type, kd[i].arg1, kd[i].arg2, 1, 0, (double)now); + break; + + case BSC_bind: + exit_syscall("bind", thread, type, kd[i].arg1, kd[i].arg2, 1, 0, (double)now); + break; + + case BSC_listen: + exit_syscall("listen", thread, type, kd[i].arg1, kd[i].arg2, 1, 0, (double)now); + break; + case BSC_sendto: exit_syscall("sendto", thread, type, kd[i].arg1, kd[i].arg2, 1, 1, (double)now); break; + case BSC_socketpair: + exit_syscall("socketpair", thread, type, kd[i].arg1, kd[i].arg2, 0, 0, (double)now); + break; + case BSC_stat: exit_syscall("stat", thread, type, kd[i].arg1, kd[i].arg2, 0, 0, (double)now); break; @@ -1250,6 +1384,14 @@ sample_sc() exit_syscall("open", thread, type, kd[i].arg1, kd[i].arg2, 2, 0, (double)now); break; + case BSC_dup: + exit_syscall("dup", thread, type, kd[i].arg1, kd[i].arg2, 2, 0, (double)now); + break; + + case BSC_dup2: + exit_syscall("dup2", thread, type, kd[i].arg1, kd[i].arg2, 2, 0, (double)now); + break; + case BSC_close: exit_syscall("close", thread, type, kd[i].arg1, kd[i].arg2, 1, 0, (double)now); break; @@ -1695,10 +1837,19 @@ enter_syscall(int thread, int type, kd_buf *kd, char *name, double now) case BSC_recvmsg: case BSC_sendmsg: case BSC_recvfrom: + case BSC_accept: + case BSC_select: + case BSC_socket: + case BSC_connect: + case BSC_bind: + case BSC_listen: case BSC_sendto: + case BSC_socketpair: case BSC_stat: case BSC_load_shared_file: case BSC_open: + case BSC_dup: + case BSC_dup2: case BSC_close: case BSC_read: case BSC_write: @@ -1836,12 +1987,8 @@ enter_syscall(int thread, int type, kd_buf *kd, char *name, double now) l_usecs = (long long)(now / divisor); secs = l_usecs / 1000000; - - if (bias_secs == 0) { - curr_time = time((long *)0); - bias_secs = curr_time - secs; - } curr_time = bias_secs + secs; + sprintf(buf, "%-8.8s", &(ctime(&curr_time)[11])); tsclen = strlen(buf); @@ -1924,8 +2071,9 @@ exit_syscall(char *sc_name, int thread, int type, int error, int retval, if ((ti = find_thread(thread, type)) == (struct th_info *)0) return; - - format_print(ti, sc_name, thread, type, error, retval, has_fd, has_ret, now, ti->stime, ti->waited, ti->pathname, NULL); + + if (check_filter_mode(ti, type, error, retval)) + format_print(ti, sc_name, thread, type, error, retval, has_fd, has_ret, now, ti->stime, ti->waited, ti->pathname, NULL); if (ti == &th_state[cur_max - 1]) cur_max--; @@ -1956,16 +2104,12 @@ format_print(struct th_info *ti, char *sc_name, int thread, int type, int error, if (dio) command_name = dio->issuing_command; else { - if (map = find_thread_map(thread)) + if ((map = find_thread_map(thread))) command_name = map->command; } + l_usecs = (long long)(now / divisor); secs = l_usecs / 1000000; - - if (bias_secs == 0) { - curr_time = time((long *)0); - bias_secs = curr_time - secs; - } curr_time = bias_secs + secs; sprintf(buf, "%-8.8s", &(ctime(&curr_time)[11])); clen = strlen(buf); @@ -2033,6 +2177,8 @@ format_print(struct th_info *ti, char *sc_name, int thread, int type, int error, sprintf(&buf[clen], " B=0x%-6x", retval); else if (has_ret == 4) sprintf(&buf[clen], "B=0x%-8x", retval); + else if (has_ret == 8) /* BSC_select */ + sprintf(&buf[clen], " S=%-3d ", retval); else sprintf(&buf[clen], " "); } @@ -2144,51 +2290,113 @@ void getdivisor() void read_command_map() { size_t size; + int i; + int prev_total_threads; int mib[6]; if (mapptr) { free(mapptr); mapptr = 0; } + + prev_total_threads = total_threads; total_threads = bufinfo.nkdthreads; size = bufinfo.nkdthreads * sizeof(kd_threadmap); if (size) { - if (mapptr = (kd_threadmap *) malloc(size)) + if ((mapptr = (kd_threadmap *) malloc(size))) + { bzero (mapptr, size); - else - return; - } - /* Now read the threadmap */ - mib[0] = CTL_KERN; - mib[1] = KERN_KDEBUG; - mib[2] = KERN_KDTHRMAP; - mib[3] = 0; - mib[4] = 0; - mib[5] = 0; /* no flags */ - if (sysctl(mib, 3, mapptr, &size, NULL, 0) < 0) + /* Now read the threadmap */ + mib[0] = CTL_KERN; + mib[1] = KERN_KDEBUG; + mib[2] = KERN_KDTHRMAP; + mib[3] = 0; + mib[4] = 0; + mib[5] = 0; /* no flags */ + if (sysctl(mib, 3, mapptr, &size, NULL, 0) < 0) + { + /* This is not fatal -- just means I cant map command strings */ + free(mapptr); + mapptr = 0; + } + } + } + + if (mapptr && (filter_mode != DEFAULT_DO_NOT_FILTER)) { - /* This is not fatal -- just means I cant map command strings */ - free(mapptr); - mapptr = 0; + if (fdmapptr) + { + /* We accept the fact that we lose file descriptor state if the + kd_buffer wraps */ + for (i = 0; i < prev_total_threads; i++) + { + if (fdmapptr[i].fd_setptr) + free (fdmapptr[i].fd_setptr); + } + free(fdmapptr); + fdmapptr = 0; + } + + size = total_threads * sizeof(fd_threadmap); + if ((fdmapptr = (fd_threadmap *) malloc(size))) + { + bzero (fdmapptr, size); + /* reinitialize file descriptor state map */ + for (i = 0; i < total_threads; i++) + { + fdmapptr[i].fd_thread = mapptr[i].thread; + fdmapptr[i].fd_valid = mapptr[i].valid; + fdmapptr[i].fd_setsize = 0; + fdmapptr[i].fd_setptr = 0; + } + } + } + + /* Resolve any LaunchCFMApp command names */ + if (mapptr && arguments) + { + for (i=0; i < total_threads; i++) + { + int pid; + + pid = mapptr[i].valid; + + if (pid == 0 || pid == 1) + continue; + else if (!strncmp(mapptr[i].command,"LaunchCFMA", 10)) + { + (void)get_real_command_name(pid, mapptr[i].command, sizeof(mapptr[i].command)); + } + } } } -void create_map_entry(int thread, char *command) +void create_map_entry(int thread, int pid, char *command) { int i, n; kd_threadmap *map; + fd_threadmap *fdmap = 0; if (!mapptr) return; for (i = 0, map = 0; !map && i < total_threads; i++) { - if (mapptr[i].thread == thread ) - map = &mapptr[i]; /* Reuse this entry, the thread has been reassigned */ + if ((int)mapptr[i].thread == thread ) + { + map = &mapptr[i]; /* Reuse this entry, the thread has been + * reassigned */ + if(filter_mode && fdmapptr) + { + fdmap = &fdmapptr[i]; + if (fdmap->fd_thread != thread) /* This shouldn't happen */ + fdmap = (fd_threadmap *)0; + } + } } if (!map) /* look for invalid entries that I can reuse*/ @@ -2197,6 +2405,10 @@ void create_map_entry(int thread, char *command) { if (mapptr[i].valid == 0 ) map = &mapptr[i]; /* Reuse this invalid entry */ + if (filter_mode && fdmapptr) + { + fdmap = &fdmapptr[i]; + } } } @@ -2211,6 +2423,14 @@ void create_map_entry(int thread, char *command) mapptr = (kd_threadmap *) realloc(mapptr, n * sizeof(kd_threadmap)); bzero(&mapptr[total_threads], total_threads*sizeof(kd_threadmap)); map = &mapptr[total_threads]; + + if (filter_mode && fdmapptr) + { + fdmapptr = (fd_threadmap *)realloc(fdmapptr, n * sizeof(fd_threadmap)); + bzero(&fdmapptr[total_threads], total_threads*sizeof(fd_threadmap)); + fdmap = &fdmapptr[total_threads]; + } + total_threads = n; } @@ -2223,6 +2443,23 @@ void create_map_entry(int thread, char *command) */ (void)strncpy (map->command, command, MAXCOMLEN); map->command[MAXCOMLEN] = '\0'; + + if (fdmap) + { + fdmap->fd_valid = 1; + fdmap->fd_thread = thread; + if (fdmap->fd_setptr) + { + free(fdmap->fd_setptr); + fdmap->fd_setptr = (unsigned long *)0; + } + fdmap->fd_setsize = 0; + } + + if (pid == 0 || pid == 1) + return; + else if (!strncmp(map->command, "LaunchCFMA", 10)) + (void)get_real_command_name(pid, map->command, sizeof(map->command)); } @@ -2237,7 +2474,7 @@ kd_threadmap *find_thread_map(int thread) for (i = 0; i < total_threads; i++) { map = &mapptr[i]; - if (map->valid && (map->thread == thread)) + if (map->valid && ((int)map->thread == thread)) { return(map); } @@ -2245,17 +2482,52 @@ kd_threadmap *find_thread_map(int thread) return ((kd_threadmap *)0); } +fd_threadmap *find_fd_thread_map(int thread) +{ + int i; + fd_threadmap *fdmap = 0; + + if (!fdmapptr) + return((fd_threadmap *)0); + + for (i = 0; i < total_threads; i++) + { + fdmap = &fdmapptr[i]; + if (fdmap->fd_valid && ((int)fdmap->fd_thread == thread)) + { + return(fdmap); + } + } + return ((fd_threadmap *)0); +} + void kill_thread_map(int thread) { kd_threadmap *map; + fd_threadmap *fdmap; - if (map = find_thread_map(thread)) { + if ((map = find_thread_map(thread))) { map->valid = 0; map->thread = 0; map->command[0] = '\0'; } + + if (filter_mode) + { + if ((fdmap = find_fd_thread_map(thread))) + { + fdmap->fd_valid = 0; + fdmap->fd_thread = 0; + if (fdmap->fd_setptr) + { + free (fdmap->fd_setptr); + fdmap->fd_setptr = (unsigned long *)0; + } + fdmap->fd_setsize = 0; + } + } } void @@ -2359,7 +2631,6 @@ int ReadSegAddrTable() int ntokens; char *substring,*ptr; int founddylib = 0; - int i; bzero(buf, sizeof(buf)); @@ -2438,7 +2709,7 @@ int ReadSegAddrTable() /* * Extract lib name from path name */ - if (substring = strrchr(tokens[2], '.')) + if ((substring = strrchr(tokens[2], '.'))) { /* * There is a ".": name is whatever is between the "/" around the "." @@ -2496,7 +2767,7 @@ struct diskio *insert_diskio(int type, int bp, int dev, int blkno, int io_size, register struct diskio *dio; register kd_threadmap *map; - if (dio = free_diskios) + if ((dio = free_diskios)) free_diskios = dio->next; else { if ((dio = (struct diskio *)malloc(sizeof(struct diskio))) == NULL) @@ -2512,8 +2783,11 @@ struct diskio *insert_diskio(int type, int bp, int dev, int blkno, int io_size, dio->issued_time = curtime; dio->issuing_thread = thread; - if (map = find_thread_map(thread)) - strcpy(dio->issuing_command, map->command); + if ((map = find_thread_map(thread))) + { + strncpy(dio->issuing_command, map->command, MAXCOMLEN); + dio->issuing_command[MAXCOMLEN-1] = '\0'; + } else strcpy(dio->issuing_command, ""); @@ -2534,7 +2808,7 @@ struct diskio *complete_diskio(int bp, int io_errno, int resid, int thread, doub if (dio->bp == bp) { if (dio == busy_diskios) { - if (busy_diskios = dio->next) + if ((busy_diskios = dio->next)) dio->next->prev = NULL; } else { if (dio->next) @@ -2563,7 +2837,6 @@ void free_diskio(struct diskio *dio) void print_diskio(struct diskio *dio) { register char *p; - struct th_info *ti; switch (dio->type) { @@ -2603,13 +2876,16 @@ void print_diskio(struct diskio *dio) case P_PgOutAsync: p = " PgOut[async]"; break; - + default: + p = " "; + break; } - format_print(NULL, p, dio->issuing_thread, dio->type, 0, 0, 0, 7, dio->completed_time, dio->issued_time, 1, "", dio); + if (check_filter_mode(NULL, dio->type,0, 0)) + format_print(NULL, p, dio->issuing_thread, dio->type, 0, 0, 0, 7, dio->completed_time, dio->issued_time, 1, "", dio); } -cache_disk_names() +void cache_disk_names() { struct stat st; DIR *dirp = NULL; @@ -2661,3 +2937,312 @@ char *find_disk_name(int dev) } return ("NOTFOUND"); } + +void +fs_usage_fd_set(thread, fd) + unsigned int thread; + unsigned int fd; +{ + int n; + fd_threadmap *fdmap; + + if(!(fdmap = find_fd_thread_map(thread))) + return; + + /* If the map is not allocated, then now is the time */ + if (fdmap->fd_setptr == (unsigned long *)0) + { + fdmap->fd_setptr = (unsigned long *)malloc(FS_USAGE_NFDBYTES(FS_USAGE_FD_SETSIZE)); + if (fdmap->fd_setptr) + { + fdmap->fd_setsize = FS_USAGE_FD_SETSIZE; + bzero(fdmap->fd_setptr,(FS_USAGE_NFDBYTES(FS_USAGE_FD_SETSIZE))); + } + else + return; + } + + /* If the map is not big enough, then reallocate it */ + while (fdmap->fd_setsize < fd) + { + printf("reallocating bitmap for threadid %d, fd = %d, setsize = %d\n", + thread, fd, fdmap->fd_setsize); + n = fdmap->fd_setsize * 2; + fdmap->fd_setptr = (unsigned long *)realloc(fdmap->fd_setptr, (FS_USAGE_NFDBYTES(n))); + bzero(&fdmap->fd_setptr[(fdmap->fd_setsize/FS_USAGE_NFDBITS)], (FS_USAGE_NFDBYTES(fdmap->fd_setsize))); + fdmap->fd_setsize = n; + } + + /* set the bit */ + fdmap->fd_setptr[fd/FS_USAGE_NFDBITS] |= (1 << ((fd) % FS_USAGE_NFDBITS)); + + return; +} + +/* + Return values: + 0 : File Descriptor bit is not set + 1 : File Descriptor bit is set +*/ + +int +fs_usage_fd_isset(thread, fd) + unsigned int thread; + unsigned int fd; +{ + int ret = 0; + fd_threadmap *fdmap; + + if(!(fdmap = find_fd_thread_map(thread))) + return(ret); + + if (fdmap->fd_setptr == (unsigned long *)0) + return (ret); + + if (fd < fdmap->fd_setsize) + ret = fdmap->fd_setptr[fd/FS_USAGE_NFDBITS] & (1 << (fd % FS_USAGE_NFDBITS)); + + return (ret); +} + +void +fs_usage_fd_clear(thread, fd) + unsigned int thread; + unsigned int fd; +{ + fd_threadmap *map; + + if (!(map = find_fd_thread_map(thread))) + return; + + if (map->fd_setptr == (unsigned long *)0) + return; + + /* clear the bit */ + if (fd < map->fd_setsize) + map->fd_setptr[fd/FS_USAGE_NFDBITS] &= ~(1 << (fd % FS_USAGE_NFDBITS)); + + return; +} + + +/* + * ret = 1 means print the entry + * ret = 0 means don't print the entry + */ +int +check_filter_mode(struct th_info * ti, int type, int error, int retval) +{ + int ret = 0; + int network_fd_isset = 0; + unsigned int fd; + + if (filter_mode == DEFAULT_DO_NOT_FILTER) + return(1); + + if (ti == (struct th_info *)0) + { + if(filter_mode & FILESYS_FILTER) + ret = 1; + else + ret = 0; + return(ret); + } + + + switch (type) { + case BSC_close: + fd = ti->arg1; + network_fd_isset = fs_usage_fd_isset(ti->thread, fd); + if (error == 0) + { + fs_usage_fd_clear(ti->thread,fd); + } + + if (network_fd_isset) + { + if (filter_mode & NETWORK_FILTER) + ret = 1; + } + else if (filter_mode & FILESYS_FILTER) + ret = 1; + break; + case BSC_read: + case BSC_write: + /* we don't care about error in this case */ + fd = ti->arg1; + network_fd_isset = fs_usage_fd_isset(ti->thread, fd); + if (network_fd_isset) + { + if (filter_mode & NETWORK_FILTER) + ret = 1; + } + else if (filter_mode & FILESYS_FILTER) + ret = 1; + break; + case BSC_accept: + case BSC_socket: + fd = retval; + if (error == 0) + fs_usage_fd_set(ti->thread, fd); + if (filter_mode & NETWORK_FILTER) + ret = 1; + break; + case BSC_recvfrom: + case BSC_sendto: + case BSC_recvmsg: + case BSC_sendmsg: + case BSC_connect: + case BSC_bind: + case BSC_listen: + fd = ti->arg1; + if (error == 0) + fs_usage_fd_set(ti->thread, fd); + if (filter_mode & NETWORK_FILTER) + ret = 1; + break; + case BSC_select: + case BSC_socketpair: + /* Cannot determine info about file descriptors */ + if (filter_mode & NETWORK_FILTER) + ret = 1; + break; + case BSC_dup: + case BSC_dup2: + ret=0; /* We track these cases for fd state only */ + fd = ti->arg1; /* oldd */ + network_fd_isset = fs_usage_fd_isset(ti->thread, fd); + if (error == 0 && network_fd_isset) + { + /* then we are duping a socket descriptor */ + fd = retval; /* the new fd */ + fs_usage_fd_set(ti->thread, fd); + } + break; + + default: + if (filter_mode & FILESYS_FILTER) + ret = 1; + break; + } + + return(ret); +} + +/* + * Allocate a buffer that is large enough to hold the maximum arguments + * to execve(). This is used when getting the arguments to programs + * when we see LaunchCFMApps. If this fails, it is not fatal, we will + * simply not resolve the command name. + */ + +void +init_arguments_buffer() +{ + + int mib[2]; + size_t size; + + mib[0] = CTL_KERN; + mib[1] = KERN_ARGMAX; + size = sizeof(argmax); + if (sysctl(mib, 2, &argmax, &size, NULL, 0) == -1) + return; + +#if 1 + /* Hack to avoid kernel bug. */ + if (argmax > 8192) { + argmax = 8192; + } +#endif + + arguments = (char *)malloc(argmax); + + return; +} + + +int +get_real_command_name(int pid, char *cbuf, int csize) +{ + /* + * Get command and arguments. + */ + char *cp; + int mib[4]; + char *command_beg, *command, *command_end; + + if (cbuf == NULL) { + return(0); + } + + if (arguments) + bzero(arguments, argmax); + else + return(0); + + /* + * A sysctl() is made to find out the full path that the command + * was called with. + */ + mib[0] = CTL_KERN; + mib[1] = KERN_PROCARGS; + mib[2] = pid; + mib[3] = 0; + + if (sysctl(mib, 3, arguments, (size_t *)&argmax, NULL, 0) < 0) { + return(0); + } + + /* Skip the saved exec_path. */ + for (cp = arguments; cp < &arguments[argmax]; cp++) { + if (*cp == '\0') { + /* End of exec_path reached. */ + break; + } + } + if (cp == &arguments[argmax]) { + return(0); + } + + /* Skip trailing '\0' characters. */ + for (; cp < &arguments[argmax]; cp++) { + if (*cp != '\0') { + /* Beginning of first argument reached. */ + break; + } + } + if (cp == &arguments[argmax]) { + return(0); + } + command_beg = cp; + + /* + * Make sure that the command is '\0'-terminated. This protects + * against malicious programs; under normal operation this never + * ends up being a problem.. + */ + for (; cp < &arguments[argmax]; cp++) { + if (*cp == '\0') { + /* End of first argument reached. */ + break; + } + } + if (cp == &arguments[argmax]) { + return(0); + } + command_end = command = cp; + + /* Get the basename of command. */ + for (command--; command >= command_beg; command--) { + if (*command == '/') { + command++; + break; + } + } + + (void) strncpy(cbuf, (char *)command, csize); + cbuf[csize-1] = '\0'; + + return(1); +} diff --git a/getty.tproj/extern.h b/getty.tproj/extern.h index 37241b8..f8e759a 100644 --- a/getty.tproj/extern.h +++ b/getty.tproj/extern.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/getty.tproj/gettytab.h b/getty.tproj/gettytab.h index 0d869e2..2fcd79c 100644 --- a/getty.tproj/gettytab.h +++ b/getty.tproj/gettytab.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/getty.tproj/init.c b/getty.tproj/init.c index b5b6581..99c980a 100644 --- a/getty.tproj/init.c +++ b/getty.tproj/init.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/getty.tproj/main.c b/getty.tproj/main.c index cafc07d..ee934ae 100644 --- a/getty.tproj/main.c +++ b/getty.tproj/main.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ @@ -63,7 +62,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)main.c 8.1 (Berkeley) 6/20/93";*/ -static char rcsid[] = "$Id: main.c,v 1.1.1.2 2000/01/11 02:10:14 wsanchez Exp $"; +static char rcsid[] = "$Id: main.c,v 1.2 2003/05/30 18:10:02 rbraun Exp $"; #endif /* not lint */ #include @@ -347,7 +346,7 @@ main(argc, argv) limit.rlim_max = RLIM_INFINITY; limit.rlim_cur = RLIM_INFINITY; (void)setrlimit(RLIMIT_CPU, &limit); - execle(LO, "login", "-p", name, (char *) 0, env); + execle(LO, "login", "-p1", name, (char *) 0, env); syslog(LOG_ERR, "%s: %m", LO); exit(1); } diff --git a/getty.tproj/pathnames.h b/getty.tproj/pathnames.h index 1cf18ea..909042a 100644 --- a/getty.tproj/pathnames.h +++ b/getty.tproj/pathnames.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/getty.tproj/subr.c b/getty.tproj/subr.c index cd9aca9..d3322b6 100644 --- a/getty.tproj/subr.c +++ b/getty.tproj/subr.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/halt.tproj/Makefile b/halt.tproj/Makefile deleted file mode 100644 index a731515..0000000 --- a/halt.tproj/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -# -# Generated by the NeXT Project Builder. -# -# NOTE: Do NOT change this file -- Project Builder maintains it. -# -# Put all of your customizations in files called Makefile.preamble -# and Makefile.postamble (both optional), and Makefile will include them. -# - -NAME = halt - -PROJECTVERSION = 2.8 -PROJECT_TYPE = Tool - -CFILES = halt.c - -OTHERSRCS = Makefile.preamble Makefile halt.8 Makefile.dist - - -MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles -CODE_GEN_STYLE = DYNAMIC -MAKEFILE = tool.make -NEXTSTEP_INSTALLDIR = /sbin -WINDOWS_INSTALLDIR = /sbin -PDO_UNIX_INSTALLDIR = /sbin -LIBS = -DEBUG_LIBS = $(LIBS) -PROF_LIBS = $(LIBS) - - - - -NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc -WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc -PDO_UNIX_OBJCPLUS_COMPILER = $(NEXTDEV_BIN)/gcc -NEXTSTEP_JAVA_COMPILER = /usr/bin/javac -WINDOWS_JAVA_COMPILER = $(JDKBINDIR)/javac.exe -PDO_UNIX_JAVA_COMPILER = $(NEXTDEV_BIN)/javac - -include $(MAKEFILEDIR)/platform.make - --include Makefile.preamble - -include $(MAKEFILEDIR)/$(MAKEFILE) - --include Makefile.postamble - --include Makefile.dependencies diff --git a/halt.tproj/Makefile.dist b/halt.tproj/Makefile.dist deleted file mode 100644 index 52b2af8..0000000 --- a/halt.tproj/Makefile.dist +++ /dev/null @@ -1,9 +0,0 @@ -# from: @(#)Makefile 5.3 (Berkeley) 5/11/90 -# $Id: Makefile.dist,v 1.1.1.1 1999/05/02 04:21:30 wsanchez Exp $ - -PROG= halt -MAN8= halt.0 -DPADD= ${LIBUTIL} -LDADD= -lutil - -.include diff --git a/halt.tproj/Makefile.preamble b/halt.tproj/Makefile.preamble deleted file mode 100644 index b7b38d0..0000000 --- a/halt.tproj/Makefile.preamble +++ /dev/null @@ -1,3 +0,0 @@ -CLEAN_ALL_SUBPROJECTS = YES -OTHER_GENERATED_OFILES = $(VERS_OFILE) - diff --git a/halt.tproj/PB.project b/halt.tproj/PB.project deleted file mode 100644 index 0ceaecf..0000000 --- a/halt.tproj/PB.project +++ /dev/null @@ -1,37 +0,0 @@ -{ - FILESTABLE = { - C_FILES = (); - H_FILES = (); - M_FILES = (); - OTHER_LIBS = (); - OTHER_LINKED = (halt.c); - OTHER_SOURCES = (Makefile.preamble, Makefile, halt.8, Makefile.dist); - SUBPROJECTS = (); - }; - LANGUAGE = English; - LOCALIZABLE_FILES = {}; - NEXTSTEP_BUILDDIR = ""; - NEXTSTEP_BUILDTOOL = /bin/make; - NEXTSTEP_COMPILEROPTIONS = ""; - NEXTSTEP_INSTALLDIR = /sbin; - NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; - NEXTSTEP_LINKEROPTIONS = ""; - NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDDIR = ""; - PDO_UNIX_BUILDTOOL = /bin/make; - PDO_UNIX_COMPILEROPTIONS = ""; - PDO_UNIX_INSTALLDIR = /sbin; - PDO_UNIX_JAVA_COMPILER = "$(NEXTDEV_BIN)/javac"; - PDO_UNIX_LINKEROPTIONS = ""; - PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = halt; - PROJECTTYPE = Tool; - PROJECTVERSION = 2.8; - WINDOWS_BUILDDIR = ""; - WINDOWS_BUILDTOOL = /bin/make; - WINDOWS_COMPILEROPTIONS = ""; - WINDOWS_INSTALLDIR = /sbin; - WINDOWS_JAVA_COMPILER = "$(JDKBINDIR)/javac.exe"; - WINDOWS_LINKEROPTIONS = ""; - WINDOWS_OBJCPLUS_COMPILER = "$(DEVDIR)/gcc"; -} diff --git a/halt.tproj/halt.8 b/halt.tproj/halt.8 deleted file mode 100644 index a6e5726..0000000 --- a/halt.tproj/halt.8 +++ /dev/null @@ -1,86 +0,0 @@ -.\" Copyright (c) 1980, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)halt.8 6.5 (Berkeley) 3/16/91 -.\" $Id: halt.8,v 1.1.1.1 1999/05/02 04:21:30 wsanchez Exp $ -.\" -.Dd March 16, 1991 -.Dt HALT 8 -.Os BSD 4 -.Sh NAME -.Nm halt -.Nd stop the processor -.Sh SYNOPSIS -.Nm halt -.Op Fl n -.Op Fl q -.Op Fl y -.Sh DESCRIPTION -.Nm Halt -writes out sandbagged information to the disks and then stops -the processor. The machine does not reboot, even if the auto-reboot -switch is set on the console. -.Pp -Available options for -.Nm halt : -.Bl -tag -width Ds -.It Fl n -No sync before stopping. -.It Fl q -Quick halt, no graceful shutdown is attempted. -.It Fl y -This option is needed if you are trying to halt the system from a dialup. -.El -.Pp -.Nm Halt -normally logs the shutdown using -.Xr syslog 8 -and places a shutdown record in the login accounting file -.Pa /var/log/wtmp. -These actions are inhibited if the -.Fl n -or -.Fl q -options are present. -.Sh SEE ALSO -.Xr reboot 8 , -.Xr shutdown 8 , -.Xr syslogd 8 -.Sh BUGS -It is very difficult to halt a -.Tn VAX , -as the machine wants to then -reboot itself. A rather tight loop suffices. -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.0 . diff --git a/halt.tproj/halt.c b/halt.tproj/halt.c deleted file mode 100644 index b4a975b..0000000 --- a/halt.tproj/halt.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* - * Copyright (c) 1980, 1986 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -char copyright[] = -"@(#) Copyright (c) 1980, 1986 The Regents of the University of California.\n\ - All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)halt.c 5.10 (Berkeley) 4/3/91";*/ -static char rcsid[] = "$Id: halt.c,v 1.1.1.2 2000/01/11 02:10:15 wsanchez Exp $"; -#endif /* not lint */ - -/* - * Halt - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -main(argc, argv) - int argc; - char **argv; -{ - register int i; - register int qflag = 0; - struct passwd *pw; - int ch, howto, needlog = 1; - char *user, *ttyn, *getlogin(), *ttyname(); - - howto = RB_HALT; - ttyn = ttyname(2); - while ((ch = getopt(argc, argv, "lnqy")) != EOF) - switch((char)ch) { - case 'l': /* undocumented; for shutdown(8) */ - needlog = 0; - break; - case 'n': - howto |= RB_NOSYNC; - break; - case 'q': - qflag++; - break; - case 'y': - ttyn = 0; - break; - case '?': - default: - fprintf(stderr, "usage: halt [-nqy]\n"); - exit(1); - } - - if (ttyn && ttyn[sizeof(_PATH_TTY) - 1] == 'd') { - fprintf(stderr, "halt: dangerous on a dialup; use ``halt -y'' if you are really sure\n"); - exit(1); - } - - if (needlog) { - openlog("halt", 0, LOG_AUTH); - if ((user = getlogin()) == NULL) - if ((pw = getpwuid(getuid()))) - user = pw->pw_name; - else - user = "???"; - syslog(LOG_CRIT, "halted by %s", user); - } - - signal(SIGHUP, SIG_IGN); /* for network connections */ - if (kill(1, SIGTSTP) == -1) { - fprintf(stderr, "halt: can't idle init\n"); - exit(1); - } -#if 0 - sleep(1); - (void) kill(-1, SIGTERM); /* one chance to catch it */ - sleep(5); - - if (!qflag) for (i = 1; ; i++) { - if (kill(-1, SIGKILL) == -1) { - extern int errno; - - if (errno == ESRCH) - break; - - perror("halt: kill"); - kill(1, SIGHUP); - exit(1); - } - if (i > 5) { - fprintf(stderr, - "CAUTION: some process(es) wouldn't die\n"); - break; - } - setalarm(2 * i); - pause(); - } - if (!qflag && (howto & RB_NOSYNC) == 0) { - logwtmp("~", "shutdown", ""); - sync(); - setalarm(5); - pause(); - } -#endif - reboot(howto); - perror("halt"); -} - -void -dingdong() -{ - /* RRRIIINNNGGG RRRIIINNNGGG */ -} - -setalarm(n) - int n; -{ - signal(SIGALRM, dingdong); - alarm(n); -} diff --git a/hostinfo.tproj/hostinfo.c b/hostinfo.tproj/hostinfo.c index b228499..ee9b6dc 100644 --- a/hostinfo.tproj/hostinfo.c +++ b/hostinfo.tproj/hostinfo.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/init.tproj/init.c b/init.tproj/init.c index 6027707..b5b0979 100644 --- a/init.tproj/init.c +++ b/init.tproj/init.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/init.tproj/pathnames.h b/init.tproj/pathnames.h index ac36be9..777fe14 100644 --- a/init.tproj/pathnames.h +++ b/init.tproj/pathnames.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/iostat.tproj/Makefile.postamble b/iostat.tproj/Makefile.postamble index e2b071c..a3600ab 100644 --- a/iostat.tproj/Makefile.postamble +++ b/iostat.tproj/Makefile.postamble @@ -1,109 +1,6 @@ -############################################################################### -# NeXT Makefile.postamble Template -# Copyright 1993, NeXT Computer, Inc. -# -# This Makefile is used for configuring the standard app makefiles associated -# with ProjectBuilder. -# -# Use this template to set attributes for a project, sub-project, bundle, or -# palette. Each node in the project's tree of sub-projects and bundles -# should have it's own Makefile.preamble and Makefile.postamble. Additional -# rules (e.g., after_install) that are defined by the developer should be -# defined in this file. -# -############################################################################### -# -# Here are the variables exported by the common "app" makefiles that can be -# used in any customizations you make to the template below: -# -# PRODUCT_ROOT - Name of top-level app-wrapper (e.g., Webster.app) -# OFILE_DIR - Directory into which .o object files are generated. -# (Note that this name is calculated based on the target -# architectures specified in Project Builder). -# DERIVED_SRC_DIR - Directory used for all other derived files -# ALL_CFLAGS - All the flags passed to the cc(1) driver for compilations -# -# NAME - name of application, bundle, subproject, palette, etc. -# LANGUAGE - langage in which the project is written (default "English") -# ENGLISH - boolean flag set iff $(LANGUAGE) = "English" -# JAPANESE - boolean flag set iff $(LANGUAGE) = "Japanese" -# LOCAL_RESOURCES - localized resources (e.g. nib's, images) of project -# GLOBAL_RESOURCES - non-localized resources of project -# PROJECTVERSION - version of ProjectBuilder that output Makefile -# APPICON - application icon file -# DOCICONS - dock icon files -# ICONSECTIONS - Specifies icon sections when linking executable -# -# CLASSES - Class implementation files in project. -# HFILES - Header files in project. -# MFILES - Other Objective-C source files in project. -# CFILES - Other C source files in project. -# PSWFILES - .psw files in the project -# PSWMFILES - .pswm files in the project -# SUBPROJECTS - Subprojects of this project -# BUNDLES - Bundle subprojects of this project -# OTHERSRCS - Other miscellaneous sources of this project -# OTHERLINKED - Source files not matching a standard source extention -# -# LIBS - Libraries to link with when making app target -# DEBUG_LIBS - Libraries to link with when making debug target -# PROF_LIBS - Libraries to link with when making profile target -# OTHERLINKEDOFILES - Other relocatable files to (always) link in. -# -# APP_MAKEFILE_DIR - Directory in which to find generic set of Makefiles -# MAKEFILEDIR - Directory in which to find $(MAKEFILE) -# MAKEFILE - Top level mechanism Makefile (e.g., app.make, bundle.make) -# INSTALLDIR - Directory app will be installed into by 'install' target +# This is modeled after the postamble script found in the +# system_cmds/ktrace.tproj/Makefile.postamble script - -# Change defaults assumed by the standard app makefiles here. Edit the -# following default values as appropriate. (Note that if no Makefile.postamble -# exists, these values will have defaults set in common.make). - -# Add Makefile.preamble, Makefile.postamble, and Makefile.dependencies here if -# you would like changes to them to invalidate previous builds. The project -# depends on $(MAKEFILES) so that changes to Makefiles will trigger a re-build. -#MAKEFILES = Makefile - -# Optimization flag passed to compiler: -#OPTIMIZATION_CFLAG = -O - -# Flags always passed to compiler: -#COMMON_CFLAGS = $(PROJECT_SPECIFIC_CFLAGS) -g -Wall - -# Flags passed to compiler in normal 'app' compiles: -#NORMAL_CFLAGS = $(COMMON_CFLAGS) $(OPTIMIZATION_CFLAG) - -# Flags passed to compiler in 'debug' compiles: -#DEBUG_CFLAGS = $(COMMON_CFLAGS) -DDEBUG - -# Flags passed to compiler in 'profile' compiles -#PROFILE_CFLAGS = $(COMMON_CFLAGS) -pg $(OPTIMIZATION_CFLAG) -DPROFILE - -# Flags passed to yacc -#YFLAGS = -d - -# Ownership and permissions of files installed by 'install' target -#INSTALL_AS_USER = root # User to chown app to -#INSTALL_AS_GROUP = kmem # Group to chgrp app to -#INSTALL_PERMISSIONS = 2555 # If set, 'install' chmod's executable to this - -# Options to strip for bundles, apps with bundles, and apps without bundles, -# respectively. -#RELOCATABLE_STRIP_OPTS = -x -u -#DYLD_APP_STRIP_OPTS = -A -n -#APP_STRIP_OPTS = -#TOOL_STRIP_OPTS = -#LIBRARY_STRIP_OPTS = -x -S # Note: -S strips debugging symbols -# (Note: APP_STRIP_OPTS and TOOL_STRIP_OPTS default to empty, but -# developers doing their own dynamic loading should set this to -# $(DYLD_APP_STRIP_OPTS)). - - -######################################################################### -# Put rules to extend the behavior of the standard Makefiles here. Typical -# user-defined rules are before_install and after_install (please don't -# redefine things like install or app, as they are owned by the top-level -# Makefile API), which are rules that get invoked before and after the install -# target runs. Such rules should be specified with the '::' syntax rather than -# a single colon. +install-man-page: + install -d $(DSTROOT)/usr/share/man/man8 + install -c -m 444 iostat.8 $(DSTROOT)/usr/share/man/man8/iostat.8 diff --git a/iostat.tproj/Makefile.preamble b/iostat.tproj/Makefile.preamble index dd14626..d52a820 100644 --- a/iostat.tproj/Makefile.preamble +++ b/iostat.tproj/Makefile.preamble @@ -112,4 +112,5 @@ OTHER_HELP_DIRS = OTHER_GENERATED_OFILES = $(VERS_OFILE) - +# to make it install the man page +AFTER_INSTALL += install-man-page diff --git a/iostat.tproj/iostat.8 b/iostat.tproj/iostat.8 index 129945e..4428877 100644 --- a/iostat.tproj/iostat.8 +++ b/iostat.tproj/iostat.8 @@ -110,7 +110,7 @@ is also specfied to enable the display of CPU or TTY statistics. Display total statstics for a given time period, rather than average statistics for each second during that time period. .It Fl K -In the blocks transfered display (-o), display block count in kilobytes rather +In the blocks transferred display (-o), display block count in kilobytes rather then the device native block size. .It Fl n Display up to diff --git a/iostat.tproj/iostat.c b/iostat.tproj/iostat.c index 3ea24b1..da5fe41 100644 --- a/iostat.tproj/iostat.c +++ b/iostat.tproj/iostat.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/kdump.tproj/kdump.c b/kdump.tproj/kdump.c index 822b118..7f1238e 100644 --- a/kdump.tproj/kdump.c +++ b/kdump.tproj/kdump.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/kdump.tproj/syscalls.c b/kdump.tproj/syscalls.c index 456f002..71a9215 100644 --- a/kdump.tproj/syscalls.c +++ b/kdump.tproj/syscalls.c @@ -3,22 +3,19 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/kgmon.tproj/kgmon.c b/kgmon.tproj/kgmon.c index 3039a89..47161c0 100644 --- a/kgmon.tproj/kgmon.c +++ b/kgmon.tproj/kgmon.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/ktrace.tproj/ktrace.c b/ktrace.tproj/ktrace.c index 74484ce..dc09649 100644 --- a/ktrace.tproj/ktrace.c +++ b/ktrace.tproj/ktrace.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/ktrace.tproj/subr.c b/ktrace.tproj/subr.c index e5186dd..90144d3 100644 --- a/ktrace.tproj/subr.c +++ b/ktrace.tproj/subr.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/latency.tproj/latency.1 b/latency.tproj/latency.1 index 40b23d6..94ce927 100644 --- a/latency.tproj/latency.1 +++ b/latency.tproj/latency.1 @@ -17,77 +17,80 @@ .Op Fl d Ar decrementer_in_usecs .Op Fl n Ar kernel .Sh DESCRIPTION +The .Nm latency -provides scheduling and interrupt latency statistics. +utility provides scheduling and interrupt latency statistics. +It requires root privileges due to the kernel tracing facility it uses to +operate. .Pp The arguments are as follows: .Bl -tag -width Ds .It Fl rt -Set real time scheduling policy. Default policy is timeshare. +Set real time scheduling policy. +Default policy is timeshare. .It Fl c When the .Fl c option is specified, it takes a path to a .Ar codefile -that -contains the mappings for the system calls. This option -overrides the default location of the system call codefile -which is found in /usr/share/misc/trace.codes. +that contains the mappings for the system calls. +This option overrides the default location of the system call codefile which is +found in /usr/share/misc/trace.codes. .It Fl l Specifies a .Ar logfile -that is written to when either the interrupt or scheduling -latency is exceeded. +that is written to when either the interrupt or scheduling latency is exceeded. .It Fl st -Set the scheduler latency threshold in microseconds. If latency -exceeds this, and a logfile has been specified, a record -of what occurred during this time is recorded. +Set the scheduler latency threshold in microseconds. +If latency exceeds this, and a logfile has been specified, a record of what +occurred during this time is recorded. .It Fl it -Set the interrupt latency threshold in microseconds. If latency -exceeds this, and a logfile has been specified, a record -of what occurred during this time is recorded. +Set the interrupt latency threshold in microseconds. +If latency exceeds this, and a logfile has been specified, a record of what +occurred during this time is recorded. .It Fl s The .Fl s -option sets the timer. It takes microseconds as an argument, -the default timer is set to 1000 microseconds. +option sets the timer. +It takes microseconds as an argument, the default timer is set to 1000 +microseconds. .It Fl d The .Fl d -option sets the decrementer. It takes microseconds as an argument. +option sets the decrementer. +It takes microseconds as an argument. The decrementer is set back to the system default on exit. .It Fl n By default, .Nm latency -acts on the default /mach_kernel. This option -allows you to specify an alternate booted kernel. +acts on the default /mach_kernel. +This option allows you to specify an alternate booted kernel. .El .Pp The data columns displayed are as follows: .Bl -tag -width LAST_PATHNAME_WAITED_FOR -compact .Pp .It SCHEDULER -The number of context switches that fall -within the described delay. +The number of context switches that fall within the described delay. .It INTERRUPTS -The number of interrupts that fall -within the described delay. +The number of interrupts that fall within the described delay. .El .Pp The .Nm latency -command is also SIGWINCH savvy, so adjusting your window geometry will change +utility is also SIGWINCH savvy, so adjusting your window geometry will change the list of delay values displayed. .Sh SAMPLE USAGE .Pp latency -rt -st 20000 -it 1000 -l /var/tmp/latency.log .Pp +The .Nm latency -will set the realtime scheduling policy. The threshold for the scheduler is set to -20000 microseconds. The threshold for interrupts is set to 1000 -microseconds. Latencies that exceed these thresholds will be logged -in /var/tmp/latency.log. +utility will set the realtime scheduling policy. +The threshold for the scheduler is set to 20000 microseconds. +The threshold for interrupts is set to 1000 microseconds. +Latencies that exceed these thresholds will be logged in /var/tmp/latency.log. .Sh SEE ALSO -.Xr top 1 -.Xr fs_usage 1 +.Xr top 1 , +.Xr fs_usage 1 , .Xr sc_usage 1 diff --git a/latency.tproj/latency.c b/latency.tproj/latency.c index 3d98e94..42a9155 100644 --- a/latency.tproj/latency.c +++ b/latency.tproj/latency.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ @@ -434,6 +433,7 @@ void sigintr() set_enable(0); set_pidexclude(getpid(), 0); screen_update(log_fp); + endwin(); set_rtcdec(0); set_remove(); @@ -444,6 +444,7 @@ void leave() /* exit under normal conditions -- signal handler */ { set_enable(0); set_pidexclude(getpid(), 0); + endwin(); set_rtcdec(0); set_remove(); @@ -1253,8 +1254,7 @@ void sample_sc(uint64_t start, uint64_t stop) if (type == DECR_TRAP) i_latency = handle_decrementer(kd); - now = (((uint64_t)kd->timestamp.tv_sec) << 32) | - (uint64_t)((unsigned int)(kd->timestamp.tv_nsec)); + now = kd->timestamp; timestamp = ((double)now) / divisor; @@ -1781,8 +1781,7 @@ kd_buf *log_decrementer(kd_buf *kd_beg, kd_buf *kd_end, kd_buf *end_of_sample, d if (kd_stop >= end_of_sample) kd_stop = end_of_sample - 1; - now = (((uint64_t)kd_start->timestamp.tv_sec) << 32) | - (uint64_t)((unsigned int)(kd_start->timestamp.tv_nsec)); + now = kd_start->timestamp; timestamp = ((double)now) / divisor; for (kd = kd_start; kd <= kd_stop; kd++) { @@ -1801,8 +1800,7 @@ kd_buf *log_decrementer(kd_buf *kd_beg, kd_buf *kd_end, kd_buf *end_of_sample, d debugid = kd->debugid; type = kd->debugid & DBG_FUNC_MASK; - now = (((uint64_t)kd->timestamp.tv_sec) << 32) | - (uint64_t)((unsigned int)(kd->timestamp.tv_nsec)); + now = kd->timestamp; timestamp = ((double)now) / divisor; diff --git a/login.tproj/klogin.c b/login.tproj/klogin.c index ed9444d..3426d9c 100644 --- a/login.tproj/klogin.c +++ b/login.tproj/klogin.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/login.tproj/login.1 b/login.tproj/login.1 index 6c78b23..1d30551 100644 --- a/login.tproj/login.1 +++ b/login.tproj/login.1 @@ -102,7 +102,7 @@ then records an entry in the .Xr wtmp 5 and .Xr utmp 5 -files and executes the user's command interpretor. +files and executes the user's command interpreter. .Pp Login enters information into the environment (see .Xr environ 7 ) diff --git a/login.tproj/login.c b/login.tproj/login.c index a2d9ef3..cdaed0e 100644 --- a/login.tproj/login.c +++ b/login.tproj/login.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ @@ -140,7 +139,7 @@ main(argc, argv) struct stat st; struct timeval tp; struct utmp utmp; - int ask, ch, cnt, fflag, hflag, pflag, quietlog, rootlogin = 0, rval; + int ask, ch, cnt, oflag = 0, fflag, hflag, pflag, quietlog, rootlogin = 0, rval; uid_t uid; uid_t euid; gid_t egid; @@ -179,8 +178,11 @@ main(argc, argv) fflag = hflag = pflag = 0; uid = getuid(); - while ((ch = getopt(argc, argv, "fh:p")) != EOF) + while ((ch = getopt(argc, argv, "1fh:p")) != EOF) switch (ch) { + case '1': + oflag = 1; + break; case 'f': fflag = 1; break; @@ -262,7 +264,7 @@ main(argc, argv) } else { rval = pam_authenticate(pamh, 0); - while( (cnt++ < 10) && ((rval == PAM_AUTH_ERR) || + while( (!oflag) && (cnt++ < 10) && ((rval == PAM_AUTH_ERR) || (rval == PAM_USER_UNKNOWN) || (rval == PAM_CRED_INSUFFICIENT) || (rval == PAM_AUTHINFO_UNAVAIL))) { diff --git a/login.tproj/pathnames.h b/login.tproj/pathnames.h index ffdde6d..b83bb9b 100644 --- a/login.tproj/pathnames.h +++ b/login.tproj/pathnames.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/mach_init.tproj/bootstrap.c b/mach_init.tproj/bootstrap.c index 98bf77e..970bc93 100644 --- a/mach_init.tproj/bootstrap.c +++ b/mach_init.tproj/bootstrap.c @@ -1,24 +1,23 @@ /* - * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ @@ -47,12 +46,15 @@ #import #import +#import +#import #import #import #import #import #import #import +#import #import "bootstrap.h" @@ -123,42 +125,60 @@ pthread_t demand_thread; mach_port_t notify_port; mach_port_t backup_port; + static void -notify_server_loop(mach_port_name_t about) +enablecoredumps(boolean_t enabled) +{ + struct rlimit rlimit; + + getrlimit(RLIMIT_CORE, &rlimit); + rlimit.rlim_cur = (enabled) ? rlimit.rlim_max : 0; + setrlimit(RLIMIT_CORE, &rlimit); +} + +static void +toggle_debug(int signal) +{ + + debugging = (debugging) ? FALSE : TRUE; + enablecoredumps(debugging); +} + +static mach_msg_return_t +inform_server_loop( + mach_port_name_t about, + mach_msg_option_t options) { mach_port_destroyed_notification_t not; - mach_msg_return_t nresult; + mach_msg_size_t size = sizeof(not) - sizeof(not.trailer); not.not_header.msgh_id = DEMAND_REQUEST; not.not_header.msgh_remote_port = backup_port; not.not_header.msgh_local_port = MACH_PORT_NULL; not.not_header.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_MAKE_SEND, 0); - not.not_header.msgh_size = sizeof(not) - sizeof(not.trailer); + not.not_header.msgh_size = size; not.not_body.msgh_descriptor_count = 1; not.not_port.type = MACH_MSG_PORT_DESCRIPTOR; not.not_port.disposition = MACH_MSG_TYPE_PORT_NAME; not.not_port.name = about; - nresult = mach_msg_send(¬.not_header); - if (nresult != MACH_MSG_SUCCESS) { - kern_error(nresult, "notify_server: mach_msg_send()"); - } + return mach_msg(¬.not_header, MACH_SEND_MSG|options, size, + 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); } -void _myExit(int arg) +static void +notify_server_loop(mach_port_name_t about) { - exit(arg); -} + mach_msg_return_t result; -void toggle_debug(int signal) -{ - debugging = (debugging) ? FALSE : TRUE; + result = inform_server_loop(about, MACH_MSG_OPTION_NONE); + if (result != MACH_MSG_SUCCESS) + kern_error(result, "notify_server_loop: mach_msg()"); } void start_shutdown(int signal) { - debug("received SIGTERM"); shutdown_in_progress = TRUE; - notify_server_loop(MACH_PORT_DEAD); + (void) inform_server_loop(MACH_PORT_NULL, MACH_SEND_TIMEOUT); } int @@ -243,6 +263,22 @@ main(int argc, char * argv[]) exit(1); /* will likely trigger a panic */ } + + /* + * Child - will continue along as mach_init. Construct + * a very basic environment - as much as if we were + * actually forked from init (instead of the other way + * around): + * + * Set up the PATH to be approriate for the root user. + * Create an initial session. + * Establish an initial user. + * Disbale core dumps. + */ + setenv("PATH", _PATH_STDPATH, 1); + setsid(); + setlogin("root"); + enablecoredumps(FALSE); } else init_notify_port = MACH_PORT_NULL; @@ -261,9 +297,11 @@ main(int argc, char * argv[]) switch (c = *argp++) { case 'd': debugging = TRUE; + enablecoredumps(TRUE); break; case 'D': debugging = FALSE; + enablecoredumps(FALSE); break; case 'F': force_fork = TRUE; @@ -606,12 +644,7 @@ useless_server(server_t *serverp) boolean_t active_server(server_t *serverp) { - return ( -#ifdef DELAYED_BOOTSTRAP_DESTROY - serverp->port || -#else - (serverp->port && serverp->pid == NO_PID) || -#endif + return ( serverp->port || serverp->task_port || serverp->active_services); } @@ -747,9 +780,7 @@ start_server(server_t *serverp) case SERVER: case DEMAND: case RESTARTABLE: -#ifdef DELAYED_BOOTSTRAP_DESTROY if (!serverp->port) -#endif setup_server(serverp); serverp->activity = 0; diff --git a/mach_init.tproj/bootstrap.defs b/mach_init.tproj/bootstrap.defs index e628cbe..55c0b32 100644 --- a/mach_init.tproj/bootstrap.defs +++ b/mach_init.tproj/bootstrap.defs @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ @@ -279,7 +278,7 @@ routine bootstrap_look_up_array( routine bootstrap_parent( bootstrap_port : mach_port_t; ServerSecToken token : security_token_t; - out parent_port : mach_port_t); + out parent_port : mach_port_make_send_t); /* * kern_return_t diff --git a/mach_init.tproj/bootstrap_internal.h b/mach_init.tproj/bootstrap_internal.h index 1592e90..38c4234 100644 --- a/mach_init.tproj/bootstrap_internal.h +++ b/mach_init.tproj/bootstrap_internal.h @@ -1,24 +1,23 @@ /* - * Copyright (c) 2002-1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ @@ -41,8 +40,6 @@ #define DEMAND_REQUEST MACH_NOTIFY_LAST /* demand service messaged */ -#define DELAYED_BOOTSTRAP_DESTROY TRUE /* destroyed on last reference */ - extern const char *program_name; extern mach_port_t lookup_only_port; extern mach_port_t inherited_bootstrap_port; diff --git a/mach_init.tproj/error_log.c b/mach_init.tproj/error_log.c index 5133d69..183abfc 100644 --- a/mach_init.tproj/error_log.c +++ b/mach_init.tproj/error_log.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/mach_init.tproj/error_log.h b/mach_init.tproj/error_log.h index caca280..f6dc4df 100644 --- a/mach_init.tproj/error_log.h +++ b/mach_init.tproj/error_log.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/mach_init.tproj/lists.c b/mach_init.tproj/lists.c index 89014a9..92bb29c 100644 --- a/mach_init.tproj/lists.c +++ b/mach_init.tproj/lists.c @@ -1,24 +1,23 @@ /* - * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ @@ -65,6 +64,7 @@ init_lists(void) { bootstraps.ref_count = 2; /* make sure we never deallocate this one */ bootstraps.next = bootstraps.prev = &bootstraps; + bootstraps.parent = &bootstraps; servers.next = servers.prev = &servers; services.next = services.prev = &services; nservices = 0; @@ -208,20 +208,20 @@ lookup_service_by_name(bootstrap_info_t *bootstrap, name_t name) { service_t *servicep; - while (bootstrap) { - for ( servicep = FIRST(services) - ; !IS_END(servicep, services) - ; servicep = NEXT(servicep)) - { - if (!STREQ(name, servicep->name)) - continue; - if (bootstrap && servicep->bootstrap != bootstrap) - continue; - return servicep; - } - bootstrap = bootstrap->parent; - } - + if (bootstrap) + do { + for ( servicep = FIRST(services) + ; !IS_END(servicep, services) + ; servicep = NEXT(servicep)) + { + if (!STREQ(name, servicep->name)) + continue; + if (bootstrap && servicep->bootstrap != bootstrap) + continue; + return servicep; + } + } while (bootstrap != &bootstraps && + (bootstrap = bootstrap->parent)); return NULL; } @@ -372,11 +372,9 @@ delete_server(server_t *serverp) deallocate_bootstrap(serverp->bootstrap); -#ifndef DELAYED_BOOTSTRAP_DESTROY if (serverp->port) mach_port_mod_refs(mach_task_self(), serverp->port, MACH_PORT_RIGHT_RECEIVE, -1); -#endif free(serverp); } @@ -441,7 +439,6 @@ deactivate_bootstrap(bootstrap_info_t *bootstrap) mach_port_deallocate(mach_task_self(), bootstrap->bootstrap_port); -#ifdef DELAYED_BOOTSTRAP_DESTROY { mach_port_t previous; mach_port_request_notification( @@ -453,16 +450,6 @@ deactivate_bootstrap(bootstrap_info_t *bootstrap) MACH_MSG_TYPE_MAKE_SEND_ONCE, &previous); } -#else - mach_port_mod_refs( - mach_task_self(), - bootstrap->bootstrap_port, - MACH_PORT_RIGHT_RECEIVE, - -1); - bootstrap->bootstrap_port = MACH_PORT_NULL; - deallocate_bootstrap(bootstrap); -#endif - } while (deactivating_bootstraps != NULL); } diff --git a/mach_init.tproj/lists.h b/mach_init.tproj/lists.h index 924d941..4ad1515 100644 --- a/mach_init.tproj/lists.h +++ b/mach_init.tproj/lists.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/mach_init.tproj/mach_init.8 b/mach_init.tproj/mach_init.8 index 84694cd..6099079 100644 --- a/mach_init.tproj/mach_init.8 +++ b/mach_init.tproj/mach_init.8 @@ -29,13 +29,16 @@ When the .Fl D option is specified, .Nm mach_init -starts in normal (non-debug) mode. This is the default. +starts in normal (non-debug) mode. Logging is minimal (only security-related +and process launch failures are logged). Core dumps are disabled for launched +servers. This is the default. .It Fl d When the .Fl d option is specified, .Nm mach_init -starts in debug mode. +starts in debug mode. Logging is extensive. Core dumps will be taken for any +launched servers that crash. .It Fl F When the .Fl F diff --git a/mach_init.tproj/rpc_services.c b/mach_init.tproj/rpc_services.c index 4d3f34d..9f0a546 100644 --- a/mach_init.tproj/rpc_services.c +++ b/mach_init.tproj/rpc_services.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ @@ -495,7 +494,6 @@ x_bootstrap_parent( security_token_t sectoken, mach_port_t *parent_port) { -#if 0 bootstrap_info_t *bootstrap; debug("Parent attempt for bootstrap %x", bootstrap_port); @@ -515,11 +513,6 @@ x_bootstrap_parent( bootstrap->parent->bootstrap_port, bootstrap_port); *parent_port = bootstrap->parent->bootstrap_port; return BOOTSTRAP_SUCCESS; -#else - debug("bootstrap parent for bootstrap %x: not implemented", - bootstrap_port); - return BOOTSTRAP_NOT_PRIVILEGED; -#endif } /* diff --git a/makekey.tproj/makekey.c b/makekey.tproj/makekey.c index 557bcfc..487cfaa 100644 --- a/makekey.tproj/makekey.c +++ b/makekey.tproj/makekey.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/mkfile.tproj/mkfile.c b/mkfile.tproj/mkfile.c index 5f70877..4aff548 100644 --- a/mkfile.tproj/mkfile.c +++ b/mkfile.tproj/mkfile.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nvram.tproj/nvram.c b/nvram.tproj/nvram.c index 284a34d..a681211 100644 --- a/nvram.tproj/nvram.c +++ b/nvram.tproj/nvram.c @@ -2,24 +2,21 @@ * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * * @APPLE_LICENSE_HEADER_END@ */ /* @@ -369,15 +366,44 @@ static kern_return_t SetOFVariable(char *name, char *value) if (valueRef) { typeID = CFGetTypeID(valueRef); CFRelease(valueRef); - } else typeID = CFDataGetTypeID(); - - valueRef = ConvertValueToCFTypeRef(typeID, value); - if (valueRef == 0) { - FatalError(-1, "Error (-1) creating CFTypeRef for value %s",(long)value); + + valueRef = ConvertValueToCFTypeRef(typeID, value); + if (valueRef == 0) { + FatalError(-1, "Error (-1) creating CFTypeRef for value %s",(long)value); + } result = IORegistryEntrySetCFProperty(gOptionsRef, nameRef, valueRef); + } else { + while (1) { + // In the default case, try data, string, number, then boolean. + + valueRef = ConvertValueToCFTypeRef(CFDataGetTypeID(), value); + if (valueRef != 0) { + result = IORegistryEntrySetCFProperty(gOptionsRef, nameRef, valueRef); + if (result == KERN_SUCCESS) break; + } + + valueRef = ConvertValueToCFTypeRef(CFStringGetTypeID(), value); + if (valueRef != 0) { + result = IORegistryEntrySetCFProperty(gOptionsRef, nameRef, valueRef); + if (result == KERN_SUCCESS) break; + } + + valueRef = ConvertValueToCFTypeRef(CFNumberGetTypeID(), value); + if (valueRef != 0) { + result = IORegistryEntrySetCFProperty(gOptionsRef, nameRef, valueRef); + if (result == KERN_SUCCESS) break; + } + + valueRef = ConvertValueToCFTypeRef(CFBooleanGetTypeID(), value); + if (valueRef != 0) { + result = IORegistryEntrySetCFProperty(gOptionsRef, nameRef, valueRef); + if (result == KERN_SUCCESS) break; + } + + result = -1; + break; + } } - result = IORegistryEntrySetCFProperty(gOptionsRef, nameRef, valueRef); - CFRelease(nameRef); return result; diff --git a/passwd.tproj/Makefile b/passwd.tproj/Makefile index 53850dc..cfb6938 100644 --- a/passwd.tproj/Makefile +++ b/passwd.tproj/Makefile @@ -14,7 +14,7 @@ PROJECT_TYPE = Tool HFILES = stringops.h -CFILES = nis_passwd.c file_passwd.c netinfo_passwd.c passwd.c\ +CFILES = nis_passwd.c file_passwd.c netinfo_passwd.c ds_passwd.c passwd.c\ stringops.c OTHERSRCS = Makefile.preamble Makefile Makefile.postamble passwd.1 @@ -26,7 +26,7 @@ MAKEFILE = tool.make NEXTSTEP_INSTALLDIR = /usr/bin WINDOWS_INSTALLDIR = /usr/bin PDO_UNIX_INSTALLDIR = /usr/bin -LIBS = +LIBS = /System/Library/Frameworks/DirectoryService.framework/Versions/A/DirectoryService DEBUG_LIBS = $(LIBS) PROF_LIBS = $(LIBS) diff --git a/passwd.tproj/ds_passwd.c b/passwd.tproj/ds_passwd.c new file mode 100644 index 0000000..169edfb --- /dev/null +++ b/passwd.tproj/ds_passwd.c @@ -0,0 +1,412 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." + * + * @APPLE_LICENSE_HEADER_END@ + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +// password server can store 511 characters + a terminator. +#define kMaxPassword 512 + +//------------------------------------------------------------------------------------- +// ds_getpasswd +//------------------------------------------------------------------------------------- + +void +ds_getpasswd(char *name, int isroot, int wasroot, int changePassOnSelf, char **old_clear, char **new_clear) +{ + int tries, len; + char *p; + static char obuf[kMaxPassword]; + static char nbuf[kMaxPassword]; + + printf("Changing password for %s.\n", name); + + p = ""; + + if (isroot == 0) + { + p = getpass( changePassOnSelf ? "Old password:" : "Administrator password:" ); + snprintf( obuf, sizeof(obuf), "%s", p ); + } + + if ( wasroot == 0 ) + { + tries = 0; + nbuf[0] = '\0'; + for (;;) + { + p = getpass("New password:"); + if (!*p) + { + printf("Password unchanged.\n"); + exit(0); + } + + tries++; + len = strlen(p); + + snprintf( nbuf, sizeof(nbuf), "%s", p ); + if (!strcmp(nbuf, getpass("Retype new password:"))) break; + + printf("Mismatch; try again, EOF to quit.\n"); + } + } + + *old_clear = obuf; + *new_clear = nbuf; +} + + +//------------------------------------------------------------------------------------- +// ds_passwd +//------------------------------------------------------------------------------------- + +int +ds_passwd(char *uname, char *locn) +{ + tDirReference dsRef = 0; + tDataBuffer *tDataBuff = NULL; + tDirNodeReference nodeRef = 0; + long status = eDSNoErr; + tContextData context = NULL; + unsigned long nodeCount = 0; + unsigned long attrIndex = 0; + tDataList *nodeName = NULL; + tAttributeEntryPtr pAttrEntry = NULL; + tDataList *pRecName = NULL; + tDataList *pRecType = NULL; + tDataList *pAttrType = NULL; + unsigned long recCount = 0; + tRecordEntry *pRecEntry = NULL; + tAttributeListRef attrListRef = 0; + char *pUserLocation = NULL; + char *pUserName = NULL; + tAttributeValueListRef valueRef = 0; + tAttributeValueEntry *pValueEntry = NULL; + tDataList *pUserNode = NULL; + tDirNodeReference userNodeRef = 0; + tDataBuffer *pStepBuff = NULL; + tDataNode *pAuthType = NULL; + unsigned long uiCurr = 0; + unsigned long uiLen = 0; + char *old_clear = NULL; + char *new_clear = NULL; + int isroot = 0; + int wasroot = 0; + char *loginUser = NULL; + int changePassOnSelf = 1; + + if (uname == NULL) + return -1; + + loginUser = getlogin(); + if ( loginUser != NULL ) + changePassOnSelf = ( strcmp( loginUser, uname ) == 0 ); + + status = dsOpenDirService( &dsRef ); + if (status != eDSNoErr) + return status; + + do + { + if ( tDataBuff == NULL ) + tDataBuff = dsDataBufferAllocate( dsRef, 4096 ); + if (tDataBuff == NULL) break; + + if ( locn != NULL ) + { + nodeName = dsBuildFromPath( dsRef, locn, "/" ); + if ( nodeName == NULL ) break; + + // find + status = dsFindDirNodes( dsRef, tDataBuff, nodeName, eDSiExact, &nodeCount, &context ); + } + else + { + // find on search node + status = dsFindDirNodes( dsRef, tDataBuff, NULL, eDSSearchNodeName, &nodeCount, &context ); + } + + if (status != eDSNoErr) break; + if ( nodeCount < 1 ) { + status = eDSNodeNotFound; + break; + } + + if ( isroot == 1 ) + { + // we already tried SetPasswordAsRoot and it didn't work + // get the old (current) password and try again + + // getpass + isroot = 0; + wasroot = 1; + } + else + if ( getuid() == 0 ) + isroot = 1; + + ds_getpasswd( uname, isroot, wasroot, changePassOnSelf, &old_clear, &new_clear ); + + status = dsGetDirNodeName( dsRef, tDataBuff, 1, &nodeName ); + if (status != eDSNoErr) continue; + + status = dsOpenDirNode( dsRef, nodeName, &nodeRef ); + dsDataListDeallocate( dsRef, nodeName ); + free( nodeName ); + nodeName = NULL; + if (status != eDSNoErr) continue; + + pRecName = dsBuildListFromStrings( dsRef, uname, NULL ); + pRecType = dsBuildListFromStrings( dsRef, kDSStdRecordTypeUsers, NULL ); + pAttrType = dsBuildListFromStrings( dsRef, kDSNAttrMetaNodeLocation, kDSNAttrRecordName, NULL ); + + recCount = 1; + status = dsGetRecordList( nodeRef, tDataBuff, pRecName, eDSExact, pRecType, + pAttrType, 0, &recCount, &context ); + if ( status != eDSNoErr ) break; + if ( recCount == 0 ) { + status = eDSAuthUnknownUser; + break; + } + + status = dsGetRecordEntry( nodeRef, tDataBuff, 1, &attrListRef, &pRecEntry ); + if ( status != eDSNoErr ) break; + + for ( attrIndex = 1; (attrIndex <= pRecEntry->fRecordAttributeCount) && (status == eDSNoErr); attrIndex++ ) + { + status = dsGetAttributeEntry( nodeRef, tDataBuff, attrListRef, attrIndex, &valueRef, &pAttrEntry ); + if ( status == eDSNoErr && pAttrEntry != NULL ) + { + if ( strcmp( pAttrEntry->fAttributeSignature.fBufferData, kDSNAttrMetaNodeLocation ) == 0 ) + { + status = dsGetAttributeValue( nodeRef, tDataBuff, 1, valueRef, &pValueEntry ); + if ( status == eDSNoErr && pValueEntry != NULL ) + { + pUserLocation = (char *) calloc( pValueEntry->fAttributeValueData.fBufferLength + 1, sizeof(char) ); + memcpy( pUserLocation, pValueEntry->fAttributeValueData.fBufferData, pValueEntry->fAttributeValueData.fBufferLength ); + } + } + else + if ( strcmp( pAttrEntry->fAttributeSignature.fBufferData, kDSNAttrRecordName ) == 0 ) + { + status = dsGetAttributeValue( nodeRef, tDataBuff, 1, valueRef, &pValueEntry ); + if ( status == eDSNoErr && pValueEntry != NULL ) + { + pUserName = (char *) calloc( pValueEntry->fAttributeValueData.fBufferLength + 1, sizeof(char) ); + memcpy( pUserName, pValueEntry->fAttributeValueData.fBufferData, pValueEntry->fAttributeValueData.fBufferLength ); + } + } + + if ( pValueEntry != NULL ) + dsDeallocAttributeValueEntry( dsRef, pValueEntry ); + pValueEntry = NULL; + + dsDeallocAttributeEntry( dsRef, pAttrEntry ); + pAttrEntry = NULL; + dsCloseAttributeValueList( valueRef ); + valueRef = 0; + } + } + + pUserNode = dsBuildFromPath( dsRef, pUserLocation, "/" ); + status = dsOpenDirNode( dsRef, pUserNode, &userNodeRef ); + if ( status != eDSNoErr ) break; + + pStepBuff = dsDataBufferAllocate( dsRef, 128 ); + + if ( isroot ) + { + pAuthType = dsDataNodeAllocateString( dsRef, kDSStdAuthSetPasswdAsRoot ); + uiCurr = 0; + + // User name + uiLen = strlen( pUserName ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), &uiLen, sizeof( unsigned long ) ); + uiCurr += sizeof( unsigned long ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), pUserName, uiLen ); + uiCurr += uiLen; + + // new pw + uiLen = strlen( new_clear ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), &uiLen, sizeof( unsigned long ) ); + uiCurr += sizeof( unsigned long ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), new_clear, uiLen ); + uiCurr += uiLen; + + tDataBuff->fBufferLength = uiCurr; + + status = dsDoDirNodeAuth( userNodeRef, pAuthType, 1, tDataBuff, pStepBuff, NULL ); + } + else + if ( changePassOnSelf ) + { + pAuthType = dsDataNodeAllocateString( dsRef, kDSStdAuthChangePasswd ); + uiCurr = 0; + + // User name + uiLen = strlen( pUserName ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), &uiLen, sizeof( unsigned long ) ); + uiCurr += sizeof( unsigned long ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), pUserName, uiLen ); + uiCurr += uiLen; + + // old pw + uiLen = strlen( old_clear ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), &uiLen, sizeof( unsigned long ) ); + uiCurr += sizeof( unsigned long ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), old_clear, uiLen ); + uiCurr += uiLen; + + // new pw + uiLen = strlen( new_clear ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), &uiLen, sizeof( unsigned long ) ); + uiCurr += sizeof( unsigned long ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), new_clear, uiLen ); + uiCurr += uiLen; + + tDataBuff->fBufferLength = uiCurr; + + status = dsDoDirNodeAuth( userNodeRef, pAuthType, 1, tDataBuff, pStepBuff, NULL ); + } + else + { + pAuthType = dsDataNodeAllocateString( dsRef, kDSStdAuthSetPasswd ); + uiCurr = 0; + + // User name + uiLen = strlen( pUserName ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), &uiLen, sizeof( unsigned long ) ); + uiCurr += sizeof( unsigned long ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), pUserName, uiLen ); + uiCurr += uiLen; + + // new pw + uiLen = strlen( new_clear ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), &uiLen, sizeof( unsigned long ) ); + uiCurr += sizeof( unsigned long ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), new_clear, uiLen ); + uiCurr += uiLen; + + // Authenticator name + uiLen = strlen( loginUser ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), &uiLen, sizeof( unsigned long ) ); + uiCurr += sizeof( unsigned long ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), loginUser, uiLen ); + uiCurr += uiLen; + + // authenticator pw + uiLen = strlen( old_clear ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), &uiLen, sizeof( unsigned long ) ); + uiCurr += sizeof( unsigned long ); + memcpy( &(tDataBuff->fBufferData[ uiCurr ]), old_clear, uiLen ); + uiCurr += uiLen; + + tDataBuff->fBufferLength = uiCurr; + + status = dsDoDirNodeAuth( userNodeRef, pAuthType, 1, tDataBuff, pStepBuff, NULL ); + } + } + while ( isroot == 1 && status != eDSNoErr ); + + /* old_clear and new_clear are statics (don't call free) */ + if (old_clear != NULL) { + memset(old_clear, 0, strlen(old_clear)); + } + if (new_clear != NULL) { + memset(new_clear, 0, strlen(new_clear)); + } + if (tDataBuff != NULL) { + memset(tDataBuff, 0, tDataBuff->fBufferSize); + dsDataBufferDeAllocate( dsRef, tDataBuff ); + tDataBuff = NULL; + } + + if (pStepBuff != NULL) { + dsDataBufferDeAllocate( dsRef, pStepBuff ); + pStepBuff = NULL; + } + if (pUserLocation != NULL ) { + free(pUserLocation); + pUserLocation = NULL; + } + if (pRecName != NULL) { + dsDataListDeallocate( dsRef, pRecName ); + free( pRecName ); + pRecName = NULL; + } + if (pRecType != NULL) { + dsDataListDeallocate( dsRef, pRecType ); + free( pRecType ); + pRecType = NULL; + } + if (pAttrType != NULL) { + dsDataListDeallocate( dsRef, pAttrType ); + free( pAttrType ); + pAttrType = NULL; + } + if (nodeRef != 0) { + dsCloseDirNode(nodeRef); + nodeRef = 0; + } + if (dsRef != 0) { + dsCloseDirService(dsRef); + dsRef = 0; + } + + if ( status != eDSNoErr ) { + errno = EACCES; + fprintf(stderr, "Sorry\n"); + exit(1); + } + + return status; +} + + + + + + + + + + + diff --git a/passwd.tproj/file_passwd.c b/passwd.tproj/file_passwd.c index 4f67cfc..d439d97 100644 --- a/passwd.tproj/file_passwd.c +++ b/passwd.tproj/file_passwd.c @@ -3,26 +3,26 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ #include +#include #include #include #include diff --git a/passwd.tproj/netinfo_passwd.c b/passwd.tproj/netinfo_passwd.c index e86a25b..6abdd39 100644 --- a/passwd.tproj/netinfo_passwd.c +++ b/passwd.tproj/netinfo_passwd.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/passwd.tproj/nis_passwd.c b/passwd.tproj/nis_passwd.c index 8be2044..9043e92 100644 --- a/passwd.tproj/nis_passwd.c +++ b/passwd.tproj/nis_passwd.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/passwd.tproj/passwd.c b/passwd.tproj/passwd.c index 4b16ce7..894d797 100644 --- a/passwd.tproj/passwd.c +++ b/passwd.tproj/passwd.c @@ -3,28 +3,28 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ #define INFO_NETINFO 0 #define INFO_FILE 1 #define INFO_NIS 2 +#define INFO_DIRECTORYSERVICES 3 #ifndef __SLICK__ #define _PASSWD_FILE "/etc/master.passwd" @@ -50,6 +50,7 @@ static char *saltchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01 extern int file_passwd(char *, char *); extern int netinfo_passwd(char *, char *); extern int nis_passwd(char *, char *); +extern int ds_passwd(char *, char *); void getpasswd(char *name, int isroot, int minlen, int mixcase, int nonalpha, @@ -78,8 +79,9 @@ getpasswd(char *name, int isroot, int minlen, int mixcase, int nonalpha, exit(1); } } - strcpy(obuf, p); - + //strcpy(obuf, p); + snprintf( obuf, sizeof(obuf), "%s", p ); + tries = 0; nbuf[0] = '\0'; for (;;) @@ -132,7 +134,9 @@ getpasswd(char *name, int isroot, int minlen, int mixcase, int nonalpha, continue; } - strcpy(nbuf, p); + //strcpy(nbuf, p); + snprintf( nbuf, sizeof(nbuf), "%s", p ); + if (!strcmp(nbuf, getpass("Retype new password:"))) break; printf("Mismatch; try again, EOF to quit.\n"); @@ -160,10 +164,12 @@ usage() fprintf(stderr, " netinfo\n"); fprintf(stderr, " file\n"); fprintf(stderr, " nis\n"); + fprintf(stderr, " opendirectory\n"); fprintf(stderr, "for netinfo, location may be a domain name or server/tag\n"); fprintf(stderr, "for file, location may be a file name (%s is the default)\n", _PASSWD_FILE); fprintf(stderr, "for nis, location may be a NIS domainname\n"); + fprintf(stderr, "for opendirectory, location may be a directory node name\n"); exit(1); } @@ -172,11 +178,13 @@ main(int argc, char *argv[]) { char *user, *locn; int i, infosystem; - - infosystem = INFO_NETINFO; + + /* since DS works for most infosystems, make it the default */ + //infosystem = INFO_NETINFO; + infosystem = INFO_DIRECTORYSERVICES; user = NULL; locn = NULL; - + for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-i")) @@ -195,6 +203,7 @@ main(int argc, char *argv[]) else if (!strcmp(argv[i], "nis")) infosystem = INFO_NIS; else if (!strcmp(argv[i], "YP")) infosystem = INFO_NIS; else if (!strcmp(argv[i], "yp")) infosystem = INFO_NIS; + else if (!strcasecmp(argv[i], "opendirectory")) infosystem = INFO_DIRECTORYSERVICES; else { fprintf(stderr, "unknown info system \"%s\"\n", argv[i]); @@ -239,6 +248,9 @@ main(int argc, char *argv[]) case INFO_NIS: nis_passwd(user, locn); break; + case INFO_DIRECTORYSERVICES: + ds_passwd(user, locn); + break; } exit(0); diff --git a/passwd.tproj/stringops.c b/passwd.tproj/stringops.c index 18a9e82..fcf861d 100644 --- a/passwd.tproj/stringops.c +++ b/passwd.tproj/stringops.c @@ -3,29 +3,28 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ #import #import #import -#import +#import #import "stringops.h" char *copyString(char *s) diff --git a/passwd.tproj/stringops.h b/passwd.tproj/stringops.h index 34f9b4f..417a167 100644 --- a/passwd.tproj/stringops.h +++ b/passwd.tproj/stringops.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/pwd_mkdb.tproj/pw_scan.c b/pwd_mkdb.tproj/pw_scan.c index 0f558a1..8e49984 100644 --- a/pwd_mkdb.tproj/pw_scan.c +++ b/pwd_mkdb.tproj/pw_scan.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ @@ -82,7 +81,7 @@ pw_scan(bp, pw) char *bp; struct passwd *pw; { - long id; + uid_t id; int root; char *p, *sh; @@ -95,22 +94,32 @@ pw_scan(bp, pw) if (!(p = strsep(&bp, ":"))) /* uid */ goto fmt; - id = atol(p); + errno = 0; + id = strtoul(p, NULL, 10); + if( (id == 0) && (errno == EINVAL) ) { + warnx("%s did not convert to uid", p); + return(0); + } if (root && id) { warnx("root uid should be 0"); return (0); } - if (id > USHRT_MAX) { - warnx("%s > max uid value (%d)", p, USHRT_MAX); + if ( (id == ULONG_MAX) && (errno == ERANGE) ) { + warnx("%s > max uid value (%d)", p, ULONG_MAX); return (0); } pw->pw_uid = id; if (!(p = strsep(&bp, ":"))) /* gid */ goto fmt; - id = atol(p); - if (id > USHRT_MAX) { - warnx("%s > max gid value (%d)", p, USHRT_MAX); + errno = 0; + id = strtoul(p, NULL, 10); + if( (id == 0) && (errno == EINVAL) ) { + warnx("%s did not convert to gid", p); + return(0); + } + if ( (id == ULONG_MAX) && (errno == ERANGE) ) { + warnx("%s > max gid value (%d)", p, ULONG_MAX); return (0); } pw->pw_gid = id; diff --git a/pwd_mkdb.tproj/pw_scan.h b/pwd_mkdb.tproj/pw_scan.h index 85067f3..55754b6 100644 --- a/pwd_mkdb.tproj/pw_scan.h +++ b/pwd_mkdb.tproj/pw_scan.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/pwd_mkdb.tproj/pwd_mkdb.c b/pwd_mkdb.tproj/pwd_mkdb.c index 5d3d10c..b9acefa 100644 --- a/pwd_mkdb.tproj/pwd_mkdb.c +++ b/pwd_mkdb.tproj/pwd_mkdb.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/reboot.tproj/Makefile.postamble b/reboot.tproj/Makefile.postamble index 374a705..8dbc6d6 100644 --- a/reboot.tproj/Makefile.postamble +++ b/reboot.tproj/Makefile.postamble @@ -1,3 +1,4 @@ -#we already have a halt? -#after_install:: -# $(LN) $(INSTALLED_PRODUCTS) $(DSTROOT)$(INSTALLDIR)/halt +after_install:: + $(LN) $(INSTALLED_PRODUCTS) $(DSTROOT)$(INSTALLDIR)/halt + mkdir -p $(DSTROOT)/usr/share/man/man8 + cp reboot.8 $(DSTROOT)/usr/share/man/man8/ diff --git a/reboot.tproj/reboot.8 b/reboot.tproj/reboot.8 index 2fd2abb..30668d4 100644 --- a/reboot.tproj/reboot.8 +++ b/reboot.tproj/reboot.8 @@ -30,59 +30,70 @@ .\" SUCH DAMAGE. .\" .\" @(#)reboot.8 8.1 (Berkeley) 6/9/93 +.\" $FreeBSD: src/sbin/reboot/reboot.8,v 1.21 2002/12/27 12:15:33 schweikh Exp $ .\" .Dd June 9, 1993 .Dt REBOOT 8 .Os .Sh NAME .Nm reboot , -.Nm halt -.Nd -stopping and restarting the system +.Nm halt +.Nd stopping and restarting the system .Sh SYNOPSIS .Nm halt -.Op Fl nq -.Nm reboot -.Op Fl nq +.Op Fl lnq +.Nm +.Op Fl lnq .Sh DESCRIPTION The .Nm halt and -.Nm reboot +.Nm utilities flush the file system cache to disk, send all running processes -a SIGTERM (and subsequently a SIGKILL) and, respectively, halt or restart -the system. -The action is logged, including entering a shutdown record into the login -accounting file. +a +.Dv SIGTERM +(and subsequently a +.Dv SIGKILL ) +and, respectively, halt or restart the system. +The action is logged, including entering a shutdown record into the +.Xr wtmp 5 +file. .Pp The options are as follows: -.Bl -tag -width Ds +.Bl -tag -width indent +.It Fl l +The halt or reboot is +.Em not +logged to the system log. +This option is intended for applications such as +.Xr shutdown 8 , +that call +.Nm +or +.Nm halt +and log this themselves. .It Fl n -If the -.Fl n -option is specified, -the file system cache is not flushed. +The file system cache is not flushed. This option should probably not be used. .It Fl q -If the -.Fl q -option is specified, -the system is halted or restarted quickly and ungracefully, and only -the flushing of the file system cache is performed. +The system is halted or restarted quickly and ungracefully, and only +the flushing of the file system cache is performed (if the +.Fl n +option is not specified). This option should probably not be used. .El .Pp Normally, the .Xr shutdown 8 utility is used when the system needs to be halted or restarted, giving -users advance warning of their impending doom. +users advance warning of their impending doom and cleanly terminating +specific programs. .Sh SEE ALSO -.Xr sync 1 , -.Xr utmp 5 , -.Xr boot 8 , -.Xr shutdown 8 +.Xr wtmp 5 , +.Xr shutdown 8 , +.Xr sync 8 .Sh HISTORY A -.Nm reboot -command appeared in +.Nm +utility appeared in .At v6 . diff --git a/reboot.tproj/reboot.c b/reboot.tproj/reboot.c index 294634c..f2f0eef 100644 --- a/reboot.tproj/reboot.c +++ b/reboot.tproj/reboot.c @@ -1,30 +1,6 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ /* * Copyright (c) 1980, 1986, 1993 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -36,8 +12,8 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. + * This product includes software developed by the University of + * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -55,46 +31,84 @@ * SUCH DAMAGE. */ +#ifndef lint +static const char copyright[] = +"@(#) Copyright (c) 1980, 1986, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +#if 0 +static char sccsid[] = "@(#)reboot.c 8.1 (Berkeley) 6/5/93"; +#endif +static const char rcsid[] = + "$FreeBSD: src/sbin/reboot/reboot.c,v 1.17 2002/10/06 16:24:36 thomas Exp $"; +#endif /* not lint */ + #include +#include +#include #include -#include +#include #include +#include +#include +#include #include -#include #include #include #include +#include -void err __P((const char *fmt, ...)); -void usage __P((void)); +void usage(void); +u_int get_pageins(void); int dohalt; int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { - register int i; struct passwd *pw; - int ch, howto, lflag, nflag, qflag, sverrno; - char *p, *user; + int ch, howto, i, fd, kflag, lflag, nflag, qflag, pflag, sverrno; + u_int pageins; + char *kernel, *p; + const char *user; - if (!strcmp((p = rindex(*argv, '/')) ? p + 1 : *argv, "halt")) { + if (strstr((p = rindex(*argv, '/')) ? p + 1 : *argv, "halt")) { dohalt = 1; howto = RB_HALT; } else howto = 0; - lflag = nflag = qflag = 0; - while ((ch = getopt(argc, argv, "lnq")) != EOF) + kflag = lflag = nflag = qflag = 0; +#ifndef __APPLE__ + while ((ch = getopt(argc, argv, "dk:lnpq")) != -1) +#else + while ((ch = getopt(argc, argv, "k:lnq")) != -1) +#endif switch(ch) { - case 'l': /* Undocumented; used by shutdown. */ +#ifndef __APPLE__ + case 'd': + howto |= RB_DUMP; + break; +#endif + case 'k': + kflag = 1; + kernel = optarg; + break; + case 'l': lflag = 1; break; case 'n': nflag = 1; howto |= RB_NOSYNC; break; +/* -p is irrelevant on OS X. It does that anyway. */ +#ifndef __APPLE__ + case 'p': + pflag = 1; + howto |= RB_POWEROFF; + break; +#endif case 'q': qflag = 1; break; @@ -105,12 +119,29 @@ main(argc, argv) argc -= optind; argv += optind; - if (geteuid()) - err("%s", strerror(EPERM)); +#ifndef __APPLE__ + if ((howto & (RB_DUMP | RB_HALT)) == (RB_DUMP | RB_HALT)) + errx(1, "cannot dump (-d) when halting; must reboot instead"); +#endif + if (geteuid()) { + errno = EPERM; + err(1, NULL); + } if (qflag) { reboot(howto); - err("%s", strerror(errno)); + err(1, NULL); + } + + if (kflag) { + fd = open("/boot/nextboot.conf", O_WRONLY | O_CREAT, 0444); + if (fd > -1) { + (void)write(fd, "nextboot_enable=\"YES\"\n", 22); + (void)write(fd, "kernel=\"", 8L); + (void)write(fd, kernel, strlen(kernel)); + (void)write(fd, "\"\n", 2); + close(fd); + } } /* Log the reboot. */ @@ -138,25 +169,32 @@ main(argc, argv) /* Just stop init -- if we fail, we'll restart it. */ if (kill(1, SIGTSTP) == -1) - err("SIGTSTP init: %s", strerror(errno)); + err(1, "SIGTSTP init"); /* Ignore the SIGHUP we get when our parent shell dies. */ (void)signal(SIGHUP, SIG_IGN); -#if 0 +#ifndef __APPLE__ /* Send a SIGTERM first, a chance to save the buffers. */ if (kill(-1, SIGTERM) == -1) - err("SIGTERM processes: %s", strerror(errno)); + err(1, "SIGTERM processes"); /* * After the processes receive the signal, start the rest of the * buffers on their way. Wait 5 seconds between the SIGTERM and - * the SIGKILL to give everybody a chance. + * the SIGKILL to give everybody a chance. If there is a lot of + * paging activity then wait longer, up to a maximum of approx + * 60 seconds. */ sleep(2); - if (!nflag) - sync(); - sleep(3); + for (i = 0; i < 20; i++) { + pageins = get_pageins(); + if (!nflag) + sync(); + sleep(3); + if (get_pageins() == pageins) + break; + } for (i = 1;; ++i) { if (kill(-1, SIGKILL) == -1) { @@ -172,12 +210,13 @@ main(argc, argv) (void)sleep(2 * i); } #endif + reboot(howto); /* FALLTHROUGH */ restart: sverrno = errno; - err("%s%s", kill(1, SIGHUP) == -1 ? "(can't restart init): " : "", + errx(1, "%s%s", kill(1, SIGHUP) == -1 ? "(can't restart init): " : "", strerror(sverrno)); /* NOTREACHED */ } @@ -185,35 +224,22 @@ restart: void usage() { - (void)fprintf(stderr, "usage: %s [-nq]\n", dohalt ? "halt" : "reboot"); + (void)fprintf(stderr, "usage: %s [-dnpq] [-k kernel]\n", + dohalt ? "halt" : "reboot"); exit(1); } -#if __STDC__ -#include -#else -#include -#endif - -void -#if __STDC__ -err(const char *fmt, ...) -#else -err(fmt, va_alist) - char *fmt; - va_dcl -#endif +u_int +get_pageins() { - va_list ap; -#if __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - (void)fprintf(stderr, "%s: ", dohalt ? "halt" : "reboot"); - (void)vfprintf(stderr, fmt, ap); - va_end(ap); - (void)fprintf(stderr, "\n"); - exit(1); - /* NOTREACHED */ + u_int pageins; + size_t len; + + len = sizeof(pageins); + if (sysctlbyname("vm.stats.vm.v_swappgsin", &pageins, &len, NULL, 0) + != 0) { + warnx("v_swappgsin"); + return (0); + } + return pageins; } diff --git a/top.tproj/Makefile b/sa.tproj/Makefile similarity index 65% rename from top.tproj/Makefile rename to sa.tproj/Makefile index b9c6003..ba8402d 100644 --- a/top.tproj/Makefile +++ b/sa.tproj/Makefile @@ -7,14 +7,15 @@ # and Makefile.postamble (both optional), and Makefile will include them. # -NAME = top +NAME = sa PROJECTVERSION = 2.8 PROJECT_TYPE = Tool -CFILES = top.c +CFILES = main.c pdb.c usrdb.c -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble top.1 +OTHERSRCS = Makefile.preamble Makefile Makefile.postamble extern.h pathnames.h \ + sa.8 MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles @@ -22,14 +23,16 @@ CODE_GEN_STYLE = DYNAMIC MAKEFILE = tool.make NEXTSTEP_INSTALLDIR = /usr/bin WINDOWS_INSTALLDIR = /Library/Executables -PDO_UNIX_INSTALLDIR = /usr/bin +PDO_UNIX_INSTALLDIR = /bin LIBS = -lcurses DEBUG_LIBS = $(LIBS) PROF_LIBS = $(LIBS) -FRAMEWORKS = -framework CoreFoundation -framework IOKit - +HEADER_PATHS = -I$(NEXT_ROOT)/System/Library/System.framework/\ + -I$(NEXT_ROOT)/System/Library/Frameworks/System.framework/PrivateHeaders\ + -I$(NEXT_ROOT)/System/Library/Frameworks/System.framework/PrivateHeaders/bsd\ + -I$(NEXT_ROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders/bsd NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc WINDOWS_OBJCPLUS_COMPILER = $(DEVDIR)/gcc diff --git a/top.tproj/Makefile.postamble b/sa.tproj/Makefile.postamble similarity index 97% rename from top.tproj/Makefile.postamble rename to sa.tproj/Makefile.postamble index 5b674d4..864cfa1 100644 --- a/top.tproj/Makefile.postamble +++ b/sa.tproj/Makefile.postamble @@ -80,7 +80,7 @@ # User/group ownership #INSTALL_AS_GROUP = wheel # (probably want to set both of these) -INSTALL_PERMISSIONS = 4555 +#INSTALL_PERMISSIONS = 4555 # If set, 'install' chmod's executable to this @@ -100,5 +100,5 @@ INSTALL_PERMISSIONS = 4555 # install-man-page: - install -d $(DSTROOT)/usr/share/man/man1 - install -c -m 444 top.1 $(DSTROOT)/usr/share/man/man1/top.1 + install -d $(DSTROOT)/usr/share/man/man8 + install -c -m 444 sa.8 $(DSTROOT)/usr/share/man/man8/sa.8 diff --git a/top.tproj/Makefile.preamble b/sa.tproj/Makefile.preamble similarity index 99% rename from top.tproj/Makefile.preamble rename to sa.tproj/Makefile.preamble index 44fbaaa..a4606c6 100644 --- a/top.tproj/Makefile.preamble +++ b/sa.tproj/Makefile.preamble @@ -137,3 +137,4 @@ DSTROOT = $(HOME) AFTER_INSTALL += install-man-page + diff --git a/top.tproj/PB.project b/sa.tproj/PB.project similarity index 67% rename from top.tproj/PB.project rename to sa.tproj/PB.project index 8068b70..0158f5a 100644 --- a/top.tproj/PB.project +++ b/sa.tproj/PB.project @@ -1,22 +1,22 @@ { DYNAMIC_CODE_GEN = YES; FILESTABLE = { - FRAMEWORKS = (CoreFoundation.framework, IOKit.framework); - H_FILES = (); - OTHER_LINKED = (top.c); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble, top.1); + HEADERSEARCH = ("$(NEXT_ROOT)/System/Library/Frameworks/System.framework/PrivateHeaders/bsd"); + OTHER_LINKED = (main.c, pdb.c, usrdb.c); + OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble, sa.8, extern.h, pathnames.h); }; LANGUAGE = English; MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; NEXTSTEP_BUILDTOOL = /bin/gnumake; + NEXTSTEP_COMPILEROPTIONS = "-DKERNEL_PRIVATE"; NEXTSTEP_INSTALLDIR = /usr/bin; NEXTSTEP_JAVA_COMPILER = /usr/bin/javac; NEXTSTEP_OBJCPLUS_COMPILER = /usr/bin/cc; - PDO_UNIX_BUILDTOOL = /bin/gnumake; - PDO_UNIX_INSTALLDIR = /usr/bin; + PDO_UNIX_BUILDTOOL = $NEXT_ROOT/Developer/bin/make; + PDO_UNIX_INSTALLDIR = /bin; PDO_UNIX_JAVA_COMPILER = "$(JDKBINDIR)/javac"; PDO_UNIX_OBJCPLUS_COMPILER = "$(NEXTDEV_BIN)/gcc"; - PROJECTNAME = top; + PROJECTNAME = sa; PROJECTTYPE = Tool; PROJECTVERSION = 2.8; WINDOWS_BUILDTOOL = $NEXT_ROOT/Developer/Executables/make; diff --git a/sa.tproj/extern.h b/sa.tproj/extern.h new file mode 100644 index 0000000..f77282b --- /dev/null +++ b/sa.tproj/extern.h @@ -0,0 +1,97 @@ +/* + * Copyright (c) 1994 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christopher G. Demetriou. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD: src/usr.sbin/sa/extern.h,v 1.5 2002/07/11 22:11:20 alfred Exp $ + */ + +#include +#include +#include + +/* structures */ + +struct cmdinfo { + char ci_comm[MAXCOMLEN+2]; /* command name (+ '*') */ + u_long ci_uid; /* user id */ + u_quad_t ci_calls; /* number of calls */ + u_quad_t ci_etime; /* elapsed time */ + u_quad_t ci_utime; /* user time */ + u_quad_t ci_stime; /* system time */ + u_quad_t ci_mem; /* memory use */ + u_quad_t ci_io; /* number of disk i/o ops */ + u_int ci_flags; /* flags; see below */ +}; +#define CI_UNPRINTABLE 0x0001 /* unprintable chars in name */ + +struct userinfo { + u_long ui_uid; /* user id; for consistency */ + u_quad_t ui_calls; /* number of invocations */ + u_quad_t ui_utime; /* user time */ + u_quad_t ui_stime; /* system time */ + u_quad_t ui_mem; /* memory use */ + u_quad_t ui_io; /* number of disk i/o ops */ +}; + +/* typedefs */ + +typedef int (*cmpf_t)(const DBT *, const DBT *); + +/* external functions in pdb.c */ +int pacct_init(void); +void pacct_destroy(void); +int pacct_add(const struct cmdinfo *); +int pacct_update(void); +void pacct_print(void); + +/* external functions in usrdb.c */ +int usracct_init(void); +void usracct_destroy(void); +int usracct_add(const struct cmdinfo *); +int usracct_update(void); +void usracct_print(void); + +/* variables */ + +extern int aflag, bflag, cflag, dflag, Dflag, fflag, iflag, jflag, kflag; +extern int Kflag, lflag, mflag, qflag, rflag, sflag, tflag, uflag, vflag; +extern u_quad_t cutoff; +extern cmpf_t sa_cmp; + +/* some #defines to help with db's stupidity */ + +#define DB_CLOSE(db) \ + ((*(db)->close)(db)) +#define DB_GET(db, key, data, flags) \ + ((*(db)->get)((db), (key), (data), (flags))) +#define DB_PUT(db, key, data, flags) \ + ((*(db)->put)((db), (key), (data), (flags))) +#define DB_SYNC(db, flags) \ + ((*(db)->sync)((db), (flags))) +#define DB_SEQ(db, key, data, flags) \ + ((*(db)->seq)((db), (key), (data), (flags))) diff --git a/sa.tproj/main.c b/sa.tproj/main.c new file mode 100644 index 0000000..4bc068d --- /dev/null +++ b/sa.tproj/main.c @@ -0,0 +1,556 @@ +/* + * Copyright (c) 1994 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christopher G. Demetriou. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef lint +static const char copyright[] = +"@(#) Copyright (c) 1994 Christopher G. Demetriou\n\ + All rights reserved.\n"; +#endif + +#ifndef lint +static const char rcsid[] = + "$FreeBSD: src/usr.sbin/sa/main.c,v 1.12 2002/07/15 16:05:15 des Exp $"; +#endif /* not lint */ + +/* + * sa: system accounting + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "extern.h" +#include "pathnames.h" + +static int acct_load(char *, int); +static u_quad_t decode_comp_t(comp_t); +static int cmp_comm(const char *, const char *); +static int cmp_usrsys(const DBT *, const DBT *); +static int cmp_avgusrsys(const DBT *, const DBT *); +static int cmp_dkio(const DBT *, const DBT *); +static int cmp_avgdkio(const DBT *, const DBT *); +static int cmp_cpumem(const DBT *, const DBT *); +static int cmp_avgcpumem(const DBT *, const DBT *); +static int cmp_calls(const DBT *, const DBT *); +static void usage(void); + +int aflag, bflag, cflag, dflag, Dflag, fflag, iflag, jflag, kflag; +int Kflag, lflag, mflag, qflag, rflag, sflag, tflag, uflag, vflag; +u_quad_t cutoff = 1; + +static char *dfltargv[] = { NULL }; +static int dfltargc = (sizeof dfltargv/sizeof(char *)); + +/* default to comparing by sum of user + system time */ +cmpf_t sa_cmp = cmp_usrsys; + +int +main(int argc, char **argv) +{ + char ch; + char pathacct[] = _PATH_ACCT; + int error = 0; + + dfltargv[0] = pathacct; + + while ((ch = getopt(argc, argv, "abcdDfijkKlmnqrstuv:")) != -1) + switch (ch) { + case 'a': + /* print all commands */ + aflag = 1; + break; + case 'b': + /* sort by per-call user/system time average */ + bflag = 1; + sa_cmp = cmp_avgusrsys; + break; + case 'c': + /* print percentage total time */ + cflag = 1; + break; + case 'd': + /* sort by averge number of disk I/O ops */ + dflag = 1; + sa_cmp = cmp_avgdkio; + break; + case 'D': + /* print and sort by total disk I/O ops */ + Dflag = 1; + sa_cmp = cmp_dkio; + break; + case 'f': + /* force no interactive threshold comprison */ + fflag = 1; + break; + case 'i': + /* do not read in summary file */ + iflag = 1; + break; + case 'j': + /* instead of total minutes, give sec/call */ + jflag = 1; + break; + case 'k': + /* sort by cpu-time average memory usage */ + kflag = 1; + sa_cmp = cmp_avgcpumem; + break; + case 'K': + /* print and sort by cpu-storage integral */ + sa_cmp = cmp_cpumem; + Kflag = 1; + break; + case 'l': + /* separate system and user time */ + lflag = 1; + break; + case 'm': + /* print procs and time per-user */ + mflag = 1; + break; + case 'n': + /* sort by number of calls */ + sa_cmp = cmp_calls; + break; + case 'q': + /* quiet; error messages only */ + qflag = 1; + break; + case 'r': + /* reverse order of sort */ + rflag = 1; + break; + case 's': + /* merge accounting file into summaries */ + sflag = 1; + break; + case 't': + /* report ratio of user and system times */ + tflag = 1; + break; + case 'u': + /* first, print uid and command name */ + uflag = 1; + break; + case 'v': + /* cull junk */ + vflag = 1; + cutoff = atoi(optarg); + break; + case '?': + default: + usage(); + } + + argc -= optind; + argv += optind; + + /* various argument checking */ + if (fflag && !vflag) + errx(1, "only one of -f requires -v"); + if (fflag && aflag) + errx(1, "only one of -a and -v may be specified"); + /* XXX need more argument checking */ + + if (!uflag) { + /* initialize tables */ + if ((sflag || (!mflag && !qflag)) && pacct_init() != 0) + errx(1, "process accounting initialization failed"); + if ((sflag || (mflag && !qflag)) && usracct_init() != 0) + errx(1, "user accounting initialization failed"); + } + + if (argc == 0) { + argc = dfltargc; + argv = dfltargv; + } + + /* for each file specified */ + for (; argc > 0; argc--, argv++) { + int fd; + + /* + * load the accounting data from the file. + * if it fails, go on to the next file. + */ + fd = acct_load(argv[0], sflag); + if (fd < 0) + continue; + + if (!uflag && sflag) { +#ifndef DEBUG + sigset_t nmask, omask; + int unmask = 1; + + /* + * block most signals so we aren't interrupted during + * the update. + */ + if (sigfillset(&nmask) == -1) { + warn("sigfillset"); + unmask = 0; + error = 1; + } + if (unmask && + (sigprocmask(SIG_BLOCK, &nmask, &omask) == -1)) { + warn("couldn't set signal mask"); + unmask = 0; + error = 1; + } +#endif /* DEBUG */ + + /* + * truncate the accounting data file ASAP, to avoid + * losing data. don't worry about errors in updating + * the saved stats; better to underbill than overbill, + * but we want every accounting record intact. + */ + if (ftruncate(fd, 0) == -1) { + warn("couldn't truncate %s", *argv); + error = 1; + } + + /* + * update saved user and process accounting data. + * note errors for later. + */ + if (pacct_update() != 0 || usracct_update() != 0) + error = 1; + +#ifndef DEBUG + /* + * restore signals + */ + if (unmask && + (sigprocmask(SIG_SETMASK, &omask, NULL) == -1)) { + warn("couldn't restore signal mask"); + error = 1; + } +#endif /* DEBUG */ + } + + /* + * close the opened accounting file + */ + if (close(fd) == -1) { + warn("close %s", *argv); + error = 1; + } + } + + if (!uflag && !qflag) { + /* print any results we may have obtained. */ + if (!mflag) + pacct_print(); + else + usracct_print(); + } + + if (!uflag) { + /* finally, deallocate databases */ + if (sflag || (!mflag && !qflag)) + pacct_destroy(); + if (sflag || (mflag && !qflag)) + usracct_destroy(); + } + + exit(error); +} + +static void +usage() +{ + (void)fprintf(stderr, + "usage: sa [-abcdDfijkKlmnqrstu] [-v cutoff] [file ...]\n"); + exit(1); +} + +static int +acct_load(pn, wr) + char *pn; + int wr; +{ + struct acct ac; + struct cmdinfo ci; + ssize_t rv; + int fd, i; + + /* + * open the file + */ + fd = open(pn, wr ? O_RDWR : O_RDONLY, 0); + if (fd == -1) { + warn("open %s %s", pn, wr ? "for read/write" : "read-only"); + return (-1); + } + + /* + * read all we can; don't stat and open because more processes + * could exit, and we'd miss them + */ + while (1) { + /* get one accounting entry and punt if there's an error */ + rv = read(fd, &ac, sizeof(struct acct)); + if (rv == -1) + warn("error reading %s", pn); + else if (rv > 0 && rv < (int)sizeof(struct acct)) + warnx("short read of accounting data in %s", pn); + if (rv != sizeof(struct acct)) + break; + + /* decode it */ + ci.ci_calls = 1; + for (i = 0; i < (int)sizeof ac.ac_comm && ac.ac_comm[i] != '\0'; + i++) { + char c = ac.ac_comm[i]; + + if (!isascii(c) || iscntrl(c)) { + ci.ci_comm[i] = '?'; + ci.ci_flags |= CI_UNPRINTABLE; + } else + ci.ci_comm[i] = c; + } + if (ac.ac_flag & AFORK) + ci.ci_comm[i++] = '*'; + ci.ci_comm[i++] = '\0'; + ci.ci_etime = decode_comp_t(ac.ac_etime); + ci.ci_utime = decode_comp_t(ac.ac_utime); + ci.ci_stime = decode_comp_t(ac.ac_stime); + ci.ci_uid = ac.ac_uid; + ci.ci_mem = ac.ac_mem; + ci.ci_io = decode_comp_t(ac.ac_io) / AHZ; + + if (!uflag) { + /* and enter it into the usracct and pacct databases */ + if (sflag || (!mflag && !qflag)) + pacct_add(&ci); + if (sflag || (mflag && !qflag)) + usracct_add(&ci); + } else if (!qflag) + printf("%6lu %12.2f cpu %12juk mem %12ju io %s\n", + ci.ci_uid, + (ci.ci_utime + ci.ci_stime) / (double) AHZ, + (uintmax_t)ci.ci_mem, (uintmax_t)ci.ci_io, + ci.ci_comm); + } + + /* finally, return the file descriptor for possible truncation */ + return (fd); +} + +static u_quad_t +decode_comp_t(comp) + comp_t comp; +{ + u_quad_t rv; + + /* + * for more info on the comp_t format, see: + * /usr/src/sys/kern/kern_acct.c + * /usr/src/sys/sys/acct.h + * /usr/src/usr.bin/lastcomm/lastcomm.c + */ + rv = comp & 0x1fff; /* 13 bit fraction */ + comp >>= 13; /* 3 bit base-8 exponent */ + while (comp--) + rv <<= 3; + + return (rv); +} + +/* sort commands, doing the right thing in terms of reversals */ +static int +cmp_comm(s1, s2) + const char *s1, *s2; +{ + int rv; + + rv = strcmp(s1, s2); + if (rv == 0) + rv = -1; + return (rflag ? rv : -rv); +} + +/* sort by total user and system time */ +static int +cmp_usrsys(d1, d2) + const DBT *d1, *d2; +{ + struct cmdinfo c1, c2; + u_quad_t t1, t2; + + memcpy(&c1, d1->data, sizeof(c1)); + memcpy(&c2, d2->data, sizeof(c2)); + + t1 = c1.ci_utime + c1.ci_stime; + t2 = c2.ci_utime + c2.ci_stime; + + if (t1 < t2) + return -1; + else if (t1 == t2) + return (cmp_comm(c1.ci_comm, c2.ci_comm)); + else + return 1; +} + +/* sort by average user and system time */ +static int +cmp_avgusrsys(d1, d2) + const DBT *d1, *d2; +{ + struct cmdinfo c1, c2; + double t1, t2; + + memcpy(&c1, d1->data, sizeof(c1)); + memcpy(&c2, d2->data, sizeof(c2)); + + t1 = c1.ci_utime + c1.ci_stime; + t1 /= (double) (c1.ci_calls ? c1.ci_calls : 1); + + t2 = c2.ci_utime + c2.ci_stime; + t2 /= (double) (c2.ci_calls ? c2.ci_calls : 1); + + if (t1 < t2) + return -1; + else if (t1 == t2) + return (cmp_comm(c1.ci_comm, c2.ci_comm)); + else + return 1; +} + +/* sort by total number of disk I/O operations */ +static int +cmp_dkio(d1, d2) + const DBT *d1, *d2; +{ + struct cmdinfo c1, c2; + + memcpy(&c1, d1->data, sizeof(c1)); + memcpy(&c2, d2->data, sizeof(c2)); + + if (c1.ci_io < c2.ci_io) + return -1; + else if (c1.ci_io == c2.ci_io) + return (cmp_comm(c1.ci_comm, c2.ci_comm)); + else + return 1; +} + +/* sort by average number of disk I/O operations */ +static int +cmp_avgdkio(d1, d2) + const DBT *d1, *d2; +{ + struct cmdinfo c1, c2; + double n1, n2; + + memcpy(&c1, d1->data, sizeof(c1)); + memcpy(&c2, d2->data, sizeof(c2)); + + n1 = (double) c1.ci_io / (double) (c1.ci_calls ? c1.ci_calls : 1); + n2 = (double) c2.ci_io / (double) (c2.ci_calls ? c2.ci_calls : 1); + + if (n1 < n2) + return -1; + else if (n1 == n2) + return (cmp_comm(c1.ci_comm, c2.ci_comm)); + else + return 1; +} + +/* sort by the cpu-storage integral */ +static int +cmp_cpumem(d1, d2) + const DBT *d1, *d2; +{ + struct cmdinfo c1, c2; + + memcpy(&c1, d1->data, sizeof(c1)); + memcpy(&c2, d2->data, sizeof(c2)); + + if (c1.ci_mem < c2.ci_mem) + return -1; + else if (c1.ci_mem == c2.ci_mem) + return (cmp_comm(c1.ci_comm, c2.ci_comm)); + else + return 1; +} + +/* sort by the cpu-time average memory usage */ +static int +cmp_avgcpumem(d1, d2) + const DBT *d1, *d2; +{ + struct cmdinfo c1, c2; + u_quad_t t1, t2; + double n1, n2; + + memcpy(&c1, d1->data, sizeof(c1)); + memcpy(&c2, d2->data, sizeof(c2)); + + t1 = c1.ci_utime + c1.ci_stime; + t2 = c2.ci_utime + c2.ci_stime; + + n1 = (double) c1.ci_mem / (double) (t1 ? t1 : 1); + n2 = (double) c2.ci_mem / (double) (t2 ? t2 : 1); + + if (n1 < n2) + return -1; + else if (n1 == n2) + return (cmp_comm(c1.ci_comm, c2.ci_comm)); + else + return 1; +} + +/* sort by the number of invocations */ +static int +cmp_calls(d1, d2) + const DBT *d1, *d2; +{ + struct cmdinfo c1, c2; + + memcpy(&c1, d1->data, sizeof(c1)); + memcpy(&c2, d2->data, sizeof(c2)); + + if (c1.ci_calls < c2.ci_calls) + return -1; + else if (c1.ci_calls == c2.ci_calls) + return (cmp_comm(c1.ci_comm, c2.ci_comm)); + else + return 1; +} diff --git a/sa.tproj/pathnames.h b/sa.tproj/pathnames.h new file mode 100644 index 0000000..8cb7f44 --- /dev/null +++ b/sa.tproj/pathnames.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 1994 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christopher G. Demetriou. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD: src/usr.sbin/sa/pathnames.h,v 1.4 1999/08/28 01:19:52 peter Exp $ + */ + +#define _PATH_ACCT "/var/account/acct" +#define _PATH_SAVACCT "/var/account/savacct" +#define _PATH_USRACCT "/var/account/usracct" diff --git a/sa.tproj/pdb.c b/sa.tproj/pdb.c new file mode 100644 index 0000000..f0dd48b --- /dev/null +++ b/sa.tproj/pdb.c @@ -0,0 +1,424 @@ +/* + * Copyright (c) 1994 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christopher G. Demetriou. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef lint +static const char rcsid[] = + "$FreeBSD: src/usr.sbin/sa/pdb.c,v 1.9 2002/07/15 16:05:15 des Exp $"; +#endif /* not lint */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "extern.h" +#include "pathnames.h" + +static int check_junk __P((struct cmdinfo *)); +static void add_ci __P((const struct cmdinfo *, struct cmdinfo *)); +static void print_ci __P((const struct cmdinfo *, const struct cmdinfo *)); + +static DB *pacct_db; + +int +pacct_init() +{ + DB *saved_pacct_db; + int error; + + pacct_db = dbopen(NULL, O_RDWR, 0, DB_BTREE, NULL); + if (pacct_db == NULL) + return (-1); + + error = 0; + if (!iflag) { + DBT key, data; + int serr, nerr; + + saved_pacct_db = dbopen(_PATH_SAVACCT, O_RDONLY, 0, DB_BTREE, + NULL); + if (saved_pacct_db == NULL) { + error = errno == ENOENT ? 0 : -1; + if (error) + warn("retrieving process accounting summary"); + goto out; + } + + serr = DB_SEQ(saved_pacct_db, &key, &data, R_FIRST); + if (serr < 0) { + warn("retrieving process accounting summary"); + error = -1; + goto closeout; + } + while (serr == 0) { + nerr = DB_PUT(pacct_db, &key, &data, 0); + if (nerr < 0) { + warn("initializing process accounting stats"); + error = -1; + break; + } + + serr = DB_SEQ(saved_pacct_db, &key, &data, R_NEXT); + if (serr < 0) { + warn("retrieving process accounting summary"); + error = -1; + break; + } + } + +closeout: if (DB_CLOSE(saved_pacct_db) < 0) { + warn("closing process accounting summary"); + error = -1; + } + } + +out: if (error != 0) + pacct_destroy(); + return (error); +} + +void +pacct_destroy() +{ + if (DB_CLOSE(pacct_db) < 0) + warn("destroying process accounting stats"); +} + +int +pacct_add(ci) + const struct cmdinfo *ci; +{ + DBT key, data; + struct cmdinfo newci; + char keydata[sizeof ci->ci_comm]; + int rv; + + bcopy(ci->ci_comm, &keydata, sizeof keydata); + key.data = &keydata; + key.size = strlen(keydata); + + rv = DB_GET(pacct_db, &key, &data, 0); + if (rv < 0) { + warn("get key %s from process accounting stats", ci->ci_comm); + return (-1); + } else if (rv == 0) { /* it's there; copy whole thing */ + /* XXX compare size if paranoid */ + /* add the old data to the new data */ + bcopy(data.data, &newci, data.size); + } else { /* it's not there; zero it and copy the key */ + bzero(&newci, sizeof newci); + bcopy(key.data, newci.ci_comm, key.size); + } + + add_ci(ci, &newci); + + data.data = &newci; + data.size = sizeof newci; + rv = DB_PUT(pacct_db, &key, &data, 0); + if (rv < 0) { + warn("add key %s to process accounting stats", ci->ci_comm); + return (-1); + } else if (rv == 1) { + warnx("duplicate key %s in process accounting stats", + ci->ci_comm); + return (-1); + } + + return (0); +} + +int +pacct_update() +{ + DB *saved_pacct_db; + DBT key, data; + int error, serr, nerr; + + saved_pacct_db = dbopen(_PATH_SAVACCT, O_RDWR|O_CREAT|O_TRUNC, 0644, + DB_BTREE, NULL); + if (saved_pacct_db == NULL) { + warn("creating process accounting summary"); + return (-1); + } + + error = 0; + + serr = DB_SEQ(pacct_db, &key, &data, R_FIRST); + if (serr < 0) { + warn("retrieving process accounting stats"); + error = -1; + } + while (serr == 0) { + nerr = DB_PUT(saved_pacct_db, &key, &data, 0); + if (nerr < 0) { + warn("saving process accounting summary"); + error = -1; + break; + } + + serr = DB_SEQ(pacct_db, &key, &data, R_NEXT); + if (serr < 0) { + warn("retrieving process accounting stats"); + error = -1; + break; + } + } + + if (DB_SYNC(saved_pacct_db, 0) < 0) { + warn("syncing process accounting summary"); + error = -1; + } + if (DB_CLOSE(saved_pacct_db) < 0) { + warn("closing process accounting summary"); + error = -1; + } + return error; +} + +void +pacct_print() +{ + BTREEINFO bti; + DBT key, data, ndata; + DB *output_pacct_db; + struct cmdinfo *cip, ci, ci_total, ci_other, ci_junk; + int rv; + + bzero(&ci_total, sizeof ci_total); + strcpy(ci_total.ci_comm, ""); + bzero(&ci_other, sizeof ci_other); + strcpy(ci_other.ci_comm, "***other"); + bzero(&ci_junk, sizeof ci_junk); + strcpy(ci_junk.ci_comm, "**junk**"); + + /* + * Retrieve them into new DB, sorted by appropriate key. + * At the same time, cull 'other' and 'junk' + */ + bzero(&bti, sizeof bti); + bti.compare = sa_cmp; + output_pacct_db = dbopen(NULL, O_RDWR, 0, DB_BTREE, &bti); + if (output_pacct_db == NULL) { + warn("couldn't sort process accounting stats"); + return; + } + + ndata.data = NULL; + ndata.size = 0; + rv = DB_SEQ(pacct_db, &key, &data, R_FIRST); + if (rv < 0) + warn("retrieving process accounting stats"); + while (rv == 0) { + cip = (struct cmdinfo *) data.data; + bcopy(cip, &ci, sizeof ci); + + /* add to total */ + add_ci(&ci, &ci_total); + + if (vflag && ci.ci_calls <= cutoff && + (fflag || check_junk(&ci))) { + /* put it into **junk** */ + add_ci(&ci, &ci_junk); + goto next; + } + if (!aflag && + ((ci.ci_flags & CI_UNPRINTABLE) != 0 || ci.ci_calls <= 1)) { + /* put into ***other */ + add_ci(&ci, &ci_other); + goto next; + } + rv = DB_PUT(output_pacct_db, &data, &ndata, 0); + if (rv < 0) + warn("sorting process accounting stats"); + +next: rv = DB_SEQ(pacct_db, &key, &data, R_NEXT); + if (rv < 0) + warn("retrieving process accounting stats"); + } + + /* insert **junk** and ***other */ + if (ci_junk.ci_calls != 0) { + data.data = &ci_junk; + data.size = sizeof ci_junk; + rv = DB_PUT(output_pacct_db, &data, &ndata, 0); + if (rv < 0) + warn("sorting process accounting stats"); + } + if (ci_other.ci_calls != 0) { + data.data = &ci_other; + data.size = sizeof ci_other; + rv = DB_PUT(output_pacct_db, &data, &ndata, 0); + if (rv < 0) + warn("sorting process accounting stats"); + } + + /* print out the total */ + print_ci(&ci_total, &ci_total); + + /* print out; if reversed, print first (smallest) first */ + rv = DB_SEQ(output_pacct_db, &data, &ndata, rflag ? R_FIRST : R_LAST); + if (rv < 0) + warn("retrieving process accounting report"); + while (rv == 0) { + cip = (struct cmdinfo *) data.data; + bcopy(cip, &ci, sizeof ci); + + print_ci(&ci, &ci_total); + + rv = DB_SEQ(output_pacct_db, &data, &ndata, + rflag ? R_NEXT : R_PREV); + if (rv < 0) + warn("retrieving process accounting report"); + } + DB_CLOSE(output_pacct_db); +} + +static int +check_junk(cip) + struct cmdinfo *cip; +{ + char *cp; + size_t len; + + fprintf(stderr, "%s (%ju) -- ", cip->ci_comm, (uintmax_t)cip->ci_calls); + cp = fgetln(stdin, &len); + + return (cp && (cp[0] == 'y' || cp[0] == 'Y')) ? 1 : 0; +} + +static void +add_ci(fromcip, tocip) + const struct cmdinfo *fromcip; + struct cmdinfo *tocip; +{ + tocip->ci_calls += fromcip->ci_calls; + tocip->ci_etime += fromcip->ci_etime; + tocip->ci_utime += fromcip->ci_utime; + tocip->ci_stime += fromcip->ci_stime; + tocip->ci_mem += fromcip->ci_mem; + tocip->ci_io += fromcip->ci_io; +} + +static void +print_ci(cip, totalcip) + const struct cmdinfo *cip, *totalcip; +{ + double t, c; + int uflow; + + c = cip->ci_calls ? cip->ci_calls : 1; + t = (cip->ci_utime + cip->ci_stime) / (double) AHZ; + if (t < 0.01) { + t = 0.01; + uflow = 1; + } else + uflow = 0; + + printf("%8ju ", (uintmax_t)cip->ci_calls); + if (cflag) { + if (cip != totalcip) + printf(" %4.2f%% ", + cip->ci_calls / (double) totalcip->ci_calls); + else + printf(" %4s ", ""); + } + + if (jflag) + printf("%11.2fre ", cip->ci_etime / (double) (AHZ * c)); + else + printf("%11.2fre ", cip->ci_etime / (60.0 * AHZ)); + if (cflag) { + if (cip != totalcip) + printf(" %4.2f%% ", + cip->ci_etime / (double) totalcip->ci_etime); + else + printf(" %4s ", ""); + } + + if (!lflag) { + if (jflag) + printf("%11.2fcp ", t / (double) cip->ci_calls); + else + printf("%11.2fcp ", t / 60.0); + if (cflag) { + if (cip != totalcip) + printf(" %4.2f%% ", + (cip->ci_utime + cip->ci_stime) / (double) + (totalcip->ci_utime + totalcip->ci_stime)); + else + printf(" %4s ", ""); + } + } else { + if (jflag) + printf("%11.2fu ", cip->ci_utime / (double) (AHZ * c)); + else + printf("%11.2fu ", cip->ci_utime / (60.0 * AHZ)); + if (cflag) { + if (cip != totalcip) + printf(" %4.2f%% ", cip->ci_utime / (double) totalcip->ci_utime); + else + printf(" %4s ", ""); + } + if (jflag) + printf("%11.2fs ", cip->ci_stime / (double) (AHZ * c)); + else + printf("%11.2fs ", cip->ci_stime / (60.0 * AHZ)); + if (cflag) { + if (cip != totalcip) + printf(" %4.2f%% ", cip->ci_stime / (double) totalcip->ci_stime); + else + printf(" %4s ", ""); + } + } + + if (tflag) { + if (!uflow) + printf("%8.2fre/cp ", + cip->ci_etime / + (double) (cip->ci_utime + cip->ci_stime)); + else + printf("*ignore* "); + } + + if (Dflag) + printf("%10jutio ", (uintmax_t)cip->ci_io); + else + printf("%8.0favio ", cip->ci_io / c); + + if (Kflag) + printf("%10juk*sec ", (uintmax_t)cip->ci_mem); + else + printf("%8.0fk ", cip->ci_mem / t); + + printf(" %s\n", cip->ci_comm); +} diff --git a/sa.tproj/sa.8 b/sa.tproj/sa.8 new file mode 100644 index 0000000..4ba9503 --- /dev/null +++ b/sa.tproj/sa.8 @@ -0,0 +1,237 @@ +.\" +.\" Copyright (c) 1994 Christopher G. Demetriou +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by Christopher G. Demetriou. +.\" 3. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $FreeBSD: src/usr.sbin/sa/sa.8,v 1.15 2002/07/14 14:46:01 charnier Exp $ +.\" +.Dd February 25, 1994 +.Dt SA 8 +.Os +.Sh NAME +.Nm sa +.Nd print system accounting statistics +.Sh SYNOPSIS +.Nm +.Op Fl abcdDfijkKlmnqrstu +.Op Fl v Ar cutoff +.Op Ar +.Sh DESCRIPTION +The +.Nm +utility reports on, cleans up, +and generally maintains system +accounting files. +.Pp +The +.Nm +utility is able to condense the information in +.Pa /var/account/acct +into the summary files +.Pa /var/account/savacct +and +.Pa /var/account/usracct , +which contain system statistics according +to command name and login id, respectively. +This condensation is desirable because on a +large system, +.Pa /var/account/acct +can grow by hundreds of blocks per day. +The summary files are normally read before +the accounting file, so that reports include +all available information. +.Pp +If file names are supplied, they are read instead of +.Pa /var/account/acct . +After each file is read, if the summary +files are being updated, an updated summary will +be saved to disk. Only one report is printed, +after the last file is processed. +.Pp +The labels used in the output indicate the following, except +where otherwise specified by individual options: +.Bl -tag -width k*sec +.It Dv avio +Average number of I/O operations per execution +.It Dv cp +Sum of user and system time, in minutes +.It Dv cpu +Same as +.Dv cp +.It Dv k +CPU-time averaged core usage, in 1k units +.It Dv k*sec +CPU storage integral, in 1k-core seconds +.It Dv re +Real time, in minutes +.It Dv s +System time, in minutes +.It Dv tio +Total number of I/O operations +.It Dv u +User time, in minutes +.El +.Pp +The options to +.Nm +are: +.Bl -tag -width Ds +.It Fl a +List all command names, including those containing unprintable +characters and those used only once. By default, +.Nm +places all names containing unprintable characters and +those used only once under the name ``***other''. +.It Fl b +If printing command statistics, sort output by the sum of user and system +time divided by number of calls. +.It Fl c +In addition to the number of calls and the user, system and real times +for each command, print their percentage of the total over all commands. +.It Fl d +If printing command statistics, sort by the average number of disk +I/O operations. If printing user statistics, print the average number of +disk I/O operations per user. +.It Fl D +If printing command statistics, sort and print by the total number +of disk I/O operations. +.It Fl f +Force no interactive threshold comparison with the +.Fl v +option. +.It Fl i +Do not read in the summary files. +.It Fl j +Instead of the total minutes per category, give seconds per call. +.It Fl k +If printing command statistics, sort by the cpu-time average memory +usage. If printing user statistics, print the cpu-time average +memory usage. +.It Fl K +If printing command statistics, print and sort by the cpu-storage integral. +.It Fl l +Separate system and user time; normally they are combined. +.It Fl m +Print per-user statistics rather than per-command statistics. +.It Fl n +Sort by number of calls. +.It Fl q +Create no output other than error messages. +.It Fl r +Reverse order of sort. +.It Fl s +Truncate the accounting files when done and merge their data +into the summary files. +.It Fl t +For each command, report the ratio of real time to the sum +of user and system cpu times. +If the cpu time is too small to report, ``*ignore*'' appears in +this field. +.It Fl u +Superseding all other flags, for each entry +in the accounting file, print the user ID, total seconds of cpu usage, +total memory usage, number of I/O operations performed, and +command name. +.It Fl v Ar cutoff +For each command used +.Ar cutoff +times or fewer, print the command name and await a reply +from the terminal. If the reply begins with ``y'', add +the command to the category ``**junk**''. This flag is +used to strip garbage from the report. +.El +.Pp +By default, per-command statistics will be printed. The number of +calls, the total elapsed time in minutes, total cpu and user time +in minutes, average number of I/O operations, and CPU-time +averaged core usage will be printed. If the +.Fl m +option is specified, per-user statistics will be printed, including +the user name, the number of commands invoked, total cpu time used +(in minutes), total number of I/O operations, and CPU storage integral +for each user. If the +.Fl u +option is specified, the uid, user and system time (in seconds), +CPU storage integral, I/O usage, and command name will be printed +for each entry in the accounting data file. +.Pp +If the +.Fl u +flag is specified, all flags other than +.Fl q +are ignored. If the +.Fl m +flag is specified, only the +.Fl b , +.Fl d , +.Fl i , +.Fl k , +.Fl q , +and +.Fl s +flags are honored. +.Sh DIAGNOSTICS +.Ex -std +.Sh FILES +.Bl -tag -width /var/account/usracct -compact +.It Pa /var/account/acct +raw accounting data file +.It Pa /var/account/savacct +per-command accounting summary database +.It Pa /var/account/usracct +per-user accounting summary database +.El +.Sh SEE ALSO +.Xr lastcomm 1 , +.Xr acct 5 , +.Xr ac 8 , +.Xr accton 8 +.Sh BUGS +The number of options to this program is absurd, especially considering +that there's not much logic behind their lettering. +.Pp +The field labels should be more consistent. +.Pp +The VM system does not record the CPU storage integral. +.Sh CAVEATS +While the behavior of the options in this version of +.Nm +was modeled after the original version, there are some intentional +differences and undoubtedly some unintentional ones as well. In +particular, the +.Fl q +option has been added, and the +.Fl m +option now understands more options than it used to. +.Pp +The formats of the summary files created by this version of +.Nm +are very different from the those used by the original version. +This is not considered a problem, however, because the accounting record +format has changed as well (since user ids are now 32 bits). +.Sh AUTHORS +.An Chris G. Demetriou Aq cgd@postgres.berkeley.edu diff --git a/sa.tproj/usrdb.c b/sa.tproj/usrdb.c new file mode 100644 index 0000000..dda96ae --- /dev/null +++ b/sa.tproj/usrdb.c @@ -0,0 +1,288 @@ +/* + * Copyright (c) 1994 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christopher G. Demetriou. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef lint +static const char rcsid[] = + "$FreeBSD: src/usr.sbin/sa/usrdb.c,v 1.12 2002/07/15 16:05:15 des Exp $"; +#endif /* not lint */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "extern.h" +#include "pathnames.h" + +static int uid_compare __P((const DBT *, const DBT *)); + +static DB *usracct_db; + +int +usracct_init() +{ + DB *saved_usracct_db; + BTREEINFO bti; + int error; + + bzero(&bti, sizeof bti); + bti.compare = uid_compare; + + usracct_db = dbopen(NULL, O_RDWR, 0, DB_BTREE, &bti); + if (usracct_db == NULL) + return (-1); + + error = 0; + if (!iflag) { + DBT key, data; + int serr, nerr; + + saved_usracct_db = dbopen(_PATH_USRACCT, O_RDONLY, 0, DB_BTREE, + &bti); + if (saved_usracct_db == NULL) { + error = (errno == ENOENT) ? 0 : -1; + if (error) + warn("retrieving user accounting summary"); + goto out; + } + + serr = DB_SEQ(saved_usracct_db, &key, &data, R_FIRST); + if (serr < 0) { + warn("retrieving user accounting summary"); + error = -1; + goto closeout; + } + while (serr == 0) { + nerr = DB_PUT(usracct_db, &key, &data, 0); + if (nerr < 0) { + warn("initializing user accounting stats"); + error = -1; + break; + } + + serr = DB_SEQ(saved_usracct_db, &key, &data, R_NEXT); + if (serr < 0) { + warn("retrieving user accounting summary"); + error = -1; + break; + } + } + +closeout: + if (DB_CLOSE(saved_usracct_db) < 0) { + warn("closing user accounting summary"); + error = -1; + } + } + +out: + if (error != 0) + usracct_destroy(); + return (error); +} + +void +usracct_destroy() +{ + if (DB_CLOSE(usracct_db) < 0) + warn("destroying user accounting stats"); +} + +int +usracct_add(ci) + const struct cmdinfo *ci; +{ + DBT key, data; + struct userinfo newui; + u_long uid; + int rv; + + uid = ci->ci_uid; + key.data = &uid; + key.size = sizeof uid; + + rv = DB_GET(usracct_db, &key, &data, 0); + if (rv < 0) { + warn("get key %lu from user accounting stats", uid); + return (-1); + } else if (rv == 0) { /* it's there; copy whole thing */ + /* add the old data to the new data */ + bcopy(data.data, &newui, data.size); + if (newui.ui_uid != uid) { + warnx("key %lu != expected record number %lu", + newui.ui_uid, uid); + warnx("inconsistent user accounting stats"); + return (-1); + } + } else { /* it's not there; zero it and copy the key */ + bzero(&newui, sizeof newui); + newui.ui_uid = ci->ci_uid; + } + + newui.ui_calls += ci->ci_calls; + newui.ui_utime += ci->ci_utime; + newui.ui_stime += ci->ci_stime; + newui.ui_mem += ci->ci_mem; + newui.ui_io += ci->ci_io; + + data.data = &newui; + data.size = sizeof newui; + rv = DB_PUT(usracct_db, &key, &data, 0); + if (rv < 0) { + warn("add key %lu to user accounting stats", uid); + return (-1); + } else if (rv != 0) { + warnx("DB_PUT returned 1"); + return (-1); + } + + return (0); +} + +int +usracct_update() +{ + DB *saved_usracct_db; + DBT key, data; + BTREEINFO bti; + int error, serr, nerr; + + bzero(&bti, sizeof bti); + bti.compare = uid_compare; + + saved_usracct_db = dbopen(_PATH_USRACCT, O_RDWR|O_CREAT|O_TRUNC, 0644, + DB_BTREE, &bti); + if (saved_usracct_db == NULL) { + warn("creating user accounting summary"); + return (-1); + } + + error = 0; + + serr = DB_SEQ(usracct_db, &key, &data, R_FIRST); + if (serr < 0) { + warn("retrieving user accounting stats"); + error = -1; + } + while (serr == 0) { + nerr = DB_PUT(saved_usracct_db, &key, &data, 0); + if (nerr < 0) { + warn("saving user accounting summary"); + error = -1; + break; + } + + serr = DB_SEQ(usracct_db, &key, &data, R_NEXT); + if (serr < 0) { + warn("retrieving user accounting stats"); + error = -1; + break; + } + } + + if (DB_SYNC(saved_usracct_db, 0) < 0) { + warn("syncing process accounting summary"); + error = -1; + } + if (DB_CLOSE(saved_usracct_db) < 0) { + warn("closing process accounting summary"); + error = -1; + } + return error; +} + +void +usracct_print() +{ + DBT key, data; + struct userinfo uistore, *ui = &uistore; + double t; + int rv; + + rv = DB_SEQ(usracct_db, &key, &data, R_FIRST); + if (rv < 0) + warn("retrieving user accounting stats"); + + while (rv == 0) { + memcpy(ui, data.data, sizeof(struct userinfo)); + + printf("%-*s %9ju ", MAXLOGNAME - 1, + user_from_uid(ui->ui_uid, 0), (uintmax_t)ui->ui_calls); + + t = (double) (ui->ui_utime + ui->ui_stime) / + (double) AHZ; + if (t < 0.0001) /* kill divide by zero */ + t = 0.0001; + + printf("%12.2f%s ", t / 60.0, "cpu"); + + /* ui->ui_calls is always != 0 */ + if (dflag) + printf("%12ju%s", + (uintmax_t)(ui->ui_io / ui->ui_calls), "avio"); + else + printf("%12ju%s", (uintmax_t)ui->ui_io, "tio"); + + /* t is always >= 0.0001; see above */ + if (kflag) + printf("%12.0f%s", ui->ui_mem / t, "k"); + else + printf("%12ju%s", (uintmax_t)ui->ui_mem, "k*sec"); + + printf("\n"); + + rv = DB_SEQ(usracct_db, &key, &data, R_NEXT); + if (rv < 0) + warn("retrieving user accounting stats"); + } +} + +static int +uid_compare(k1, k2) + const DBT *k1, *k2; +{ + u_long d1, d2; + + bcopy(k1->data, &d1, sizeof d1); + bcopy(k2->data, &d2, sizeof d2); + + if (d1 < d2) + return -1; + else if (d1 == d2) + return 0; + else + return 1; +} diff --git a/sc_usage.tproj/sc_usage.1 b/sc_usage.tproj/sc_usage.1 index 85c4907..68e16ba 100644 --- a/sc_usage.tproj/sc_usage.1 +++ b/sc_usage.tproj/sc_usage.1 @@ -1,6 +1,6 @@ .\" Copyright (c) 2000, Apple Computer, Inc. All rights reserved. .\" -.Dd March 28, 2000 +.Dd October 28, 2002 .Dt SC_USAGE 1 .Os "Mac OS X" .Sh NAME @@ -12,12 +12,17 @@ .Op Fl e .Op Fl l .Op Fl s Ar interval -pid | cmd | -E execute +pid | cmd | +.Fl E +execute .Sh DESCRIPTION .Nm sc_usage -displays an ongoing sample of system call and -page fault usage statistics for a given process, -in a 'top' like fashion. +displays an ongoing sample of system call and page fault usage statistics for +a given process in a +.Dq Li top-like +fashion. +It requires root privileges due to the kernel tracing facility it uses to +operate. .Pp Page faults can be of the following types: .Bl -tag -width CACHEHITTT -compact @@ -39,9 +44,9 @@ When the option is specified, it expects a path to a .Ar codefile that -contains the mappings for the system calls. This option -overrides the default location of the system call codefile -which is found in /usr/share/misc/trace.codes. +contains the mappings for the system calls. +This option overrides the default location of the system call codefile which +is found in /usr/share/misc/trace.codes. .It Fl e Specifying the .Fl e @@ -52,27 +57,27 @@ The .Fl l option causes .Nm sc_usage -to turn off it's continuous window updating style of -output and instead output as a continuous scrolling -of data. +to turn off its continuous window updating style of output and instead output +as a continuous scrolling of data. .It Fl s By default, .Nm sc_usage -updates its output at one second intervals. This sampling -interval may be changed by specifying the +updates its output at one second intervals. +This sampling interval may be changed by specifying the .Fl s -option. Enter the +option. +Enter the .Ar interval in seconds. -.It pid | cmd | -E execute -The last argument must be a process id, a running command -name, or using the -E option, an execution path followed -by optional arguments. -The system call usage data for the process or command -is displayed. -If the -E flag is used, sc_usage will launch the executable, -pass along any optional arguments and display system call -usage date for that executable. +.It pid | cmd | -E execute +The last argument must be a process id, a running command name, or using the +.Fl E +option, an execution path followed by optional arguments. +The system call usage data for the process or command is displayed. +If the +.Fl E +flag is used, sc_usage will launch the executable, pass along any optional +arguments and display system call usage date for that executable. .El .Pp The data columns displayed are as follows: @@ -102,24 +107,27 @@ current scheduling priority The .Nm sc_usage command also displays some global state in the first few lines of output, -including the number of preemptions, context switches, threads, faults -and system calls, found during the sampling period. The current time -and the elapsed time that the command has been running is also +including the number of preemptions, context switches, threads, faults and +system calls, found during the sampling period. +The current time and the elapsed time that the command has been running is also displayed here. The .Nm sc_usage command is also SIGWINCH savvy, so adjusting your window geometry may change -the list of system calls being displayed. Typing a 'q' will cause sc_usage to -exit immediately. Typing any other character will cause sc_usage to reset its -counters and the display. +the list of system calls being displayed. +Typing a +.Sq Li q +will cause sc_usage to exit immediately. +Typing any other character will cause sc_usage to reset its counters and the +display. .Sh SAMPLE USAGE .Pp sc_usage Finder -e -s2 .Pp .Nm sc_usage -will sort the Finder process usage data according to system call count -and update the output at 2 second intervals. +will sort the Finder process usage data according to system call count and +update the output at 2 second intervals. .Sh SEE ALSO +.Xr fs_usage 1 , +.Xr latency 1 , .Xr top 1 -.Xr fs_usage 1 -.Xr latency 1 diff --git a/sc_usage.tproj/sc_usage.c b/sc_usage.tproj/sc_usage.c index 93d7ca2..adab8fa 100644 --- a/sc_usage.tproj/sc_usage.c +++ b/sc_usage.tproj/sc_usage.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ @@ -40,6 +39,7 @@ cc -I. -DKERNEL_PRIVATE -O -o sc_usage sc_usage.c -lncurses #include #include #include +#include #include #include @@ -213,6 +213,9 @@ void set_pidcheck(); void set_remove(); void set_numbufs(); void set_init(); +void quit(char *); +int argtopid(char *); +int argtoi(int, char*, char*, int); /* @@ -261,7 +264,7 @@ void sigwinch() } int -exit_usage(myname) { +exit_usage(char *myname) { fprintf(stderr, "Usage: %s [-c codefile] [-e] [-l] [-sn] pid | cmd | -E execute path\n", myname); fprintf(stderr, " -c name of codefile containing mappings for syscalls\n"); @@ -287,19 +290,19 @@ void print_time(char *p, unsigned int useconds, unsigned int seconds) hours = minutes / 60; if (minutes < 100) { // up to 100 minutes - sprintf(p, "%2ld:%02ld.%03ld", minutes, seconds % 60, - usec_to_1000ths(useconds)); + sprintf(p, "%2ld:%02ld.%03ld", minutes, (unsigned long)(seconds % 60), + (unsigned long)usec_to_1000ths(useconds)); } else if (hours < 100) { // up to 100 hours - sprintf(p, "%2ld:%02ld:%02ld ", hours, minutes % 60, - seconds % 60); + sprintf(p, "%2ld:%02ld:%02ld ", hours, (minutes % 60), + (unsigned long)(seconds % 60)); } else { sprintf(p, "%4ld hrs ", hours); } } - +int main(argc, argv) int argc; char *argv[]; @@ -309,15 +312,11 @@ main(argc, argv) char ch; char *ptr; int delay = Default_DELAY; - int length; void screen_update(); void sort_scalls(); void sc_tab_init(); void getdivisor(); void reset_counters(); - int argtopid(); - int argtoi(); - int quit(); if ( geteuid() != 0 ) { printf("'sc_usage' must be run as root...\n"); @@ -402,7 +401,7 @@ main(argc, argv) exit(1); case 0: /* child */ setsid(); - ptrace(0,0,0,0); /* PT_TRACE_ME */ + ptrace(0,(pid_t)0,(caddr_t)0,0); /* PT_TRACE_ME */ execve(argv[optind], &argv[optind], environ); perror("execve:"); exit(1); @@ -457,7 +456,7 @@ main(argc, argv) set_pidcheck(pid, 1); set_enable(1); if (execute_flag) - ptrace(7, pid, 1, 0); /* PT_CONTINUE */ + ptrace(7, pid, (caddr_t)1, 0); /* PT_CONTINUE */ getdivisor(); if (delay == 0) @@ -472,7 +471,6 @@ main(argc, argv) while (1) { int i; - int cnt; char c; void sample_sc(); @@ -652,7 +650,7 @@ void screen_update() clen = strlen(tbuf); sprintf(&tbuf[clen], " %3ld:%02ld:%02ld\n", - hours, minutes % 60, elapsed_secs % 60); + (long)hours, (long)(minutes % 60), (long)(elapsed_secs % 60)); if (tbuf[COLS-2] != '\n') { tbuf[COLS-1] = '\n'; @@ -981,7 +979,6 @@ sc_tab_init(char *codefile) { int msgcode_indx=0; char name[56]; FILE *fp; - int quit(); if ((fp = fopen(codefile,"r")) == (FILE *)0) { printf("Failed to open code description file %s\n", codefile); @@ -1413,8 +1410,8 @@ sample_sc() switched_out = (struct th_info *)0; switched_in = (struct th_info *)0; - now = (((uint64_t)kd[i].timestamp.tv_sec) << 32) | - (uint64_t)((unsigned int)(kd[i].timestamp.tv_nsec)); + now = kd[i].timestamp; + baseid = debugid & 0xffff0000; if (type == vfs_lookup) { @@ -1471,8 +1468,8 @@ sample_sc() code = (debugid >> 2) & 0x1ff; else if (baseid == msc_base) code = 512 + ((debugid >> 2) & 0x1ff); - else if (baseid == mach_sched || baseid == mach_stkhandoff) { - switched_out = find_thread(kd[i].arg1); + else if (type == mach_sched || type == mach_stkhandoff) { + switched_out = find_thread((kd[i].arg5 & KDBG_THREAD_MASK)); switched_in = find_thread(kd[i].arg2); if (in_idle) { @@ -1685,9 +1682,8 @@ sample_sc() delta_otime_secs += secs; } - -quit(s) -char *s; +void +quit(char *s) { if (trace_enabled) set_enable(0); @@ -1717,6 +1713,7 @@ void getdivisor() } +int argtopid(str) char *str; { @@ -1774,7 +1771,8 @@ find_msgcode(int debugid) } return (0); } - + +int argtoi(flag, req, str, base) int flag; char *req, *str; diff --git a/sc_usage.tproj/trace.codes b/sc_usage.tproj/trace.codes index a2caffd..714ae4a 100644 --- a/sc_usage.tproj/trace.codes +++ b/sc_usage.tproj/trace.codes @@ -1,4 +1,4 @@ -892 +918 0x1f000000 DYLD_initialize 0x1f010000 DYLD_CALL_image_init_routine 0x1f010004 DYLD_CALL_dependent_init_routine @@ -82,6 +82,7 @@ 0xff000358 MSG_processor_set_create 0xff00035c MSG_mach_memory_object_memory_entry_64 0xff000360 MSG_host_statistics +0xff000364 MSG_host_request_notification 0xff000640 MSG_host_get_boot_info 0xff000644 MSG_host_reboot 0xff000648 MSG_host_priv_statistics @@ -91,7 +92,7 @@ 0xff000658 MSG_vm_allocate_cpm 0xff00065c MSG_host_processors 0xff000660 MSG_host_get_clock_control -0xff000664 MSG_kmod_creat +0xff000664 MSG_kmod_create 0xff000668 MSG_kmod_destroy 0xff00066c MSG_kmod_control 0xff000670 MSG_host_get_special_port @@ -117,13 +118,19 @@ 0xff001f40 MSG_memory_object_get_attributes 0xff001f44 MSG_memory_object_change_attributes 0xff001f48 MSG_memory_object_synchronize_completed -0xff001f4c MSG_memory_object_lock_request -0xff001f50 MSG_memory_object_destroy -0xff001f54 MSG_memory_object_upl_request -0xff001f58 MSG_memory_object_super_upl_request -0xff001f5c MSG_memory_object_page_op -0xff001f60 MSG_memory_object_recover_named -0xff001f64 MSG_memory_object_release_name +0xff001f4c MSG_memory_object_data_unavailable +0xff001f50 MSG_memory_object_lock_request +0xff001f54 MSG_memory_object_data_error +0xff001f58 MSG_memory_object_destroy +0xff001f5c MSG_memory_object_data_supply +0xff001f60 MSG_memory_object_discard_reply +0xff001f64 MSG_vm_object_upl_request +0xff001f68 MSG_vm_pager_upl_request +0xff001f6c MSG_vm_upl_map +0xff001f70 MSG_vm_upl_unmap +0xff001f74 MSG_vm_upl_abort +0xff001f78 MSG_vm_upl_commit +0xff001f7c MSG_vm_upl_commit_range 0xff002008 MSG_upl_abort 0xff00200c MSG_upl_abort_range 0xff002010 MSG_upl_commit @@ -150,8 +157,6 @@ 0xff002584 MSG_exception_raise 0xff002588 MSG_exception_raise_state 0xff00258c MSG_exception_raise_state_identity -0xff002648 MSG_samples -0xff00264c MSG_notices 0xff002bc0 MSG_io_object_get_class 0xff002bc4 MSG_io_object_conforms_to 0xff002bc8 MSG_io_iterator_next @@ -208,6 +213,10 @@ 0xff002c94 MSG_io_connect_unmap_memory 0xff002c98 MSG_io_registry_entry_get_location_in_plane 0xff002c9c MSG_io_registry_entry_get_property_recursively +0xff002ca0 MSG_io_service_get_state +0xff002ca4 MSG_io_service_get_matching_services_ool +0xff002ca8 MSG_io_service_match_property_table_ool +0xff002cac MSG_io_service_add_notification_ool 0xff002ee0 MSG_processor_start 0xff002ee4 MSG_processor_exit 0xff002ee8 MSG_processor_info @@ -366,11 +375,8 @@ 0xff25abd0 MSG_semaphore_timedwait 0xff25abd4 MSG_semaphore_wait_signal 0xff25abd8 MSG_semaphore_timedwait_signal -0xff3d0904 MSG_bootstrap_ports -0xff3d0908 MSG_bootstrap_arguments -0xff3d090c MSG_bootstrap_environment -0xff3d0910 MSG_bootstrap_completed 0xffbebdcc MSG_clock_alarm_reply + 0x1300000 MACH_vmfault 0x1300004 MACH_Pageout 0x1400000 MACH_SCHED @@ -431,8 +437,8 @@ 0x10c00c4 MSC_macx_swapoff 0x10c00c8 MSC_kern_invalid_#50 0x10c00cc MSC_macx_triggers -0x10c00d0 MSC_kern_invalid_#52 -0x10c00d4 MSC_kern_invalid_#53 +0x10c00d0 MSC_macx_backing_store_suspend +0x10c00d4 MSC_macx_backing_store_recovery 0x10c00d8 MSC_kern_invalid_#54 0x10c00dc MSC_kern_invalid_#55 0x10c00e0 MSC_kern_invalid_#56 @@ -747,12 +753,12 @@ 0x40c034c BSC_ATPgetreq 0x40c0350 BSC_ATPgetrsp 0x40c0354 BSC_#213 -0x40c0358 BSC_#214 -0x40c035c BSC_#215 -0x40c0360 BSC_#216 -0x40c0364 BSC_#217 -0x40c0368 BSC_#218 -0x40c036c BSC_#219 +0x40c0358 BSC_kqueue_from_portset_np +0x40c035c BSC_kqueue_portset_np +0x40c0360 BSC_mkcomplex +0x40c0364 BSC_statv +0x40c0368 BSC_lstatv +0x40c036c BSC_fstatv 0x40c0370 BSC_getattrlist 0x40c0374 BSC_setattrlist 0x40c0378 BSC_getdirentriesattr @@ -780,8 +786,8 @@ 0x40c03d0 BSC_#244 0x40c03d4 BSC_#245 0x40c03d8 BSC_#246 -0x40c03dc BSC_#247 -0x40c03e0 BSC_#248 +0x40c03dc BSC_nfsclnt +0x40c03e0 BSC_fhopen 0x40c03e4 BSC_#249 0x40c03e8 BSC_minherit 0x40c03ec BSC_semsys @@ -846,14 +852,14 @@ 0x40c04d8 BSC_getsid 0x40c04dc BSC_#311 0x40c04e0 BSC_#312 -0x40c04e4 BSC_#313 -0x40c04e8 BSC_#314 -0x40c04ec BSC_#315 -0x40c04f0 BSC_#316 -0x40c04f4 BSC_#317 -0x40c04f8 BSC_#318 -0x40c04fc BSC_#319 -0x40c0500 BSC_#320 +0x40c04e4 BSC_aio_fsync +0x40c04e8 BSC_aio_return +0x40c04ec BSC_aio_suspend +0x40c04f0 BSC_aio_cancel +0x40c04f4 BSC_aio_error +0x40c04f8 BSC_aio_read +0x40c04fc BSC_aio_write +0x40c0500 BSC_lio_listio 0x40c0504 BSC_#321 0x40c0508 BSC_#322 0x40c050c BSC_#323 @@ -883,6 +889,26 @@ 0x40c056c BSC_#347 0x40c0570 BSC_#348 0x40c0574 BSC_#349 +0x40c0578 BSC_#350 +0x40c057c BSC_#351 +0x40c0580 BSC_#352 +0x40c0584 BSC_#353 +0x40c0588 BSC_#354 +0x40c058c BSC_#355 +0x40c0590 BSC_#356 +0x40c0594 BSC_#357 +0x40c0598 BSC_#358 +0x40c059c BSC_#359 +0x40c05a0 BSC_#360 +0x40c05a4 BSC_#361 +0x40c05a8 BSC_kqueue +0x40c05ac BSC_kevent +0x40c05b0 BSC_#364 +0x40c05b4 BSC_#365 +0x40c05b8 BSC_#366 +0x40c05bc BSC_#367 +0x40c05c0 BSC_#368 +0x40c05c4 BSC_#369 0x50b0018 IES_action 0x50b001c IES_filter 0x50c0010 TES_action diff --git a/shutdown.tproj/pathnames.h b/shutdown.tproj/pathnames.h index 4056ffe..2bb5f01 100644 --- a/shutdown.tproj/pathnames.h +++ b/shutdown.tproj/pathnames.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/shutdown.tproj/shutdown.8 b/shutdown.tproj/shutdown.8 index 74126f8..fb2c1f7 100644 --- a/shutdown.tproj/shutdown.8 +++ b/shutdown.tproj/shutdown.8 @@ -30,42 +30,43 @@ .\" SUCH DAMAGE. .\" .\" @(#)shutdown.8 8.2 (Berkeley) 4/27/95 +.\" $FreeBSD: src/sbin/shutdown/shutdown.8,v 1.21 2002/12/23 16:04:50 ru Exp $ .\" -.Dd April 27, 1995 +.Dd December 11, 1998 .Dt SHUTDOWN 8 -.Os BSD 4 +.Os .Sh NAME .Nm shutdown .Nd "close down the system at a given time" .Sh SYNOPSIS -.Nm shutdown -.Op Fl -.Op Fl fhkrn +.Nm +.Op Fl +.Oo +.Fl h | +.Fl r | Fl k +.Oc +.Oo +.Fl o +.Op Fl n +.Oc .Ar time .Op Ar warning-message ... .Sh DESCRIPTION -.Nm Shutdown -provides an automated shutdown procedure for super-users +The +.Nm +utility provides an automated shutdown procedure for super-users to nicely notify users when the system is shutting down, saving them from system administrators, hackers, and gurus, who would otherwise not bother with such niceties. .Pp -Available friendlinesses: -.Bl -tag -width time -.It Fl f -.Nm Shutdown -arranges, in the manner of -.Xr fastboot 8 , -for the file systems -.Em not to be -checked on reboot. +The following options are available: +.Bl -tag -width indent .It Fl h The system is halted at the specified -.Ar time -when -.Nm shutdown -execs -.Xr halt 8 . +.Ar time . +.It Fl r +The system is rebooted at the specified +.Ar time . .It Fl k Kick everybody off. The @@ -73,20 +74,34 @@ The option does not actually halt the system, but leaves the system multi-user with logins disabled (for all but super-user). -.It Fl n -Prevent the normal -.Xr sync 2 -before stopping. -.It Fl r -.Nm Shutdown -execs +.It Fl o +If one of the +.Fl h , +.Fl p +or +.Fl r +is specified, +.Nm +will execute +.Xr halt 8 +or .Xr reboot 8 -at the specified -.Ar time . +instead of sending signal to +.Xr init 8 . +.It Fl n +If the +.Fl o +is specified, prevent the file system cache from being flushed by passing +.Fl n +option to +.Xr halt 8 +or +.Xr reboot 8 . +This option should probably not be used. .It Ar time .Ar Time is the time at which -.Nm shutdown +.Nm will bring the system down and may be the word .Ar now @@ -104,7 +119,7 @@ Any other arguments comprise the warning message that is broadcast to users currently logged into the system. .It Fl If -.Ql Fl +.Sq Fl is supplied as an option, the warning message is read from the standard input. .El @@ -114,43 +129,51 @@ and starting at ten hours before shutdown, warning messages are displayed on the terminals of all users logged in. Five minutes before shutdown, or immediately if shutdown is in less than 5 minutes, logins are disabled by creating -.Pa /etc/nologin +.Pa /var/run/nologin and copying the warning message there. If this file exists when a user attempts to log in, .Xr login 1 prints its contents and exits. The file is removed just before -.Nm shutdown +.Nm exits. .Pp -At shutdown time a message is written in the system log, containing the -time of shutdown, who initiated the shutdown and the reason. -A terminate -signal is then sent to -.Xr init -to bring the system down to single-user state (depending on above -options). +At shutdown time a message is written to the system log, containing the +time of shutdown, the person who initiated the shutdown and the reason. +Corresponding signal is then sent to +.Xr init 8 +to respectively halt, reboot or bring the system down to single-user state +(depending on the above options). The time of the shutdown and the warning message are placed in -.Pa /etc/nologin +.Pa /var/run/nologin and should be used to inform the users about when the system will be back up and why it is going down (or anything else). +.Pp +A scheduled shutdown can be canceled by killing the +.Nm +process (a +.Dv SIGTERM +should suffice). +The +.Pa /var/run/nologin +file that +.Nm +created will be removed automatically. .Sh FILES -.Bl -tag -width /etc/nologin -compact -.It Pa /etc/nologin +.Bl -tag -width /var/run/nologin -compact +.It Pa /var/run/nologin tells login not to let anyone log in -.It Pa /fastboot -tells -.Xr rc 8 -not to run fsck when rebooting .El .Sh SEE ALSO +.Xr kill 1 , .Xr login 1 , .Xr wall 1 , -.Xr fastboot 8 , +.Xr nologin 5 , .Xr halt 8 , +.Xr init 8 , .Xr reboot 8 .Sh BACKWARD COMPATIBILITY The hours and minutes in the second time format may be separated by @@ -158,5 +181,5 @@ a colon (``:'') for backward compatibility. .Sh HISTORY The .Nm -command appeared in +utility appeared in .Bx 4.0 . diff --git a/shutdown.tproj/shutdown.c b/shutdown.tproj/shutdown.c index 0064c30..3b1b795 100644 --- a/shutdown.tproj/shutdown.c +++ b/shutdown.tproj/shutdown.c @@ -1,30 +1,6 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ /* * Copyright (c) 1988, 1990, 1993 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -36,8 +12,8 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. + * This product includes software developed by the University of + * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -55,12 +31,27 @@ * SUCH DAMAGE. */ +#ifndef lint +static const char copyright[] = +"@(#) Copyright (c) 1988, 1990, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +#if 0 +static char sccsid[] = "@(#)shutdown.c 8.4 (Berkeley) 4/28/95"; +#endif +static const char rcsid[] = + "$FreeBSD: src/sbin/shutdown/shutdown.c,v 1.23 2002/03/21 13:20:48 imp Exp $"; +#endif /* not lint */ + #include #include #include #include #include +#include #include #include #include @@ -68,16 +59,17 @@ #include #include #include -#include #include #include "pathnames.h" +#ifdef __APPLE__ +#define __unused +#endif + #ifdef DEBUG #undef _PATH_NOLOGIN #define _PATH_NOLOGIN "./nologin" -#undef _PATH_FASTBOOT -#define _PATH_FASTBOOT "./fastboot" #endif #define H *60*60 @@ -87,56 +79,62 @@ struct interval { int timeleft, timetowait; } tlist[] = { - 10 H, 5 H, 5 H, 3 H, 2 H, 1 H, 1 H, 30 M, - 30 M, 10 M, 20 M, 10 M, 10 M, 5 M, 5 M, 3 M, - 2 M, 1 M, 1 M, 30 S, 30 S, 30 S, - 0, 0, + { 10 H, 5 H }, + { 5 H, 3 H }, + { 2 H, 1 H }, + { 1 H, 30 M }, + { 30 M, 10 M }, + { 20 M, 10 M }, + { 10 M, 5 M }, + { 5 M, 3 M }, + { 2 M, 1 M }, + { 1 M, 30 S }, + { 30 S, 30 S }, + { 0 , 0 } }; #undef H #undef M #undef S static time_t offset, shuttime; -static int dofast, dohalt, doreboot, killflg, mbuflen; -static char *nosync, *whom, mbuf[BUFSIZ]; - -void badtime __P((void)); -void die_you_gravy_sucking_pig_dog __P((void)); -void doitfast __P((void)); -void finish __P((int)); -void getoffset __P((char *)); -void loop __P((void)); -void nolog __P((void)); -void timeout __P((int)); -void timewarn __P((int)); -void usage __P((void)); +static int dohalt, dopower, doreboot, killflg, mbuflen, oflag = 1; +static char mbuf[BUFSIZ]; +static const char *nosync, *whom; + +void badtime(void); +void die_you_gravy_sucking_pig_dog(void); +void finish(int); +void getoffset(char *); +void loop(void); +void nolog(void); +void timeout(int); +void timewarn(int); +void usage(const char *); int main(argc, argv) int argc; char *argv[]; { - extern int optind; - register char *p, *endp; + char *p, *endp; struct passwd *pw; int arglen, ch, len, readstdin; #ifndef DEBUG - if (geteuid()) { - (void)fprintf(stderr, "shutdown: NOT super-user\n"); - exit(1); - } + if (geteuid()) + errx(1, "NOT super-user"); #endif nosync = NULL; readstdin = 0; - while ((ch = getopt(argc, argv, "-fhknr")) != EOF) +#ifndef __APPLE__ + while ((ch = getopt(argc, argv, "-hknopr")) != -1) +#else + while ((ch = getopt(argc, argv, "-hknor")) != -1) +#endif switch (ch) { case '-': readstdin = 1; break; - case 'f': - dofast = 1; - break; case 'h': dohalt = 1; break; @@ -146,29 +144,44 @@ main(argc, argv) case 'n': nosync = "-n"; break; + case 'o': + oflag = 1; + break; +#ifndef __APPLE__ + case 'p': + dopower = 1; + break; +#endif case 'r': doreboot = 1; break; case '?': default: - usage(); + usage((char *)NULL); } argc -= optind; argv += optind; if (argc < 1) - usage(); + usage((char *)NULL); + +#ifndef __APPLE__ + if (killflg + doreboot + dohalt + dopower > 1) + usage("incompatible switches -h, -k, -p and -r"); + + if (oflag && !(dohalt || dopower || doreboot)) + usage("-o requires -h, -p or -r"); +#else + if (killflg + doreboot + dohalt > 1) + usage("incompatible switches -h, -k, and -r"); + + if (oflag && !(dohalt || doreboot)) + usage("-o requires -h or -r"); +#endif + + if (nosync != NULL && !oflag) + usage("-n requires -o"); - if (dofast && nosync) { - (void)fprintf(stderr, - "shutdown: incompatible switches -f and -n.\n"); - usage(); - } - if (doreboot && dohalt) { - (void)fprintf(stderr, - "shutdown: incompatible switches -h and -r.\n"); - usage(); - } getoffset(*argv++); if (*argv) { @@ -217,19 +230,16 @@ main(argc, argv) int forkpid; forkpid = fork(); - if (forkpid == -1) { - perror("shutdown: fork"); - exit(1); - } - if (forkpid) { - (void)printf("shutdown: [pid %d]\n", forkpid); - exit(0); - } + if (forkpid == -1) + err(1, "fork"); + if (forkpid) + errx(0, "[pid %d]", forkpid); } + setsid(); #endif openlog("shutdown", LOG_CONS, LOG_AUTH); loop(); - /* NOTREACHED */ + return(0); } void @@ -249,14 +259,14 @@ loop() if (tp->timeleft < offset) (void)sleep((u_int)(offset - tp->timeleft)); else { - while (offset < tp->timeleft) + while (tp->timeleft && offset < tp->timeleft) ++tp; /* * Warn now, if going to sleep more than a fifth of * the next wait time. */ - if (sltime = offset - tp->timeleft) { - if (sltime > tp->timetowait / 5) + if ((sltime = offset - tp->timeleft)) { + if (sltime > (u_int)(tp->timetowait / 5)) timewarn(offset); (void)sleep(sltime); } @@ -276,6 +286,11 @@ loop() static jmp_buf alarmbuf; +static const char *restricted_environ[] = { + "PATH=" _PATH_STDPATH, + NULL +}; + void timewarn(timeleft) int timeleft; @@ -284,12 +299,14 @@ timewarn(timeleft) static char hostname[MAXHOSTNAMELEN + 1]; FILE *pf; char wcmd[MAXPATHLEN + 4]; + extern const char **environ; if (!first++) (void)gethostname(hostname, sizeof(hostname)); /* undoc -n option to wall suppresses normal wall banner */ (void)snprintf(wcmd, sizeof(wcmd), "%s -n", _PATH_WALL); + environ = restricted_environ; if (!(pf = popen(wcmd, "w"))) { syslog(LOG_ERR, "shutdown: can't find %s: %m", _PATH_WALL); return; @@ -315,7 +332,7 @@ timewarn(timeleft) /* * play some games, just in case wall doesn't come back - * probably unecessary, given that wall is careful. + * probably unnecessary, given that wall is careful. */ if (!setjmp(alarmbuf)) { (void)signal(SIGALRM, timeout); @@ -328,7 +345,7 @@ timewarn(timeleft) void timeout(signo) - int signo; + int signo __unused; { longjmp(alarmbuf, 1); } @@ -336,40 +353,68 @@ timeout(signo) void die_you_gravy_sucking_pig_dog() { + char *empty_environ[] = { NULL }; syslog(LOG_NOTICE, "%s by %s: %s", - doreboot ? "reboot" : dohalt ? "halt" : "shutdown", whom, mbuf); +#ifndef __APPLE__ + doreboot ? "reboot" : dohalt ? "halt" : dopower ? "power-down" : +#else + doreboot ? "reboot" : dohalt ? "halt" : +#endif + "shutdown", whom, mbuf); (void)sleep(2); (void)printf("\r\nSystem shutdown time has arrived\007\007\r\n"); if (killflg) { (void)printf("\rbut you'll have to do it yourself\r\n"); - finish(0); + exit(0); } - if (dofast) - doitfast(); #ifdef DEBUG if (doreboot) (void)printf("reboot"); else if (dohalt) (void)printf("halt"); - if (nosync) +#ifndef __APPLE__ + else if (dopower) + (void)printf("power-down"); +#endif + if (nosync != NULL) (void)printf(" no sync"); - if (dofast) - (void)printf(" no fsck"); (void)printf("\nkill -HUP 1\n"); #else - if (doreboot) { - execle(_PATH_REBOOT, "reboot", "-l", nosync, 0); - syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_REBOOT); - perror("shutdown"); - } - else if (dohalt) { - execle(_PATH_HALT, "halt", "-l", nosync, 0); - syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_HALT); - perror("shutdown"); + if (!oflag) { + (void)kill(1, doreboot ? SIGINT : /* reboot */ + dohalt ? SIGUSR1 : /* halt */ +#ifndef __APPLE__ + dopower ? SIGUSR2 : /* power-down */ +#endif + SIGTERM); /* single-user */ + } else { + if (doreboot) { + execle(_PATH_REBOOT, "reboot", "-l", nosync, + (char *)NULL, empty_environ); + syslog(LOG_ERR, "shutdown: can't exec %s: %m.", + _PATH_REBOOT); + warn(_PATH_REBOOT); + } + else if (dohalt) { + execle(_PATH_HALT, "halt", "-l", nosync, + (char *)NULL, empty_environ); + syslog(LOG_ERR, "shutdown: can't exec %s: %m.", + _PATH_HALT); + warn(_PATH_HALT); + } +#ifndef __APPLE__ + else if (dopower) { + execle(_PATH_HALT, "halt", "-l", "-p", nosync, + (char *)NULL, empty_environ); + syslog(LOG_ERR, "shutdown: can't exec %s: %m.", + _PATH_HALT); + warn(_PATH_HALT); + } +#endif + (void)kill(1, SIGTERM); /* to single-user */ } - (void)kill(1, SIGTERM); /* to single user */ #endif finish(0); } @@ -378,29 +423,33 @@ die_you_gravy_sucking_pig_dog() void getoffset(timearg) - register char *timearg; + char *timearg; { - register struct tm *lt; - register char *p; + struct tm *lt; + char *p; time_t now; + int this_year; + + (void)time(&now); if (!strcasecmp(timearg, "now")) { /* now */ offset = 0; + shuttime = now; return; } - (void)time(&now); if (*timearg == '+') { /* +minutes */ if (!isdigit(*++timearg)) badtime(); - offset = atoi(timearg) * 60; + if ((offset = atoi(timearg) * 60) < 0) + badtime(); shuttime = now + offset; return; } /* handle hh:mm by getting rid of the colon */ for (p = timearg; *p; ++p) - if (!isascii(*p) || !isdigit(*p)) + if (!isascii(*p) || !isdigit(*p)) { if (*p == ':' && strlen(p) == 3) { p[0] = p[1]; p[1] = p[2]; @@ -408,13 +457,24 @@ getoffset(timearg) } else badtime(); + } unsetenv("TZ"); /* OUR timezone */ lt = localtime(&now); /* current time val */ switch(strlen(timearg)) { case 10: + this_year = lt->tm_year; lt->tm_year = ATOI2(timearg); + /* + * check if the specified year is in the next century. + * allow for one year of user error as many people will + * enter n - 1 at the start of year n. + */ + if (lt->tm_year < (this_year % 100) - 1) + lt->tm_year += 100; + /* adjust for the year 2000 and beyond */ + lt->tm_year += (this_year - (this_year % 100)); /* FALLTHROUGH */ case 8: lt->tm_mon = ATOI2(timearg); @@ -436,34 +496,19 @@ getoffset(timearg) lt->tm_sec = 0; if ((shuttime = mktime(lt)) == -1) badtime(); - if ((offset = shuttime - now) < 0) { - (void)fprintf(stderr, - "shutdown: that time is already past.\n"); - exit(1); - } + if ((offset = shuttime - now) < 0) + errx(1, "that time is already past."); break; default: badtime(); } } -#define FSMSG "fastboot file for fsck\n" -void -doitfast() -{ - int fastfd; - - if ((fastfd = open(_PATH_FASTBOOT, O_WRONLY|O_CREAT|O_TRUNC, - 0664)) >= 0) { - (void)write(fastfd, FSMSG, sizeof(FSMSG) - 1); - (void)close(fastfd); - } -} - #define NOMSG "\n\nNO LOGINS: System going down at " void nolog() { +#ifndef __APPLE__ int logfd; char *ct; @@ -481,27 +526,34 @@ nolog() (void)write(logfd, mbuf, strlen(mbuf)); (void)close(logfd); } +#endif } void finish(signo) - int signo; + int signo __unused; { +#ifndef __APPLE__ if (!killflg) (void)unlink(_PATH_NOLOGIN); +#endif exit(0); } void badtime() { - (void)fprintf(stderr, "shutdown: bad time format.\n"); - exit(1); + errx(1, "bad time format"); } void -usage() +usage(cp) + const char *cp; { - fprintf(stderr, "usage: shutdown [-fhknr] shutdowntime [ message ]\n"); + if (cp != NULL) + warnx("%s", cp); + (void)fprintf(stderr, + "usage: shutdown [-] [-h | -p | -r | -k] [-o [-n]]" + " time [warning-message ...]\n"); exit(1); } diff --git a/sync.tproj/sync.c b/sync.tproj/sync.c index b61e1ba..9a242f3 100644 --- a/sync.tproj/sync.c +++ b/sync.tproj/sync.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/sysctl.tproj/sysctl.c b/sysctl.tproj/sysctl.c index 76b8a6f..b1b8e75 100644 --- a/sysctl.tproj/sysctl.c +++ b/sysctl.tproj/sysctl.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ @@ -147,9 +146,9 @@ struct list secondlevel[] = { { kernname, KERN_MAXID }, /* CTL_KERN */ { vmname, VM_MAXID }, /* CTL_VM */ { 0, 0 }, /* CTL_VFS */ - { 0, 0 }, /* CTL_NET */ + { 0, 0 }, /* CTL_NET */ { 0, CTL_DEBUG_MAXID }, /* CTL_DEBUG */ - { 0,0 }, /* CTL_HW */ + { hwname, HW_MAXID }, /* CTL_HW */ #ifdef CTL_MACHDEP_NAMES { machdepname, CPU_MAXID }, /* CTL_MACHDEP */ #else @@ -170,7 +169,7 @@ void usage(); static void parse(char *string, int flags); static int oidfmt(int *, int, char *, u_int *); -static int show_var(int *, int, int); +static int show_var(int *, int); static int sysctl_all (int *oid, int len); static int name2oid(char *, int *); @@ -351,7 +350,7 @@ old_parse(string, flags) break; case CTL_VM: - if (mib[1] == VM_LOADAVG) { /* XXX this is bogus */ + if (mib[1] == VM_LOADAVG) { double loads[3]; getloadavg(loads, 3); @@ -694,7 +693,7 @@ parse(char *string, int flags) foundSome = 1; old_parse (string, flags); } else { - i = show_var(mib, len, 1); + i = show_var(mib, len); if (!i && !bflag) putchar('\n'); } @@ -731,7 +730,7 @@ parse(char *string, int flags) kind & CTLTYPE); } - i = show_var(mib, len, 1); + i = show_var(mib, len); if (sysctl(mib, len, 0, 0, newval, newsize) == -1) { if (!i && !bflag) putchar('\n'); @@ -754,7 +753,7 @@ parse(char *string, int flags) printf(" -> "); i = nflag; nflag = 1; - j = show_var(mib, len, 1); + j = show_var(mib, len); if (!j && !bflag) putchar('\n'); nflag = i; @@ -887,7 +886,7 @@ oidfmt(int *oid, int len, char *fmt, u_int *kind) */ static int -show_var(int *oid, int nlen, int show_masked) +show_var(int *oid, int nlen) { u_char buf[BUFSIZ], *val, *mval, *p; char name[BUFSIZ], /* descr[BUFSIZ], */ *fmt; @@ -933,25 +932,11 @@ show_var(int *oid, int nlen, int show_masked) err(1, "sysctl fmt %d %d %d", i, j, errno); kind = *(u_int *)buf; - if (!show_masked && (kind & CTLFLAG_MASKED)) { - retval = 1; - goto RETURN; - } fmt = (char *)(buf + sizeof(u_int)); - - /* XXX special-case hack for hw.physmem */ - if ((oid[0] == CTL_HW) && (oid[1] == HW_PHYSMEM)) - fmt = "IU"; p = val; switch (*fmt) { - case '-': - /* deprecated, do not print */ - retval = 0; - goto RETURN; - - case 'A': if (!nflag) printf("%s: ", name); @@ -1000,24 +985,6 @@ show_var(int *oid, int nlen, int show_masked) retval = 0; goto RETURN; - case 'Q': - if (!nflag) - printf("%s: ", name); - fmt++; - val = ""; - while (len >= sizeof(long long)) { - if(*fmt == 'U') - printf("%s%llu", val, *(unsigned long long *)p); - else - printf("%s%lld", val, *(long long *)p); - val = " "; - len -= sizeof (long long); - p += sizeof (long long); - } - retval = 0; - goto RETURN; - - case 'T': case 'S': i = 0; @@ -1093,7 +1060,7 @@ sysctl_all (int *oid, int len) if (name2[i] != oid[i]) return 0; - i = show_var(name2, l2, 0); + i = show_var(name2, l2); if (!i && !bflag) putchar('\n'); diff --git a/top.tproj/top.1 b/top.tproj/top.1 deleted file mode 100644 index aee3997..0000000 --- a/top.tproj/top.1 +++ /dev/null @@ -1,194 +0,0 @@ -.\" Copyright (c) 1999, Apple Computer, Inc. All rights reserved. -.\" -.Dd September 30, 1999 -.Dt TOP 1 -.Os "Mac OS X" -.Sh NAME -.Nm top -.Nd show system usage statistics -.Sh SYNOPSIS -.Nm top -.Op Fl u -.Op Fl w -.Op Fl k -.Op Fl s Ar interval -.Op Fl e | Fl d | Fl a -.Op Fl l Ar samples -.Op Ar number -.Sh DESCRIPTION -.Nm top -displays an ongoing sample of system usage statistics. It operates -in various modes, but by default shows cpu utilization and -memory usage for each process in the system. -.Pp -The options are as follows: -.Bl -tag -width Ds -.It Fl u -When the -.Fl u -option is specified, processes are first sorted by cpu usage -and then displayed starting with the highest consumers. -.It Fl w -Specifying the -.Fl w -option generates additional columns in the output producing -a much wider display of data. The additional columns include -VPRVT, along with the delta information for #PRTS, -RPRVT, RSHRD, RSIZE and VSIZE (see descriptions following). -.It Fl k -The -.Fl k -option causes -.Nm top -to traverse and report the memory object map for pid 0 -(the kernel task). It is optional because it is fairly -expensive to traverse the object maps and the kernel -task may have a huge number of entries. -.It Fl s -By default, -.Nm top -updates its output at one second intervals. This sampling -interval may be changed by specifying the -.Fl s -option. Enter the -.Ar interval -in seconds. -.It Fl e -Using the -.Fl e -option switches from the default output to an event counting -mode where the counts reported are absolute counters. The -.Fl w -and -.Fl k -options are ignored when running in event counting mode. -.It Fl d -Using the -.Fl d -option switches from the default output to an event counting -mode where the counts are reported as deltas relative to -the previous sample. -The -.Fl w -and -.Fl k -options are ignored when running in event counting, delta mode. -.It Fl a -Using the -.Fl a -option switches from the default output to an event counting -mode where the counts are reported as cumulative counters relative to -when top was launched. -The -.Fl w -and -.Fl k -options are ignored when running in event counting, accumulate mode. -.It Fl l -Using the -.Fl l -option switches from the default screen mode to a logging mode suitable for -saving the output to a file. You may specify the number of samples to be -output before top exits, the default is 1 sample. -.It number -If you wish to limit the number of processes displayed by -.Nm top, -specify the desired -.Ar number -of output lines in this last argument. -.El -.Pp -The columns displayed in the default data mode are as follows: -.Bl -tag -width VSIZE(deltadelta) -compact -.Pp -.It PID -the Unix process id. -.It COMMAND -the Unix command name. -.It %CPU -the percentage of cpu consumed (kernel and user). -.It TIME -the absolute cpu consumption (min:secs.hundreths). -.It #TH -the number of threads. -.It #PRTS(delta) -the number of mach ports. -.It #MREG -the number of memory regions. -.It VPRVT(-w only) -the private address space currently allocated. -.It RPRVT(delta) -the resident private memory. -.It RSHRD(delta) -the resident shared memory (as represented by the -resident page count of each shared memory object). -.It RSIZE(delta) -the total resident memory (real pages that this -process currently has associated with it. Some -may be shared by other processes). -.It VSIZE(delta) -the total address space currently allocated (including shared). -.El -.Pp -The delta columns are enabled by the -.Fl w -option. The deltas for #PRTS and VSIZE are relative -to the numbers observed when -.Nm top -was launched. The deltas for RPRVT, RSHRD and RSIZE are relative to -the previous sample. If the -.Fl w -option was not specified, -.Nm top -will append either a '+' or a '-' to the RPRVT, RSHRD, RSIZE or VSIZE -columns indicating either a gain or a loss relative to the previous sample. -.Pp -The columns displayed in the event counting modes (ie: -e | -d | -a options) -are as follows: -.Bl -tag -width MACHSYSCALL -compact -.Pp -.It PID -the Unix process id. -.It COMMAND -the Unix command name. -.It %CPU -the percentage of cpu consumed (kernel and user). -.It TIME -the absolute cpu consumption (min:secs.hundreths). -.It FAULTS -the number of page faults. -.It PAGEINS -the number of requests for pages from a pager. -.It COW_FAULTS -the number of faults that caused a page to be copied. -.It MSGS_SENT -the number of mach messages sent by the process. -.It MSGS_RCVD -the number of mach messages received by the process. -.It BSDSYSCALL -the number of BSD system calls made by the process. -.It MACHSYSCALL -the number of MACH system calls made by the process. -.It CSWITCH -the number of context switches to this process. -.El -.Pp -The -.Nm top -command also displays some global state in the first few lines of output, -including load averages, cpu utilization and idleness, process and thread counts and memory breakdowns -for shared libraries and processes. -The -.Nm top -command is SIGWINCH savvy, so adjusting your window geometry may change -the number of processes and number of columns displayed. Typing a 'q' will cause top to exit -immediately. Typing any other character will cause top to immediately update it's display. -.Sh SAMPLE USAGE -.Pp -top -u -s5 20 -.Pp -.Nm top -will sort the processes according to cpu usage, update the output at 5 -second intervals, and limit the display to the top 20 processes. -.Sh SEE ALSO -.Xr vm_stat 1 diff --git a/top.tproj/top.c b/top.tproj/top.c deleted file mode 100644 index 2f4bb4e..0000000 --- a/top.tproj/top.c +++ /dev/null @@ -1,2271 +0,0 @@ -/* - * Top users display for Berkeley Unix - * Version 1.8 - * - * This program may be freely redistributed to other Unix sites, but this - * entire comment MUST remain intact. - * - * Copyright (c) 1984, William LeFebvre, Rice University - * - * This program is designed to run on either Berkeley 4.1 or 4.2 Unix. - * Compile with the preprocessor constant "FOUR_ONE" set to get an - * executable that will run on Berkeley 4.1 Unix. - * - * The Sun kernel uses scaled integers instead of floating point so compile - * with the preprocessor variable "SUN" to get an executable that will run - * on Sun Unix version 1.1 or later. - * - * Fixes and enhancements since version 1.5: - * - * Jonathon Feiber at sun: - * added "#ifdef SUN" code to make top work on a Sun, - * fixed race bug in getkval for getting user structure, - * efficiency improvements: added register variables and - * removed the function hashit - * - * added real and virtual memory status line - * - * added second "key" to the qsort comparisn function "proc_compar" - * which sorts by on cpu ticks if percentage is equal - * - ********************************************************************** - * HISTORY - * 22-Apr-99 Avadis Tevanian (avie) at Apple - * Another rewrite for Mach 3.0 - * - * 21-Apr-90 Avadis Tevanian (avie) at NeXT - * Completely rewritten again for processor sets. - * - * 6-May-88 David Golub (dbg) at Carnegie-Mellon University - * Completely rewritten for MACH. This version will NOT run on any - * other version of BSD. - * - */ - -#define Default_TOPN 16 /* default number of lines */ -#define Default_DELAY 1 /* default delay interval */ -#define IOKIT 1 /* for io_name_t in device_types.h */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -/* Number of lines of header information on the standard screen */ -#define HEADER_LINES 8 - -#define sec_to_minutes(t) ((t) / 60) -#define sec_to_seconds(t) ((t) % 60) -#define usec_to_100ths(t) ((t) / 10000) - -#ifndef TH_USAGE_SCALE -#define TH_USAGE_SCALE 1000 -#endif TH_USAGE_SCALE -#define usage_to_percent(u) ((u*100)/TH_USAGE_SCALE) -#define usage_to_tenths(u) (((u*1000)/TH_USAGE_SCALE) % 10) - - -#define time_value_sub(tvp, uvp, vvp) \ - do { \ - (vvp)->seconds = (tvp)->seconds - (uvp)->seconds; \ - (vvp)->microseconds = (tvp)->microseconds - (uvp)->microseconds; \ - if ((vvp)->microseconds < 0) { \ - (vvp)->seconds--; \ - (vvp)->microseconds += 1000000; \ - } \ - } while (0) - - - -/* From libcurses */ -int wclear(WINDOW *win); -int wmove(WINDOW *win, int y, int x); -int wrefresh(WINDOW *win); -int endwin(void); -int werase(WINDOW *win); - -int total_threads; -unsigned long long total_fw_private; - -char bytesread[128]; - -host_cpu_load_info_data_t lastcounters, curcounters, startcounters; -double userticks, systicks, idleticks, totalticks; - -struct timeval cur_tod; -struct timeval start_tod; -struct timeval last_tod; -struct timeval elapsed_tod; -int elapsed_milliseconds; -int newLINES = 0; -int Header_lines = HEADER_LINES; - -int do_proc0_vm; -int sort_by_usage; -int wide_output; -int oneshot; -int logcnt; -int events_only; -int events_delta; -int events_accumulate; -long start_time = 0; - - -struct io_stats { - UInt64 io_accum; - UInt64 io_prev; - UInt64 io; - UInt64 kbytes_accum; - UInt64 kbytes_prev; - UInt64 kbytes; -}; - -struct io_stats i_net, o_net; -struct io_stats i_dsk, o_dsk; -struct io_stats i_vm, o_vm; - - -io_iterator_t drivelist = 0; /* needs release */ -mach_port_t masterPort = 0; - - -struct proc_info { - uid_t uid; - short pid; - short ppid; - short pgrp; - int status; - int flag; - - int state; - int pri; - int base_pri; - boolean_t all_swapped; - boolean_t has_idle_thread; - time_value_t total_time; - time_value_t idle_time; - time_value_t beg_total_time; - time_value_t beg_idle_time; - - vm_size_t virtual_size; - vm_size_t resident_size; - vm_size_t orig_virtual_size; - vm_offset_t drsize, dvsize; - vm_offset_t drprvt, drshrd; - vm_offset_t rvsize; - unsigned int shared; - unsigned int private; - unsigned int vprivate; - int obj_count; - int cpu_usage; - int cpu_idle; - - char command[20]; - - int num_ports; - int orig_num_ports; - int dnum_ports; - int num_threads; - thread_basic_info_t threads; /* array */ - task_events_info_data_t tei; - task_events_info_data_t deltatei; - task_events_info_data_t accumtei; -}; - -typedef struct proc_info *proc_info_t; - -mach_port_t host_priv_port, host_port; - -struct object_info { - int id; - int pid; - int share_type; - int resident_page_count; - int ref_count; - int task_ref_count; - int size; - struct object_info *next; -}; - -#define OBJECT_TABLE_SIZE 537 -#define OT_HASH(object) (((unsigned)object)%OBJECT_TABLE_SIZE) - -struct object_info *shared_hash_table[OBJECT_TABLE_SIZE]; - -struct object_info *of_free_list = 0; - -/* - * Translate thread state to a number in an ordered scale. - * When collapsing all the threads' states to one for the - * entire task, the lower-numbered state dominates. - */ -#define STATE_MAX 7 - -int -mach_state_order(s, sleep_time) - int s; - long sleep_time; - { - switch (s) { - case TH_STATE_RUNNING: return(1); - case TH_STATE_UNINTERRUPTIBLE: - return(2); - case TH_STATE_WAITING: return((sleep_time > 20) ? 4 : 3); - case TH_STATE_STOPPED: return(5); - case TH_STATE_HALTED: return(6); - default: return(7); - } -} - /*01234567 */ -char mach_state_table[] = "ZRUSITH?"; - -char * state_name[] = { - "zombie", - "running", - "stuck", - "sleeping", - "idle", - "stopped", - "halted", - "unknown", -}; -int state_breakdown[STATE_MAX+1]; - - -char *state_to_string(pi) - proc_info_t pi; -{ - static char s[5]; /* STATIC! */ - - s[0] = mach_state_table[pi->state]; - s[1] = (pi->all_swapped) ? 'W' : ' '; - s[2] = (pi->base_pri > 50) ? 'N' : - (pi->base_pri < 40) ? '<' : ' '; - s[3] = ' '; - s[4] = '\0'; - return(s); -} - -void print_time(char *p, time_value_t t) -{ - long seconds, useconds, minutes, hours; - - seconds = t.seconds; - useconds = t.microseconds; - minutes = seconds / 60; - hours = minutes / 60; - - if (minutes < 100) { // up to 100 minutes - sprintf(p, "%2ld:%02ld.%02ld", minutes, seconds % 60, - usec_to_100ths(useconds)); - } - else if (hours < 100) { // up to 100 hours - sprintf(p, "%2ld:%02ld:%02ld", hours, minutes % 60, - seconds % 60); - } - else { - sprintf(p, "%4ld hrs", hours); - } -} - - -void -print_usage(char *p, int cpu_usage) -{ - int left_of_decimal; - int right_of_decimal; - - if (elapsed_milliseconds) { - left_of_decimal = (cpu_usage * 100) / elapsed_milliseconds; - - right_of_decimal = (((cpu_usage * 100) - (left_of_decimal * elapsed_milliseconds)) * 10) / - elapsed_milliseconds; - } else { - left_of_decimal = 0; - right_of_decimal = 0; - } - sprintf(p, "%3d.%01d%%%%", left_of_decimal, right_of_decimal); /* %cpu */ -} - - - -char * -digits(n) - float n; -{ - static char tmp[10]; /* STATIC! */ - - if ((n > 0) && (n < 10)) - sprintf(tmp, "%4.2f", n); - else if ((n > 0) && (n < 100)) - sprintf(tmp, "%4.1f", n); - else if ((n < 0) && (n > -10)) - sprintf(tmp, "%4.1f", n); - else - sprintf(tmp, "%4.0f", n); - return(tmp); -} - -char * -mem_to_string(n) - unsigned long long n; -{ - static char s[10]; /* STATIC! */ - - /* convert to kilobytes */ - n /= 1024; - - if (n > 1024*1024) - sprintf(s, "%sG", digits(((float)n)/(1024.0*1024.0))); - else if (n > 1024) - sprintf(s, "%sM", digits((float)n/(1024.0))); - else - sprintf(s, "%dK", (int)n); - - return(s); -} - -char * -offset_to_string(n) - int n; -{ - static char s[10]; /* STATIC! */ - int an; - - /* convert to kilobytes */ - n /= 1024; - an = abs(n); - - if (an > 1024*1024) - sprintf(s, "%sG", digits(((float)n)/(1024.0*1024.0))); - else if (an > 1024) - sprintf(s, "%sM", digits((float)n/(1024.0))); - else - sprintf(s, "%dK", n); - - return(s); -} - -mach_port_t get_host_priv() -{ - return(mach_host_self()); -} - -mach_port_t get_host_port() -{ - return(mach_host_self()); -} - -void -shared_hash_enter(int obj_id, int share_type, int resident_page_count, int ref_count, int size, int pid) -{ - register struct object_info **bucket; - register struct object_info *of; - - of = shared_hash_table[OT_HASH(obj_id/OBJECT_TABLE_SIZE)]; - while (of) { - if (of->id == obj_id) { - of->size += size; - of->task_ref_count++; - of->pid = pid; - return; - } - of = of->next; - } - bucket = &shared_hash_table[OT_HASH(obj_id/OBJECT_TABLE_SIZE)]; - - if (of = of_free_list) - of_free_list = of->next; - else - of = (struct object_info *) malloc(sizeof(*of)); - - of->resident_page_count = resident_page_count; - of->id = obj_id; - of->share_type = share_type; - of->ref_count = ref_count; - of->task_ref_count = 1; - of->pid = pid; - of->size = size; - - of->next = *bucket; - *bucket = of; -} - -void -pmem_doit(task_port_t task, int pid, int *shared, int *private, int *aliased, int *obj_count, int *vprivate, vm_size_t *vsize, unsigned long long *fw_private) -{ - vm_address_t address = 0; - kern_return_t err = 0; - register int i; - int split = 0; - - *obj_count = *aliased = *shared = *private = *vprivate = 0; - - while (1) { - mach_port_t object_name; - vm_region_top_info_data_t info; - mach_msg_type_number_t count; - vm_size_t size; - - count = VM_REGION_TOP_INFO_COUNT; - - if (err = vm_region(task, &address, &size, VM_REGION_TOP_INFO, (vm_region_info_t)&info, - &count, &object_name)) - break; - - if (address >= GLOBAL_SHARED_TEXT_SEGMENT && address < (GLOBAL_SHARED_DATA_SEGMENT + SHARED_DATA_REGION_SIZE)) { - - *fw_private += info.private_pages_resident * vm_page_size; - - if ( !split && info.share_mode == SM_EMPTY) { - vm_region_basic_info_data_64_t b_info; - - count = VM_REGION_BASIC_INFO_COUNT_64; - if (err = vm_region_64(task, &address, &size, VM_REGION_BASIC_INFO, (vm_region_info_t)&b_info, - &count, &object_name)) - break; - - if (b_info.reserved) - split = 1; - } - if (info.share_mode != SM_PRIVATE) { - address += size; - continue; - } - } - address += size; - - *obj_count += 1; - - switch (info.share_mode) { - - case SM_PRIVATE: - *private += info.private_pages_resident * vm_page_size; - *vprivate += size; - break; - - case SM_COW: - if (info.ref_count == 1) - info.share_mode = SM_PRIVATE; - if (pid && info.share_mode == SM_COW) - shared_hash_enter(info.obj_id, SM_COW, info.shared_pages_resident, - info.ref_count, size, pid); - if (info.share_mode == SM_PRIVATE) - *private += info.shared_pages_resident * vm_page_size; - *private += info.private_pages_resident * vm_page_size; - - if (info.share_mode == SM_PRIVATE) - *vprivate += size; - else - *vprivate += info.private_pages_resident * vm_page_size; - break; - - case SM_SHARED: - if (pid) - shared_hash_enter(info.obj_id, SM_SHARED, info.shared_pages_resident, - info.ref_count, size, pid); - break; - } - } - for (i = 0; i < OBJECT_TABLE_SIZE; i++) { - register struct object_info *sl; - - sl = shared_hash_table[i]; - - while (sl) { - if (sl->pid == pid) { - if (sl->share_type == SM_SHARED) { - if (sl->ref_count == sl->task_ref_count) { - sl->share_type = SM_PRIVATE_ALIASED; - - *aliased += sl->resident_page_count * vm_page_size; - *vprivate += sl->size; - } - } - if (sl->share_type != SM_PRIVATE_ALIASED) - *shared += sl->resident_page_count * vm_page_size; - } - sl->task_ref_count = 0; - - sl = sl->next; - } - } - if (split) - *vsize -= (SHARED_TEXT_REGION_SIZE + SHARED_DATA_REGION_SIZE); -} - - -void -pmem_fw_resident(unsigned int *num_fw, unsigned long long *vsize, unsigned int *code_size, unsigned int *data_size, unsigned int *linkedit_size) -{ vm_address_t address = GLOBAL_SHARED_TEXT_SEGMENT; - kern_return_t err = 0; - int state = 0; - - *vsize = 0; - *num_fw = 0; - *code_size = 0; - *data_size = 0; - *linkedit_size = 0; - - while (address < (GLOBAL_SHARED_DATA_SEGMENT + SHARED_DATA_REGION_SIZE)) { - vm_region_submap_info_data_64_t s_info; - mach_msg_type_number_t count; - vm_size_t size; - int nesting_depth; - - nesting_depth = 1; - count = VM_REGION_SUBMAP_INFO_COUNT_64; - - if (err = vm_region_recurse_64(mach_task_self(), &address, &size, &nesting_depth, (vm_region_info_t)&s_info, &count)) - break; - - if (address >= (GLOBAL_SHARED_DATA_SEGMENT + SHARED_DATA_REGION_SIZE)) - break; - if (address < GLOBAL_SHARED_DATA_SEGMENT) { - - if (s_info.share_mode == SM_SHARED || s_info.share_mode == SM_COW) { - if (s_info.max_protection & VM_PROT_EXECUTE) { - *code_size += (s_info.pages_resident * vm_page_size); - - if (state == 0) - *num_fw += 1; - state = 1; - - } else { - *linkedit_size += (s_info.pages_resident * vm_page_size); - - state = 0; - } - } - - } else { - if (s_info.share_mode == SM_SHARED || s_info.share_mode == SM_COW || s_info.share_mode == SM_TRUESHARED) - *data_size += (s_info.pages_resident * vm_page_size); - } - *vsize += size; - - address += size; - } -} - - - - -void -pmem_shared_resident(unsigned long long *total, int *number) -{ register int i; - register int total_size; - register int total_num; - register struct object_info *sl, *next; - - total_size = total_num = 0; - - for (i = 0; i < OBJECT_TABLE_SIZE; i++) { - sl = shared_hash_table[i]; - shared_hash_table[i] = 0; - - while (sl) { - if (sl->share_type != SM_PRIVATE_ALIASED) { - total_size += sl->resident_page_count; - total_num++; - } - next = sl->next; - - sl->next = of_free_list; - of_free_list = sl; - - sl = next; - } - } - *number = total_num; - *total = total_size * vm_page_size; -} - - -int -get_real_command_name(int pid, char *cbuf, int csize) -{ - /* - * Get command and arguments. - */ - volatile int *ip, *savedip; - volatile char *cp; - char c; - char *end_argc; - int mib[4]; - char *arguments; - int arguments_size = 4096; - volatile unsigned int *valuep; - unsigned int value; - int blahlen=0, skiplen=0; - - /* - * A sysctl() is made to find out the full path that the command - * was called with. - */ - mib[0] = CTL_KERN; - mib[1] = KERN_PROCARGS; - mib[2] = pid; - mib[3] = 0; - - arguments = (char *) malloc(arguments_size); - if (sysctl(mib, 3, arguments, (size_t *)&arguments_size, NULL, 0) < 0) { - free(arguments); - return(0); - } - end_argc = &arguments[arguments_size]; - - ip = (int *)end_argc; - ip -= 2; /* last arg word and .long 0 */ - while (*--ip) { - if (ip == (int *)arguments) { - free(arguments); - return(0); - } - } - savedip = ip; - savedip++; - cp = (char *)savedip; - while (*--ip) { - if (ip == (int *)arguments) { - free(arguments); - return(0); - } - } - ip++; - valuep = (unsigned int *)ip; - value = *valuep; - - if ((value & 0xbfff0000) == 0xbfff0000) { - ip++; ip++; - valuep = ip; - blahlen = strlen((char *)ip); - skiplen = (blahlen +3 ) /4 ; - valuep += skiplen; - cp = (char *)valuep; - while (!*cp) - cp++; - savedip = (int *)cp; - } - for (cp = (char *)savedip; cp < (end_argc-1); cp++) { - c = *cp & 0177; - - if (c == 0) - break; - } - *cp = 0; - - if (cp > (char *)savedip) - cp--; - - while (cp > (char *)savedip) { - if (*cp == '/') { - cp++; - break; - } - cp--; - } - if (cp[0] == '-' || cp[0] == '?' || cp[0] <= ' ') { - /* - * Not enough information - */ - free(arguments); - return(0); - } - (void) strncpy(cbuf, (char *)cp, csize); - cbuf[csize] = '\0'; - - free(arguments); - return(1); -} - - -/* All of this should come out of the process manager... */ - -void get_proc_info(kpb, pi) - struct kinfo_proc *kpb; - struct proc_info *pi; -{ - task_port_t task; - mach_port_array_t names, types; - unsigned int ncnt, tcnt; - - pi->uid = kpb->kp_eproc.e_ucred.cr_uid; - pi->pid = kpb->kp_proc.p_pid; - pi->ppid = kpb->kp_eproc.e_ppid; - pi->pgrp = kpb->kp_eproc.e_pgid; - pi->status = kpb->kp_proc.p_stat; - pi->flag = kpb->kp_proc.p_flag; - - /* - * Find the other stuff - */ - if (task_for_pid(mach_task_self(), pi->pid, &task) != KERN_SUCCESS) { - pi->status = SZOMB; - } - - else { - task_basic_info_data_t ti; - unsigned int count; - unsigned int aliased; - thread_array_t thread_table; - unsigned int table_size; - thread_basic_info_t thi; - thread_basic_info_data_t thi_data; - int i, t_state; - - count = TASK_BASIC_INFO_COUNT; - if (task_info(task, TASK_BASIC_INFO, (task_info_t)&ti, - &count) != KERN_SUCCESS) { - pi->status = SZOMB; - } else { - pi->virtual_size = ti.virtual_size; - - pi->resident_size = ti.resident_size; - - if ((pi->pid || do_proc0_vm) && (!events_only)) { - pmem_doit(task, pi->pid, &pi->shared, &pi->private, &aliased, &pi->obj_count, &pi->vprivate, &pi->virtual_size, &total_fw_private); - pi->private += aliased; - } else { - pi->shared = 0; - pi->private = 0; - pi->vprivate = 0; - pi->obj_count = 0; - } - pi->orig_virtual_size = pi->virtual_size; - pi->total_time = ti.user_time; - time_value_add(&pi->total_time, &ti.system_time); - - pi->idle_time.seconds = 0; - pi->idle_time.microseconds = 0; - - if (task_threads(task, &thread_table, &table_size) != KERN_SUCCESS) - pi->status = SZOMB; - else { - pi->state = STATE_MAX; - pi->pri = 255; - pi->base_pri = 255; - pi->all_swapped = TRUE; - pi->has_idle_thread = FALSE; - - thi = &thi_data; - - pi->num_threads = table_size; - total_threads += table_size; - - for (i = 0; i < table_size; i++) { - count = THREAD_BASIC_INFO_COUNT; - if (thread_info(thread_table[i], THREAD_BASIC_INFO, - (thread_info_t)thi, &count) == KERN_SUCCESS) { - - if (thi->flags & TH_FLAGS_IDLE) { - pi->has_idle_thread = TRUE; - - time_value_add(&pi->idle_time, - &thi->user_time); - time_value_add(&pi->idle_time, - &thi->system_time); - } else { - time_value_add(&pi->total_time, - &thi->user_time); - time_value_add(&pi->total_time, - &thi->system_time); - } - t_state = mach_state_order(thi->run_state, - thi->sleep_time); - if (t_state < pi->state) - pi->state = t_state; -// update priority info based on schedule policy -// if (thi->cur_priority < pi->pri) -// pi->pri = thi->cur_priority; -// if (thi->base_priority < pi->base_pri) -// pi->base_pri = thi->base_priority; - if ((thi->flags & TH_FLAGS_SWAPPED) == 0) - pi->all_swapped = FALSE; - - } - if (task != mach_task_self()) { - mach_port_deallocate(mach_task_self(), - thread_table[i]); - } - } - (void) vm_deallocate(mach_task_self(), (vm_offset_t)thread_table, - table_size * sizeof(*thread_table)); - - if (!events_only) { - if (mach_port_names(task, &names, &ncnt, - &types, &tcnt) == KERN_SUCCESS) { - pi->num_ports = ncnt; - pi->orig_num_ports = ncnt; - (void) vm_deallocate(mach_task_self(), - (vm_offset_t) names, - ncnt * sizeof(*names)); - (void) vm_deallocate(mach_task_self(), - (vm_offset_t) types, - tcnt * sizeof(*types)); - } else { - pi->num_ports = -1; - } - } else - pi->num_ports = 0; - - if (events_only) { - task_events_info_data_t tei; - - count = TASK_EVENTS_INFO_COUNT; - if (task_info(task, TASK_EVENTS_INFO, (task_info_t)&tei, - &count) != KERN_SUCCESS) { - pi->status = SZOMB; - } else { - pi->tei = tei; - - } - } - } - } - if (task != mach_task_self()) { - mach_port_deallocate(mach_task_self(), task); - } - } - if ( strncmp (kpb->kp_proc.p_comm, "LaunchCFMA", 10) || - !get_real_command_name(pi->pid, pi->command, sizeof(kpb->kp_proc.p_comm)-1)) { - (void) strncpy(pi->command, kpb->kp_proc.p_comm, - sizeof(kpb->kp_proc.p_comm)-1); - pi->command[sizeof(kpb->kp_proc.p_comm)-1] = '\0'; - } -} - - -/* - * signal handlers - */ - -void leave() /* exit under normal conditions -- INT handler */ -{ - if (!oneshot) { - move(LINES - 1, 0); - refresh(); - endwin(); - } - exit(0); -} - -void quit(status) /* exit under duress */ - int status; -{ - if (!oneshot) - endwin(); - exit(status); -} - -void sigwinch() -{ - newLINES = 1; -} - - -/* - * comparison function for "qsort" - * Do first order sort based on cpu percentage computed by kernel and - * second order sort based on total time for the process. - */ - -int proc_compar(p1, p2) - register struct proc_info **p1; - register struct proc_info **p2; -{ - if (sort_by_usage) { - if ((*p1)->cpu_usage < (*p2)->cpu_usage) - return(1); - else if ((*p1)->cpu_usage > (*p2)->cpu_usage) - return(-1); - else { - if ((*p1)->total_time.seconds < (*p2)->total_time.seconds) - return(1); - else - return(-1); - } - } - else { - if ((*p1)->pid < (*p2)->pid) - return(1); - else - return(-1); - } -} - - -int nproc, total_procs, old_procs; -struct kinfo_proc *kbase, *kpb; -struct proc_info *proc, *pp, *oldproc; -struct proc_info **pref, **prefp; - -int topn = 0; -int wanted_topn = 0; -vm_size_t pagesize; - - - -void grab_task(task) - task_t task; -{ - int pid; - size_t size; - kern_return_t ret; - struct kinfo_proc ki; - int mib[4]; - - ret = pid_for_task(task, &pid); - if (ret != KERN_SUCCESS) - return; - size = sizeof(ki); - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_PID; - mib[3] = pid; - - if (sysctl(mib, 4, &ki, &size, NULL, 0) < 0) { - perror("failure calling sysctl"); - exit(1); - } - if (ki.kp_proc.p_stat == 0) { - state_breakdown[0]++; - return; - } - if (total_procs == nproc) { - nproc *= 2; - kbase = (struct kinfo_proc *) realloc(kbase, - nproc*sizeof(struct kinfo_proc)); - bzero(&kbase[total_procs], total_procs*sizeof(struct kinfo_proc)); - proc = (struct proc_info *) realloc(proc, - nproc*sizeof(struct proc_info)); - bzero(&proc[total_procs], total_procs*sizeof(struct proc_info)); - oldproc = (struct proc_info *) realloc(oldproc, - nproc*sizeof(struct proc_info)); - bzero(&oldproc[total_procs], total_procs*sizeof(struct proc_info)); - pref = (struct proc_info **) realloc(pref, - nproc*sizeof(struct proc_info *)); - bzero(&pref[total_procs], total_procs*sizeof(struct proc_info *)); - } - kbase[total_procs] = ki; - total_procs++; -} - -void update_histdata() -{ - struct proc_info *pp, *oldp; - int i, j, pid; - time_value_t elapsed_time; - - i = 0; - pp = proc; - - // XXX use linear search since list is usually small - - while (i < total_procs) { - j = 0; - oldp = oldproc; - pid = pp->pid; - - while (j < old_procs) { - if (oldp->pid == pid) { - pp->drprvt = pp->private - oldp->private; - pp->drshrd = pp->shared - oldp->shared; - pp->drsize = pp->resident_size - oldp->resident_size; - pp->dvsize = pp->virtual_size - oldp->virtual_size; - - pp->rvsize = pp->virtual_size - oldp->orig_virtual_size; - pp->orig_virtual_size = oldp->orig_virtual_size; - - pp->dnum_ports = pp->num_ports - oldp->orig_num_ports; - pp->orig_num_ports = oldp->orig_num_ports; - - if (pp->has_idle_thread == TRUE) { - if (events_accumulate) { - time_value_sub(&pp->idle_time, &oldp->beg_idle_time, &elapsed_time); - pp->beg_idle_time = oldp->beg_idle_time; - pp->idle_time = elapsed_time; - } else - time_value_sub(&pp->idle_time, &oldp->idle_time, &elapsed_time); - - pp->cpu_idle = (elapsed_time.seconds * 1000) + (elapsed_time.microseconds / 1000); - } - if (events_accumulate) { - time_value_sub(&pp->total_time, &oldp->beg_total_time, &elapsed_time); - pp->beg_total_time = oldp->beg_total_time; - pp->total_time = elapsed_time; - } else - time_value_sub(&pp->total_time, &oldp->total_time, &elapsed_time); - - pp->cpu_usage = (elapsed_time.seconds * 1000) + (elapsed_time.microseconds / 1000); - - if (events_delta) - { - pp->deltatei.pageins = pp->tei.pageins - oldp->tei.pageins; - pp->deltatei.faults = pp->tei.faults - oldp->tei.faults; - pp->deltatei.cow_faults = pp->tei.cow_faults - oldp->tei.cow_faults; - pp->deltatei.messages_sent = pp->tei.messages_sent - oldp->tei.messages_sent; - pp->deltatei.messages_received = pp->tei.messages_received - oldp->tei.messages_received; - pp->deltatei.syscalls_unix = pp->tei.syscalls_unix - oldp->tei.syscalls_unix; - pp->deltatei.syscalls_mach = pp->tei.syscalls_mach - oldp->tei.syscalls_mach; - pp->deltatei.csw = pp->tei.csw - oldp->tei.csw; - } - if (events_accumulate) - { - pp->deltatei.pageins = pp->tei.pageins - oldp->accumtei.pageins; - pp->deltatei.faults = pp->tei.faults - oldp->accumtei.faults; - pp->deltatei.cow_faults = pp->tei.cow_faults - oldp->accumtei.cow_faults; - pp->deltatei.messages_sent = pp->tei.messages_sent - oldp->accumtei.messages_sent; - pp->deltatei.messages_received = pp->tei.messages_received - oldp->accumtei.messages_received; - pp->deltatei.syscalls_unix = pp->tei.syscalls_unix - oldp->accumtei.syscalls_unix; - pp->deltatei.syscalls_mach = pp->tei.syscalls_mach - oldp->accumtei.syscalls_mach; - pp->deltatei.csw = pp->tei.csw - oldp->accumtei.csw; - - pp->accumtei = oldp->accumtei; - } - break; - } - j++; - oldp++; - } - if (j >= old_procs) { - if (events_accumulate) { - pp->accumtei = pp->tei; - pp->beg_total_time = pp->total_time; - pp->beg_idle_time = pp->idle_time; - - pp->idle_time.seconds = 0; - pp->idle_time.microseconds = 0; - pp->total_time.seconds = 0; - pp->total_time.microseconds = 0; - } - bzero(&pp->deltatei, sizeof (task_events_info_data_t)); - - pp->drprvt = 0; - pp->drshrd = 0; - pp->drsize = 0; - pp->dvsize = 0; - pp->rvsize = 0; - pp->dnum_ports = 0; - pp->cpu_usage = 0; - pp->cpu_idle = 0; - } - i++; - pp++; - } - bcopy(proc, oldproc, total_procs*sizeof(struct proc_info)); - old_procs = total_procs; -} - -void read_proc_table() -{ - mach_port_t host; - processor_set_t *psets; - task_t *tasks; - unsigned int pcount, tcount; - kern_return_t ret; - processor_set_t p; - int i, j; - - total_procs = 0; - total_threads = 0; - - host = host_priv_port; - - if (host == MACH_PORT_NULL) { - printf("Insufficient privileges.\n"); - exit(0); - } - ret = host_processor_sets(host, &psets, &pcount); - if (ret != KERN_SUCCESS) { - mach_error("host_processor_sets", ret); - exit(0); - } - for (i = 0; i < pcount; i++) { - ret = host_processor_set_priv(host, psets[i], &p); - if (ret != KERN_SUCCESS) { - mach_error("host_processor_set_priv", ret); - exit(0); - } - - ret = processor_set_tasks(p, &tasks, &tcount); - if (ret != KERN_SUCCESS) { - mach_error("processor_set_tasks", ret); - exit(0); - } - for (j = 0; j < tcount; j++) { - grab_task(tasks[j]); - // don't delete our own task port - if (tasks[j] != mach_task_self()) - mach_port_deallocate(mach_task_self(), - tasks[j]); - } - vm_deallocate(mach_task_self(), (vm_address_t)tasks, - tcount * sizeof(task_t)); - mach_port_deallocate(mach_task_self(), p); - mach_port_deallocate(mach_task_self(), psets[i]); - } - vm_deallocate(mach_task_self(), (vm_address_t)psets, - pcount * sizeof(processor_set_t)); -} - -kern_return_t getCPU(cpucounters) - host_cpu_load_info_t cpucounters; -{ - mach_msg_type_number_t count; - kern_return_t kr; - - count = HOST_CPU_LOAD_INFO_COUNT; - kr = host_statistics (host_priv_port, HOST_CPU_LOAD_INFO, - (host_info_t)cpucounters, &count); - - return(kr); -} - -updateCPU() -{ - - if (events_accumulate) { - userticks = curcounters.cpu_ticks[CPU_STATE_USER]- - startcounters.cpu_ticks[CPU_STATE_USER]; - - systicks = curcounters.cpu_ticks[CPU_STATE_SYSTEM]- - startcounters.cpu_ticks[CPU_STATE_SYSTEM]; - - idleticks = curcounters.cpu_ticks[CPU_STATE_IDLE]- - startcounters.cpu_ticks[CPU_STATE_IDLE]; - } else if (events_only && !events_delta) { - - userticks = curcounters.cpu_ticks[CPU_STATE_USER]; - - systicks = curcounters.cpu_ticks[CPU_STATE_SYSTEM]; - - idleticks = curcounters.cpu_ticks[CPU_STATE_IDLE]; - } else { - userticks = curcounters.cpu_ticks[CPU_STATE_USER]- - lastcounters.cpu_ticks[CPU_STATE_USER]; - - systicks = curcounters.cpu_ticks[CPU_STATE_SYSTEM]- - lastcounters.cpu_ticks[CPU_STATE_SYSTEM]; - - idleticks = curcounters.cpu_ticks[CPU_STATE_IDLE]- - lastcounters.cpu_ticks[CPU_STATE_IDLE]; - - lastcounters = curcounters; - } - totalticks = userticks + systicks + idleticks; -} - - - -main(argc, argv) - int argc; - char *argv[]; -{ - char *myname = "top"; - int ch; - int delay = Default_DELAY; - kern_return_t error; - - void screen_update(); - - /* get our name */ - if (argc > 0) { - if ((myname = rindex(argv[0], '/')) == 0) { - myname = argv[0]; - } - else { - myname++; - } - } - - /* check for options */ - sort_by_usage = 0; - wide_output = 0; - do_proc0_vm = 0; - events_only = 0; - events_delta = 0; - events_accumulate = 0; - - while ((ch = getopt(argc, argv, "uwks:edal:")) != EOF) { - switch(ch) { - case 's': - delay = atoi(optarg); - break; - case 'u': - sort_by_usage = 1; - break; - case 'w': - wide_output = 1; - break; - case 'k': - do_proc0_vm = 1; - break; - case 'e': - events_only = 1; - break; - case 'd': - events_only = 1; - events_delta = 1; - break; - case 'a': - events_only = 1; - events_accumulate = 1; - break; - case 'l': - logcnt = atoi(optarg); - oneshot = 1; - LINES = 80; - COLS = 132; - break; - default: - fprintf(stderr, "Usage: %s [-u] [-w] [-k] [-sn] [-e | -d | -a] [-ln] [number]\n", myname); - fprintf(stderr, " -u enables sort by usage\n"); - fprintf(stderr, " -w enables wide output of additional info\n"); - fprintf(stderr, " -k generate vm info for kernel(proc 0)... expensive\n"); - fprintf(stderr, " -sn change sample rate to every n seconds\n"); - fprintf(stderr, " -e switch to events info counter mode\n"); - fprintf(stderr, " -d switch to events info counter delta mode\n"); - fprintf(stderr, " -a switch to events info counter accumulate mode\n"); - fprintf(stderr, " -ln log n samples\n"); - fprintf(stderr, " number limit number of processes monitored\n"); - - exit(1); - } - } - - argc -= optind; - //argv += optind; - - if (events_only) - { - if ( wide_output || do_proc0_vm) - { - fprintf(stderr, " The -w and -k flag have no effect in event mode.\n"); - wide_output = 0; - do_proc0_vm = 0; - } - } - - host_priv_port = get_host_priv(); - host_port = get_host_port(); - - /* get count of top processes to display (if any) */ - if (argc) { - wanted_topn = topn = atoi(argv[optind]); - } else - wanted_topn = -1; - - /* allocate space for proc structure array and array of pointers */ - nproc = 50; /* starting point */ - kbase = (struct kinfo_proc *) malloc(nproc*sizeof(struct kinfo_proc)); - bzero(kbase, nproc*sizeof(struct kinfo_proc)); - proc = (struct proc_info *) malloc(nproc*sizeof(struct proc_info)); - bzero(proc, nproc*sizeof(struct proc_info)); - oldproc = (struct proc_info *) malloc(nproc*sizeof(struct proc_info)); - bzero(oldproc, nproc*sizeof(struct proc_info)); - pref = (struct proc_info **) malloc(nproc*sizeof(struct proc_info *)); - bzero(pref, nproc*sizeof(struct proc_info *)); - - (void) host_page_size(host_port, &pagesize); - /* initializes curses and screen (last) */ - - if (!oneshot) { - initscr(); - cbreak(); - timeout(delay * 1000); - noecho(); - erase(); - clear(); - refresh(); - } - /* set up signal handlers */ - signal(SIGINT, leave); - signal(SIGQUIT, leave); - signal(SIGWINCH, sigwinch); - - /* can only display (LINES - Header_lines) processes */ - if (topn > LINES - Header_lines) { - if (!oneshot) - printw("Warning: this terminal can only display %d processes...\n", - LINES - Header_lines); - else - printf("Warning: this terminal can only display %d processes...\n", - LINES - Header_lines); - - if (!oneshot) - refresh(); - sleep(2); - topn = LINES - Header_lines; - if (!oneshot) - clear(); - } - if (topn == 0) { // use default - // leave one blank line at bottom - - topn = LINES - Header_lines - 1; - } - - /* prime the pump for gathering networking stats */ - kread(0, 0, 0); - - /**************************************************/ - /* get ports and services for drive stats */ - /* Obtain the I/O Kit communication handle */ - - error = IOMasterPort(bootstrap_port, &masterPort); - - /* Obtain the list of all drive objects */ - - error = IOServiceGetMatchingServices(masterPort, - IOServiceMatching("IOBlockStorageDriver"), - &drivelist); - getCPU(&lastcounters); - startcounters = lastcounters; - - gettimeofday(&cur_tod, NULL); - start_tod = cur_tod; - elapsed_milliseconds = -1; - - /* main loop */ - - while (1) { - int n; - - if (newLINES) { - newLINES = 0; - - if (!oneshot) { - struct winsize size; - - if (ioctl(1, TIOCGWINSZ, &size) != -1) { - resizeterm(size.ws_row, size.ws_col); - erase(); - clear(); - } - } - n = LINES - Header_lines; - - if (topn >= n) - topn = n; - else { - if (wanted_topn == -1) - topn = n; - else if (topn < wanted_topn) { - if (wanted_topn < n) - topn = wanted_topn; - else - topn = n; - } - } - } - (void)screen_update(); - - if (!oneshot) { - int c; - - if ((c = getch()) != ERR && (char)c == 'q') - leave(); - } else - sleep(delay); - } -} - -void screen_update() -{ - char c; - int i, n, mpid; - int active_procs; - int avenrun[3]; - long curr_time; - long elapsed_secs; - unsigned long long total_fw_vsize; - unsigned long long total_virtual_size; - unsigned long long total_private_size; - unsigned long long total_shared_size; - unsigned int total_memory_regions = 0; - unsigned int total_shared_objects; - unsigned int total_fw_code_size; - unsigned int total_fw_data_size; - unsigned int total_fw_linkedit_size; - unsigned int total_frameworks; - vm_statistics_data_t vm_stat; - struct host_load_info load_data; - int host_count; - kern_return_t error; - char tbuf[256]; - char *dp; - int clen; - - bzero((char *)state_breakdown, sizeof(state_breakdown)); - - if (!oneshot) { - /* clear for new display */ - erase(); - } - /* read all of the process information */ - read_proc_table(); - - /* get the load averages */ - host_count = sizeof(load_data)/sizeof(integer_t); - error = host_statistics(host_priv_port, HOST_LOAD_INFO, - (host_info_t)&load_data, &host_count); - if (error != KERN_SUCCESS) { - mach_error("host_statistics", error); - exit(EXIT_FAILURE); - } - - avenrun[0] = load_data.avenrun[0]; - avenrun[1] = load_data.avenrun[1]; - avenrun[2] = load_data.avenrun[2]; - - /* get total - systemwide main memory usage structure */ - host_count = sizeof(vm_stat)/sizeof(integer_t); - error = host_statistics(host_priv_port, HOST_VM_INFO, - (host_info_t)&vm_stat, &host_count); - if (error != KERN_SUCCESS) { - mach_error("host_info", error); - exit(EXIT_FAILURE); - } - - if (events_only) { - getNETWORKcounters(); - getDISKcounters(); - } - /* count up process states and get pointers to interesting procs */ - - mpid = 0; - active_procs = 0; - total_virtual_size = 0; - total_private_size = 0; - total_fw_private = 0; - - prefp = pref; - for (kpb = kbase, pp = proc, i = 0; - i < total_procs; - kpb++, pp++, i++) { - - /* place pointers to each valid proc structure in pref[] */ - get_proc_info(kpb, pp); - - if (kpb->kp_proc.p_stat != 0) { - *prefp++ = pp; - active_procs++; - if (pp->pid > mpid) - mpid = pp->pid; - - if ((unsigned int)pp->state > (unsigned int)STATE_MAX) - pp->state = STATE_MAX; - state_breakdown[pp->state]++; - total_virtual_size += pp->virtual_size; - total_private_size += pp->private; - total_memory_regions += pp->obj_count; - } - else - state_breakdown[0]++; - } - /* get the cpu counters */ - getCPU(&curcounters); - updateCPU(); - - if (elapsed_milliseconds != -1) { - last_tod = cur_tod; - gettimeofday(&cur_tod, NULL); - - if (events_accumulate) - timersub(&cur_tod, &start_tod, &elapsed_tod); - else - timersub(&cur_tod, &last_tod, &elapsed_tod); - - elapsed_milliseconds = (elapsed_tod.tv_sec * 1000) + (elapsed_tod.tv_usec / 1000); - } else - elapsed_milliseconds = 0; - - if (!events_only) { - pmem_fw_resident(&total_frameworks, &total_fw_vsize, &total_fw_code_size, &total_fw_data_size, &total_fw_linkedit_size); - - pmem_shared_resident(&total_shared_size, &total_shared_objects); - } - if (!oneshot) - move(0,0); - - /* display process state breakdown */ - sprintf(tbuf, "Processes: %d total", total_procs); - clen = strlen(tbuf); - - - for (i = 0; i <= STATE_MAX; i++) { - if (state_breakdown[i] != 0) { - sprintf(&tbuf[clen], ", %d %s%s", - state_breakdown[i], - state_name[i], - (i == 0 && state_breakdown[0] > 1) ? "s" : "" - ); - - clen = clen + strlen(&tbuf[clen]); - } - } - sprintf(&tbuf[clen], "... %d threads", total_threads); - - clen = clen + strlen(&tbuf[clen]); - /* - * Display the current time. - * "ctime" always returns a string that looks like this: - * - * Sun Sep 16 01:03:52 1973 - * 012345678901234567890123 - * 1 2 - * - * We want indices 11 thru 18 (length 8). - */ - curr_time = time((long *)0); - - if (start_time == 0) - start_time = curr_time; - - memset(&tbuf[clen], ' ', 111 - clen); - - if (wide_output) - clen = 118 - 8; - else if (events_accumulate) - clen = 103 - 8; - else if (events_only && !events_delta) - clen = 115 - 8; - else - clen = 79 - 8; - - sprintf(&tbuf[clen], "%-8.8s", &(ctime(&curr_time)[11])); - clen = clen + strlen(&tbuf[clen]); - - if (events_accumulate) { - int hours; - int minutes; - - elapsed_secs = curr_time - start_time; - minutes = elapsed_secs / 60; - hours = minutes / 60; - - sprintf(&tbuf[clen], " %3ld:%02ld:%02ld\n", hours, minutes % 60, elapsed_secs % 60); - } else { - sprintf(&tbuf[clen], "\n"); - } - - if (tbuf[COLS-2] != '\n') { - tbuf[COLS-1] = '\n'; - tbuf[COLS] = 0; - } - if (!oneshot) - printw(tbuf); - else - printf(tbuf); - - /* display the load averages */ - sprintf(tbuf, "Load Avg"); - clen = strlen(tbuf); - - for (i = 0; i < 3; i++) { - sprintf(&tbuf[clen], "%s %4.2f", i == 0 ? ": " : ",", - (double)avenrun[i] / LOAD_SCALE); - clen = clen + strlen(&tbuf[clen]); - } - if (totalticks) { - sprintf(&tbuf[clen], " CPU usage: %.1f%%%% user, %.1f%%%% sys, %.1f%%%% idle\n", - (100*userticks)/totalticks, (100*systicks)/totalticks, (100*idleticks)/totalticks); - clen = clen + strlen(&tbuf[clen]); - } - if (tbuf[COLS-2] != '\n') { - tbuf[COLS-1] = '\n'; - tbuf[COLS] = 0; - } - if (!oneshot) - printw(tbuf); - else - printf(tbuf); - - if (!events_only) { - sprintf(tbuf, "SharedLibs: num = %4d, ", total_frameworks); - clen = strlen(tbuf); - sprintf(&tbuf[clen], "resident = %s code, ", mem_to_string((unsigned long long)total_fw_code_size)); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], "%s data, ", mem_to_string((unsigned long long)total_fw_data_size)); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], "%s LinkEdit\n", mem_to_string((unsigned long long)total_fw_linkedit_size)); - - if (tbuf[COLS-2] != '\n') { - tbuf[COLS-1] = '\n'; - tbuf[COLS] = 0; - } - if (!oneshot) - printw(tbuf); - else - printf(tbuf); - - sprintf(tbuf, "MemRegions: num = %4d, ", total_memory_regions); - clen = strlen(tbuf); - sprintf(&tbuf[clen], "resident = %s + ", mem_to_string(total_private_size - total_fw_private)); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], "%s private, ", mem_to_string(total_fw_private)); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], "%s shared\n", mem_to_string(total_shared_size)); - - if (tbuf[COLS-2] != '\n') { - tbuf[COLS-1] = '\n'; - tbuf[COLS] = 0; - } - if (!oneshot) - printw(tbuf); - else - printf(tbuf); - - /* display main memory statistics */ - { - unsigned long long total_resident_size, - active_resident_size, - inactive_resident_size, - wire_resident_size, - free_size; - - active_resident_size = (unsigned long long) vm_stat.active_count * (unsigned long long) pagesize; - inactive_resident_size = (unsigned long long) vm_stat.inactive_count * (unsigned long long) pagesize; - wire_resident_size = (unsigned long long) vm_stat.wire_count * (unsigned long long) pagesize; - total_resident_size = (unsigned long long) (vm_stat.active_count + vm_stat.inactive_count + vm_stat.wire_count) * (unsigned long long) pagesize; - free_size = (unsigned long long) vm_stat.free_count * (unsigned long long) pagesize; - - sprintf(tbuf, "PhysMem: "); - clen = strlen(tbuf); - sprintf(&tbuf[clen], "%s wired, ", mem_to_string(wire_resident_size)); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], "%s active, ", mem_to_string(active_resident_size)); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], "%s inactive, ", mem_to_string(inactive_resident_size)); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], "%s used, ", mem_to_string(total_resident_size)); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], "%s free\n", mem_to_string(free_size)); - - if (tbuf[COLS-2] != '\n') { - tbuf[COLS-1] = '\n'; - tbuf[COLS] = 0; - } - if (!oneshot) - printw(tbuf); - else - printf(tbuf); - } - } else { - int i_io, o_io, i_kbytes, o_kbytes; - - i_io = o_io = i_kbytes = o_kbytes = 0; - - if (events_delta) { - if (i_net.io_prev || o_net.io_prev) { - i_io = i_net.io - i_net.io_prev; - o_io = o_net.io - o_net.io_prev; - i_kbytes = i_net.kbytes - i_net.kbytes_prev; - o_kbytes = o_net.kbytes - o_net.kbytes_prev; - } - } else if (events_accumulate) { - if (i_net.io_prev || o_net.io_prev) { - i_net.io_accum += i_net.io - i_net.io_prev; - o_net.io_accum += o_net.io - o_net.io_prev; - i_net.kbytes_accum += i_net.kbytes - i_net.kbytes_prev; - o_net.kbytes_accum += o_net.kbytes - o_net.kbytes_prev; - - i_io = i_net.io_accum; - o_io = o_net.io_accum; - i_kbytes = i_net.kbytes_accum; - o_kbytes = o_net.kbytes_accum; - } - } else { - i_io = i_net.io; - o_io = o_net.io; - i_kbytes = i_net.kbytes; - o_kbytes = o_net.kbytes; - } - sprintf(tbuf, "Networks:%10d ipkts/%dK", i_io, i_kbytes); - clen = strlen(tbuf); - memset(&tbuf[clen], ' ', 36 - clen); - sprintf(&tbuf[36], "%10d opkts /%dK\n", o_io, o_kbytes); - - i_net.io_prev = i_net.io; - o_net.io_prev = o_net.io; - i_net.kbytes_prev = i_net.kbytes; - o_net.kbytes_prev = o_net.kbytes; - - if (tbuf[COLS-2] != '\n') { - tbuf[COLS-1] = '\n'; - tbuf[COLS] = 0; - } - if (!oneshot) - printw(tbuf); - else - printf(tbuf); - - i_io = o_io = i_kbytes = o_kbytes = 0; - - if (events_delta) { - if (i_dsk.io_prev || o_dsk.io_prev) { - i_io = i_dsk.io - i_dsk.io_prev; - o_io = o_dsk.io - o_dsk.io_prev; - i_kbytes = i_dsk.kbytes - i_dsk.kbytes_prev; - o_kbytes = o_dsk.kbytes - o_dsk.kbytes_prev; - } - } else if (events_accumulate) { - if (i_dsk.io_prev || o_dsk.io_prev) { - i_dsk.io_accum += i_dsk.io - i_dsk.io_prev; - o_dsk.io_accum += o_dsk.io - o_dsk.io_prev; - i_dsk.kbytes_accum += i_dsk.kbytes - i_dsk.kbytes_prev; - o_dsk.kbytes_accum += o_dsk.kbytes - o_dsk.kbytes_prev; - - i_io = i_dsk.io_accum; - o_io = o_dsk.io_accum; - i_kbytes = i_dsk.kbytes_accum; - o_kbytes = o_dsk.kbytes_accum; - } - } else { - i_io = i_dsk.io; - o_io = o_dsk.io; - i_kbytes = i_dsk.kbytes; - o_kbytes = o_dsk.kbytes; - } - sprintf(tbuf, "Disks: %10d reads/%dK", i_io, i_kbytes); - clen = strlen(tbuf); - memset(&tbuf[clen], ' ', 36 - clen); - sprintf(&tbuf[36], "%10d writes/%dK\n", o_io, o_kbytes); - - i_dsk.io_prev = i_dsk.io; - o_dsk.io_prev = o_dsk.io; - i_dsk.kbytes_prev = i_dsk.kbytes; - o_dsk.kbytes_prev = o_dsk.kbytes; - - if (tbuf[COLS-2] != '\n') { - tbuf[COLS-1] = '\n'; - tbuf[COLS] = 0; - } - if (!oneshot) - printw(tbuf); - else - printf(tbuf); - } - - /* display paging statistics */ - if (events_only) { - int pageins, pageouts; - - pageins = pageouts = 0; - - if (events_delta) { - if (i_vm.io_prev || o_vm.io_prev) { - pageins = vm_stat.pageins - i_vm.io_prev; - pageouts = vm_stat.pageouts - o_vm.io_prev; - } - } else if (events_accumulate) { - if (i_vm.io_prev || o_vm.io_prev) { - i_vm.io_accum += vm_stat.pageins - i_vm.io_prev; - o_vm.io_accum += vm_stat.pageouts - o_vm.io_prev; - - pageins = i_vm.io_accum; - pageouts = o_vm.io_accum; - } - } else { - pageins = vm_stat.pageins; - pageouts = vm_stat.pageouts; - } - sprintf(tbuf, "VM: %10d pageins", pageins); - clen = strlen(tbuf); - memset(&tbuf[clen], ' ', 36 - clen); - sprintf(&tbuf[36], "%10d pageouts\n", pageouts); - } else { - sprintf(tbuf, "VM: %5.5s + ", mem_to_string(total_virtual_size)); - clen = strlen(tbuf); - sprintf(&tbuf[clen], "%5.5s ", mem_to_string(total_fw_vsize)); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], "%d(%d) pageins, ", vm_stat.pageins, vm_stat.pageins - (int)i_vm.io_prev); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], "%d(%d) pageouts\n", vm_stat.pageouts, vm_stat.pageouts - (int)o_vm.io_prev); - } - if (tbuf[COLS-2] != '\n') { - tbuf[COLS-1] = '\n'; - tbuf[COLS] = 0; - } - if (!oneshot) - printw(tbuf); - else - printf(tbuf); - - i_vm.io_prev = vm_stat.pageins; - o_vm.io_prev = vm_stat.pageouts; - - - /* display the processes */ - if (topn > 0) { - if (events_delta) - sprintf(tbuf, "\n PID COMMAND %%%%CPU TIME FAULTS PGINS/COWS MSENT/MRCVD BSD/MACH CSW\n"); - else if (events_only) - sprintf(tbuf, "\n PID COMMAND %%%%CPU TIME FAULTS PAGEINS COW_FAULTS MSGS_SENT MSGS_RCVD BSDSYSCALL MACHSYSCALL CSWITCH\n"); - else if (wide_output) - sprintf(tbuf, "\n PID COMMAND %%%%CPU TIME #TH #PRTS(delta) #MREGS VPRVT RPRVT(delta) RSHRD(delta) RSIZE(delta) VSIZE(delta)\n"); - else - sprintf(tbuf, "\n PID COMMAND %%%%CPU TIME #TH #PRTS #MREGS RPRVT RSHRD RSIZE VSIZE\n"); - - - if (tbuf[COLS] != '\n') { - tbuf[COLS+1] = '\n'; - tbuf[COLS+2] = 0; - } - if (!oneshot) - printw(tbuf); - else - printf(tbuf); - - update_histdata(); - - /* sort */ - qsort((char *)pref, - active_procs, - sizeof(struct proc_info *), - proc_compar); - - /* now, show the top whatever */ - if (active_procs > topn) - { - /* adjust for too many processes */ - active_procs = topn; - } - - for (prefp = pref, i = 0; i < active_procs; prefp++, i++) - { - pp = *prefp; - - sprintf(tbuf, "%5d", pp->pid); /* pid */ - clen = strlen(tbuf); - sprintf(&tbuf[clen], " %-10.10s ", pp->command); /* command */ - clen = clen + strlen(&tbuf[clen]); - - print_usage(&tbuf[clen], pp->cpu_usage); - clen = clen + strlen(&tbuf[clen]); - - sprintf(&tbuf[clen], " "); - clen++; - - print_time(&tbuf[clen], pp->total_time); /* cputime */ - clen = clen + strlen(&tbuf[clen]); - - - if (events_only) { - if (events_delta) { - sprintf(&tbuf[clen], " %6d", pp->deltatei.faults); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], " %5d", pp->deltatei.pageins); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], "/%-4d", pp->deltatei.cow_faults); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], " %5d", pp->deltatei.messages_sent); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], "/%-4d", pp->deltatei.messages_received); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], " %5d", pp->deltatei.syscalls_unix); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], "/%-5d", pp->deltatei.syscalls_mach); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], "%6d", pp->deltatei.csw); - clen = clen + strlen(&tbuf[clen]); - } else if (events_accumulate) { - sprintf(&tbuf[clen], " %-8d", pp->deltatei.faults); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], " %-8d", pp->deltatei.pageins); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], " %-10d", pp->deltatei.cow_faults); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], " %-10d", pp->deltatei.messages_sent); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], " %-10d", pp->deltatei.messages_received); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], " %-10d", pp->deltatei.syscalls_unix); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], " %-11d", pp->deltatei.syscalls_mach); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], " %-8d", pp->deltatei.csw); - clen = clen + strlen(&tbuf[clen]); - } else { - sprintf(&tbuf[clen], " %-8d", pp->tei.faults); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], " %-8d", pp->tei.pageins); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], " %-10d", pp->tei.cow_faults); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], " %-10d", pp->tei.messages_sent); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], " %-10d", pp->tei.messages_received); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], " %-10d", pp->tei.syscalls_unix); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], " %-11d", pp->tei.syscalls_mach); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], " %-8d", pp->tei.csw); - clen = clen + strlen(&tbuf[clen]); - } - } else { - - sprintf(&tbuf[clen], " %3d", pp->num_threads); /* # of threads */ - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], " %5d", pp->num_ports); /* # of ports */ - clen = clen + strlen(&tbuf[clen]); - - if (wide_output) { - if (pp->dnum_ports) - sprintf(&tbuf[clen], "(%5d)", pp->dnum_ports); - else - sprintf(&tbuf[clen], " "); - clen = clen + strlen(&tbuf[clen]); - } - if (pp->pid || do_proc0_vm) - sprintf(&tbuf[clen], " %4d", pp->obj_count); - else - sprintf(&tbuf[clen], " -"); - clen = clen + strlen(&tbuf[clen]); - - if (wide_output) { - if (pp->pid || do_proc0_vm) { - sprintf(&tbuf[clen], " %5.5s", mem_to_string((unsigned long long)pp->vprivate)); /* res size */ - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], " %5.5s", mem_to_string((unsigned long long)pp->private)); /* res size */ - clen = clen + strlen(&tbuf[clen]); - - if (pp->drprvt) - sprintf(&tbuf[clen], "(%5.5s)", offset_to_string(pp->drprvt)); - else - sprintf(&tbuf[clen], " "); - } else - sprintf(&tbuf[clen], " - - "); - } else { - if (pp->drprvt == 0) - dp = " "; - else if ((int)pp->drprvt > 0) - dp = "+"; - else - dp = "-"; - - if (pp->pid || do_proc0_vm) - sprintf(&tbuf[clen], " %5.5s%s", mem_to_string((unsigned long long)pp->private), dp); /* res size */ - else - sprintf(&tbuf[clen], " -"); - } - clen = clen + strlen(&tbuf[clen]); - - if (wide_output) { - if (pp->pid || do_proc0_vm) { - sprintf(&tbuf[clen], " %5.5s", mem_to_string((unsigned long long)pp->shared)); - clen = clen + strlen(&tbuf[clen]); - - if (pp->drshrd) - sprintf(&tbuf[clen], "(%5.5s)", offset_to_string(pp->drshrd)); - else - sprintf(&tbuf[clen], " "); - } else - sprintf(&tbuf[clen], " - "); - } else { - if (pp->drshrd == 0) - dp = " "; - else if ((int)pp->drshrd > 0) - dp = "+"; - else - dp = "-"; - - if (pp->pid || do_proc0_vm) - sprintf(&tbuf[clen], " %5.5s%s", mem_to_string((unsigned long long)pp->shared), dp); - else - sprintf(&tbuf[clen], " - "); - } - clen = clen + strlen(&tbuf[clen]); - - if (wide_output) { - sprintf(&tbuf[clen], " %5.5s", mem_to_string((unsigned long long)pp->resident_size)); /* res size */ - clen = clen + strlen(&tbuf[clen]); - - if (pp->drsize) - sprintf(&tbuf[clen], "(%5.5s)", offset_to_string(pp->drsize)); - else - sprintf(&tbuf[clen], " "); - } else { - if (pp->drsize == 0) - dp = " "; - else if ((int)pp->drsize > 0) - dp = "+"; - else - dp = "-"; - - sprintf(&tbuf[clen], " %5.5s%s", mem_to_string((unsigned long long)pp->resident_size), dp); /* res size */ - } - clen = clen + strlen(&tbuf[clen]); - - if (wide_output) { - sprintf(&tbuf[clen], " %5.5s", mem_to_string((unsigned long long)pp->virtual_size)); /* size */ - clen = clen + strlen(&tbuf[clen]); - - if (pp->rvsize) - sprintf(&tbuf[clen], "(%5.5s)", offset_to_string(pp->rvsize)); - else - sprintf(&tbuf[clen], " "); - } else { - if (pp->dvsize == 0) - dp = " "; - else if ((int)pp->dvsize > 0) - dp = "+"; - else - dp = "-"; - - sprintf(&tbuf[clen], " %5.5s%s", mem_to_string((unsigned long long)pp->virtual_size), dp); /* size */ - } - clen = clen + strlen(&tbuf[clen]); - - } /* else not events only */ - - sprintf(&tbuf[clen], "\n"); - - if (tbuf[COLS-1] != '\n') { - tbuf[COLS] = '\n'; - tbuf[COLS+1] = 0; - } - if (!oneshot) - printw(tbuf); - else - printf(tbuf); - } - - for (n = 0, prefp = pref; n < total_procs && i < topn; prefp++, n++) - { - pp = *prefp; - - if (pp->has_idle_thread == TRUE) { - sprintf(tbuf, "%5d", pp->pid); - clen = strlen(tbuf); - sprintf(&tbuf[clen], " %-10.10s ", "idle_thread"); - clen = clen + strlen(&tbuf[clen]); - - print_usage(&tbuf[clen], pp->cpu_idle); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], " "); - clen++; - print_time(&tbuf[clen], pp->idle_time); - clen = clen + strlen(&tbuf[clen]); - sprintf(&tbuf[clen], "\n"); - - if (tbuf[COLS-1] != '\n') { - tbuf[COLS] = '\n'; - tbuf[COLS+1] = 0; - } - if (!oneshot) - printw(tbuf); - else - printf(tbuf); - i++; - } - } - } - if (oneshot) { - printf("\n"); - - if (--logcnt <= 0) - leave(); - } else - refresh(); -} - - -void -update_eventsdata() -{ - /* unimplemented */ -} - - -static struct nlist nl_net[] = { -#define N_IFNET 0 - { "_ifnet" }, - { "" }, -}; - - - -/* - * Read kernel memory, return 0 on success. - */ -int -kread(addr, buf, size) - u_long addr; - char *buf; - int size; -{ - static kvm_t *kvmd = 0; - - if (kvmd == 0) { - /* - * XXX. - */ - kvmd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, buf); - if (kvmd != NULL) { - if (kvm_nlist(kvmd, nl_net) < 0) - errx(1, "kvm_nlist: %s", kvm_geterr(kvmd)); - - if (nl_net[0].n_type == 0) - errx(1, "no namelist"); - } else { - return(-1); - } - } - if (!buf) - return (0); - if (kvm_read(kvmd, addr, buf, size) != size) { - warnx("%s", kvm_geterr(kvmd)); - return (-1); - } - return (0); -} - - -getNETWORKcounters() -{ - struct ifnet ifnet; - struct ifnethead ifnethead; - u_long off; - - if (nl_net[N_IFNET].n_value == 0) - return; - if (kread(nl_net[N_IFNET].n_value, (char *)&ifnethead, sizeof ifnethead)) - return; - - i_net.io = 0; - o_net.io = 0; - - i_net.kbytes = 0; - o_net.kbytes = 0; - - for (off = (u_long)ifnethead.tqh_first; off; ) { - char tname[16]; - - if (kread(off, (char *)&ifnet, sizeof ifnet)) - break; - if (kread((u_long)ifnet.if_name, tname, 16)) - break; - - if (strncmp(tname, "lo", 2)) { - i_net.io += ifnet.if_ipackets; - o_net.io += ifnet.if_opackets; - - i_net.kbytes += ifnet.if_ibytes/1024; - o_net.kbytes += ifnet.if_obytes/1024; - } - off = (u_long) ifnet.if_link.tqe_next; - } - return; -} - - -getDISKcounters() -{ - io_registry_entry_t drive = 0; /* needs release */ - UInt64 totalReadBytes = 0; - UInt64 totalReadCount = 0; - UInt64 totalWriteBytes = 0; - UInt64 totalWriteCount = 0; - - kern_return_t status = 0; - - while ( (drive = IOIteratorNext(drivelist)) ) - { - CFNumberRef number = 0; /* don't release */ - CFDictionaryRef properties = 0; /* needs release */ - CFDictionaryRef statistics = 0; /* don't release */ - UInt64 value = 0; - - /* Obtain the properties for this drive object */ - - status = IORegistryEntryCreateCFProperties (drive, - (CFMutableDictionaryRef *) &properties, - kCFAllocatorDefault, - kNilOptions); - if (properties) { - - /* Obtain the statistics from the drive properties */ - statistics = (CFDictionaryRef) CFDictionaryGetValue(properties, CFSTR(kIOBlockStorageDriverStatisticsKey)); - - if (statistics) { - /* Obtain the number of bytes read from the drive statistics */ - number = (CFNumberRef) CFDictionaryGetValue (statistics, - CFSTR(kIOBlockStorageDriverStatisticsBytesReadKey)); - if (number) { - status = CFNumberGetValue(number, kCFNumberSInt64Type, &value); - totalReadBytes += value; - } - /* Obtain the number of reads from the drive statistics */ - number = (CFNumberRef) CFDictionaryGetValue (statistics, - CFSTR(kIOBlockStorageDriverStatisticsReadsKey)); - if (number) { - status = CFNumberGetValue(number, kCFNumberSInt64Type, &value); - totalReadCount += value; - } - - /* Obtain the number of writes from the drive statistics */ - number = (CFNumberRef) CFDictionaryGetValue (statistics, - CFSTR(kIOBlockStorageDriverStatisticsWritesKey)); - if (number) { - status = CFNumberGetValue(number, kCFNumberSInt64Type, &value); - totalWriteCount += value; - } - /* Obtain the number of bytes written from the drive statistics */ - number = (CFNumberRef) CFDictionaryGetValue (statistics, - CFSTR(kIOBlockStorageDriverStatisticsBytesWrittenKey)); - if (number) { - status = CFNumberGetValue(number, kCFNumberSInt64Type, &value); - totalWriteBytes += value; - } - } - /* Release resources */ - - CFRelease(properties); properties = 0; - } - IOObjectRelease(drive); drive = 0; - } - IOIteratorReset(drivelist); - - i_dsk.io = (int)totalReadCount; - o_dsk.io = (int)totalWriteCount; - i_dsk.kbytes = (int)(totalReadBytes / 1024); - o_dsk.kbytes = (int)(totalWriteBytes / 1024); -} diff --git a/update.tproj/update.c b/update.tproj/update.c index 7afb397..980a7da 100644 --- a/update.tproj/update.c +++ b/update.tproj/update.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/vipw.tproj/Makefile.postamble b/vipw.tproj/Makefile.postamble index 70b747f..de7e523 100644 --- a/vipw.tproj/Makefile.postamble +++ b/vipw.tproj/Makefile.postamble @@ -107,3 +107,7 @@ # Makefile API), which are rules that get invoked before and after the install # target runs. Such rules should be specified with the '::' syntax rather than # a single colon. + +after_install:: + $(MKDIR) -p $(DSTROOT)/usr/share/man/man8 + $(CP) vipw.8 $(DSTROOT)/usr/share/man/man8/ diff --git a/vipw.tproj/pw_util.c b/vipw.tproj/pw_util.c index 1b8163d..e0514a0 100644 --- a/vipw.tproj/pw_util.c +++ b/vipw.tproj/pw_util.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/vipw.tproj/pw_util.h b/vipw.tproj/pw_util.h index bd59553..b5811b0 100644 --- a/vipw.tproj/pw_util.h +++ b/vipw.tproj/pw_util.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/vipw.tproj/vipw.8 b/vipw.tproj/vipw.8 index 18ef5ed..dd8fa37 100644 --- a/vipw.tproj/vipw.8 +++ b/vipw.tproj/vipw.8 @@ -84,7 +84,6 @@ will be invoked instead of the default editor .Xr chpass 1 , .Xr passwd 1 , .Xr passwd 5 , -.Xr adduser 8 , .Xr pwd_mkdb 8 .Sh HISTORY The diff --git a/vipw.tproj/vipw.c b/vipw.tproj/vipw.c index 9301626..d15932b 100644 --- a/vipw.tproj/vipw.c +++ b/vipw.tproj/vipw.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/vm_stat.tproj/vm_stat.1 b/vm_stat.tproj/vm_stat.1 index 4ce6212..0a8ebeb 100644 --- a/vm_stat.tproj/vm_stat.1 +++ b/vm_stat.tproj/vm_stat.1 @@ -47,6 +47,7 @@ to the active list (reactivated). the number of requests for pages from a pager (such as the inode pager). .It Pageouts the number of pages that have been paged out. +.El .Pp If .Ar interval @@ -54,7 +55,3 @@ is not specified, then .Nm vm_stat displays all accumulated statistics along with the page size and the object cache performance. - - -.Sh SEE ALSO -.Xr vm_statistics 2 diff --git a/vm_stat.tproj/vm_stat.c b/vm_stat.tproj/vm_stat.c index 611924c..6bad7ca 100644 --- a/vm_stat.tproj/vm_stat.c +++ b/vm_stat.tproj/vm_stat.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/zdump.tproj/zdump.c b/zdump.tproj/zdump.c index 5c8cd68..ce849c4 100644 --- a/zdump.tproj/zdump.c +++ b/zdump.tproj/zdump.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/zic.tproj/ialloc.c b/zic.tproj/ialloc.c index f82638f..490d2fa 100644 --- a/zic.tproj/ialloc.c +++ b/zic.tproj/ialloc.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/zic.tproj/private.h b/zic.tproj/private.h index 51f379d..db7990d 100644 --- a/zic.tproj/private.h +++ b/zic.tproj/private.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/zic.tproj/scheck.c b/zic.tproj/scheck.c index bfb5ab2..8407656 100644 --- a/zic.tproj/scheck.c +++ b/zic.tproj/scheck.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/zic.tproj/tzfile.h b/zic.tproj/tzfile.h index 1702d15..25220c6 100644 --- a/zic.tproj/tzfile.h +++ b/zic.tproj/tzfile.h @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/zic.tproj/zic.c b/zic.tproj/zic.c index 5bf725b..a381bd4 100644 --- a/zic.tproj/zic.c +++ b/zic.tproj/zic.c @@ -3,22 +3,21 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 1.0 (the 'License'). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License." * * @APPLE_LICENSE_HEADER_END@ */ -- 2.45.2