Embedded Freebsd Cookbook.Pdf
Total Page:16
File Type:pdf, Size:1020Kb
Embedded FreeBSD Cookbook A Volume in the Embedded Technology™ Series Embedded FreeBSD Cookbook by Paul Cevoli An imprint of Elsevier Science Amsterdam Boston London New York Oxford Paris San Diego San Francisco Singapore Sydney Tokyo iv Newnes is an imprint of Elsevier Science. Copyright © 2002, Elsevier Science (USA). All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. Recognizing the importance of preserving what has been written, Elsevier Science prints its books on acid-free paper whenever possible. Library of Congress Cataloging-in-Publication Data ISBN: 1-5899-5004-6 British Library Cataloguing-in-Publication Data A catalogue record for this book is available from the British Library. The publisher offers special discounts on bulk orders for this book. For information, please contact: Manager of Special Sales Elsevier Science 200 Wheeler Road Burlington, MA 01803 For information on all Newnes publications available, contact our World Wide Web home page at http://www.newnespress.com 10 9 8 7 6 5 4 3 2 1 Printed in the United States of America Preface .................................................................................. vii Prerequisites and Other Resources .................................................... vii 1 Getting Started .................................................................. 1 Overview ............................................................................................. 1 Embedded Systems ............................................................................ 1 Internet Appliances ............................................................................. 2 Compatibility of upgrades ........................................................................ 3 Time to market ......................................................................................... 4 Labor pool ................................................................................................ 4 Licensing.................................................................................................. 4 The DIO Server Appliance .................................................................. 4 FreeBSD .................................................................................................. 5 GNU Development Tools ......................................................................... 6 Java ......................................................................................................... 7 Server ...................................................................................................... 7 Data Acquisition ....................................................................................... 7 Boot Device.............................................................................................. 7 Summary............................................................................................. 8 2 Systems Programming ..................................................... 9 Overview ............................................................................................. 9 Process ............................................................................................... 9 The ........................................................................................................... 10 System Call.............................................................................................. 10 The ........................................................................................................... 11 System Call.............................................................................................. 11 The ........................................................................................................... 12 System Call.............................................................................................. 12 The ........................................................................................................... 12 System Call.............................................................................................. 12 An Example.............................................................................................. 12 Process IDs.............................................................................................. 13 Security .................................................................................................... 14 An Example.............................................................................................. 15 The ........................................................................................................... 16 and ........................................................................................................... 16 System Calls ............................................................................................ 16 File Descriptors ........................................................................................ 17 Permissions ............................................................................................. 17 Current Working Directory ....................................................................... 17 The ........................................................................................................... 18 and ........................................................................................................... 18 System Calls ............................................................................................ 18 The ........................................................................................................... 18 System Call.............................................................................................. 18 Priority...................................................................................................... 19 State......................................................................................................... 20 The ........................................................................................................... 20 Function ................................................................................................... 20 The ........................................................................................................... 21 System Call.............................................................................................. 21 Daemons............................................................................................. 21 Fork.......................................................................................................... 21 Create a new session .............................................................................. 22 Close file descriptors................................................................................ 22 Change the current working directory ...................................................... 22 Set the file mode creation mask............................................................... 22 Handle Child Exit Status .......................................................................... 22 The ........................................................................................................... 22 Function ................................................................................................... 22 The ........................................................................................................... 23 Function ................................................................................................... 23 Summary............................................................................................. 25 3 System Calls ...................................................................... 27 Overview ............................................................................................. 27 Library Functions and System Calls.................................................... 27 Software Interrupt .................................................................................... 29 Passing Data............................................................................................ 29 An Example.............................................................................................. 30 Creating a System Call ....................................................................... 32 Load Handler ........................................................................................... 32 System Call Arguments ........................................................................... 34 The ........................................................................................................... 34 System Call.............................................................................................. 34 The ........................................................................................................... 36 Structure .................................................................................................. 36 The System Call Number ......................................................................... 36 The SYSCALL_MODULE Macro ............................................................. 38 Command Definitions............................................................................... 39 Command Table .....................................................................................