Character Device Drivers
|
|
- Reynard Little
- 6 years ago
- Views:
Transcription
1 Character Device Drivers 張大緯 CSIE, NCKU The information on the slides are from Linux Device Drivers, Third Edition, by Jonathan Corbet, Alessandro Rubini, and Greg Kroah-Hartman. Copyright 2005 O Reilly Media, Inc.,
2 The Scull Char Driver We present code fragments of a char device driver: scull acts on a memory area, not traditional IO devices Hardware independent Portable Can be a template But, only shows the kernel interface The device interface is not shown 2
3 The Scull Char Driver Four devices implemented by scull scull0 to 3 Each device Contains a global and persistent memory area Global Data of an area can be shared by multiple users Persistent Data remains even when the device is closed 3
4 Major and Minor Numbers Char devices are accessed through device files in the filesystem Device files, Special files, or Nodes Located in the /dev directory Char devices Major Minor Device name 4
5 Major and Minor Numbers Why we need major & minor numbers? For identifying a device Major: the device type Minor: the device number in that type Traditionally, each major number is managed by a driver kernel seldom handles minor numbers But Linux allows multiple drivers share the same major number 5
6 Internal Representation of Device Numbers dev_t is used to hold a device number Major (12bits), minor (20bits) for kernel The real representation can be changed.so, Use the following macros MAJOR(dev_t dev); MINOR(dev_t dev); MKDEV(int major, int minor); 6
7 Allocating and Freeing Device Numbers Allocating a range of device numbers to manage If you know the major number register_chrdev_region Traditionally, major numbers are statically assigned You can pick an unused number in Documentation/devices.txt Major number conflict may happen when you deploy your driver If you want the kernel to give you a major number dynamically alloc_chrdev_region 7
8 Allocating and Freeing Device Numbers int register_chrdev_region(dev_t first, unsigned int count, char *name); first: the first dev_t include (major, first minor) count: total number of contiguous device numbers you are requesting name: the name of the device 8
9 Allocating and Freeing Device Numbers int alloc_chrdev_region(dev_t *dev, unsigned int firstminor, unsigned int count, char *name); dev: output parameter The dev_t indicating the (major, first minor) is setup when the function successfully returns Check /proc/devices or sysfs after the invocation of the above two functions 9
10 An Example of /proc/devices Character devices: 1 mem 2 pty 3 ttyp 4 ttys 6 lp 7 vcs 10 misc 13 input 14 sound 21 sg 180 usb Block devices: 2 fd 8 sd 11 sr 65 sd 66 sd 10
11 Allocating and Freeing Device Numbers Free the device numbers void unregister_chrdev_region(dev_t first, unsigned int count); 11
12 Dynamic Allocation of Major Numbers More flexible, no conflict However, the device files can not be created in advance Create the device files after insmod Creating ${device}0-3 after you got the $major Recent Linux version supports udev, which allows automatic creation of these device files! 12
13 Where Are We? Now, the driver have some device numbers And, we have device files mknod Users can access these files But, how these accesses finally go to the driver? 13
14 Some Important Data Structures file_operations file inode 14
15 File Operations Let the accesses go to the driver Why?.. because device FILE A collection of function pointers read, write, Each driver should implement this set of functions (some of them may be NULL) Each open file is associated with its own set of functions File: object, file operation: method 15
16 File Operations: An Example ssize_t (*read) (struct file *, char user *, size_t, loff_t *); corresponds to the read() system call user user-space address cannot be directly dereferenced 16
17 File Operations of the scull Driver struct file_operations scull_fops = { };.owner = THIS_MODULE,.llseek = scull_llseek,.read = scull_read,.write = scull_write,.ioctl = scull_ioctl,.open = scull_open,.release = scull_release, The syntax is more portable across changes in the definitions of the structures Others functions are not implemented by the scull driver Handled by the kernel default handler 17
18 The file Structure Represents an open instance of a file not specific to device drivers created by the kernel on open released when the user closes the file Important fields mode_t f_mode read/write permission 18
19 The file Structure Important fields loff_t f_pos current reading or writing position unsigned int f_flags E.g., O_RDONLY, O_NONBLOCK, O_SYNC A driver should check the O_NONBLOCK flag to see if nonblocking operation has been requested 19
20 The file Structure Important fields struct file_operations *f_op operations associated with the file assign the operations during open you can change the file operations E.g., you can assign a different set of file operations for each minor number during the open method void *private_data For your private use Usually be used to preserve state information across system calls 20
21 The file Structure Important fields struct dentry *f_dentry The directory entry (dentry) structure A directory is a file that records a set of directory entries Usually be used to access inode filp->f_dentry->d_inode // filp is a ptr to struct file Dentry format: Examples: i_no some fields (name_len, ) file/sudir name 100 some fields (5, ) file some fields (7, ) subdir1 80 some fields (7, ) firefox 21
22 The inode Structure Each file has an inode Record file information/attributes/metadata Locations of data blocks, timing information, size. If a file is opened by two users Two file structures and one inode structure How to find the file /usr/local/bin/foo? Starts from the inode of the root dir (/) Important fields dev_t i_rdev the actual device number ( for a device file ) struct cdev *i_cdev pointer to the cdev, which represents a char device 22
23 Char Device Registration Allocating & Initializing cdev Method 1 struct cdev *my_cdev = cdev_alloc( ); my_cdev->ops = &my_fops; Method 2 void cdev_init(struct cdev *cdev, struct file_operations *fops); In either way, my_cdev->owner = THIS_MODULE; 23
24 Char Device Registration Registering to the kernel int cdev_add(struct cdev *dev, dev_t num, unsigned int count); num : first device number count: number of device numbers for the device Usually, 1 The registration may fail should check it Once the registration succeeds, kernel will call your operations prepare for that Remove a char device void cdev_del(struct cdev *dev); 24
25 Device Registration in scull scull represents each device with a structure of type struct scull_dev struct scull_dev { struct scull_qset *data; /* Pointer to first quantum set */ int quantum; /* the current quantum size */ int qset; /* the current array size */ unsigned long size; /* amount of data stored here */ unsigned int access_key; /* used by sculluid and scullpriv */ struct semaphore sem; /* mutual exclusion semaphore */ struct cdev cdev; /* Char device structure */ }; Check slide
26 Device Registration in scull static void scull_setup_cdev(struct scull_dev *dev, int index) { int err, devno = MKDEV(scull_major, scull_minor + index); cdev_init(&dev->cdev, &scull_fops); //init the cdev dev->cdev.owner = THIS_MODULE; dev->cdev.ops = &scull_fops; err = cdev_add (&dev->cdev, devno, 1); // register to kernel /* Fail gracefully if need be */ if (err) printk(kern_notice "Error %d adding scull%d", err, index); } The caller : for (i = 0; i < scull_nr_devs; i++) {.. scull_setup_cdev(&scull_devices[i], i); } 26
27 The Older Way Registration int register_chrdev(unsigned int major, const char *name, struct file_operations *fops); registers minor numbers for the given major number sets up a default cdev structure for each minor number Unregistration int unregister_chrdev(unsigned int major, const char *name); 27
28 Open Method Initialization and preparation for later operations Usually perform the following jobs Check for device-specific errors Initialize the device Update the f_op pointer, if necessary Allocate and fill any data structure to be put in filp->private_data 28
29 Open Method Which scull device is being opened? int (*open)(struct inode *inode, struct file *filp); Get the cdev inode->i_cdev Get the scull_dev dev = container_of( inode->i_cdev, struct scull_dev, cdev); Set the private area to point to the scull dev filp->private_data = dev; 29
30 scull_open() Introduced later 30
31 The release Method Usually perform the following tasks Deallocate anything that open allocated in filp-> private_data Shut down the device on last close int scull_release(struct inode *inode, struct file *filp) { return 0; } Scull has no hardware to shut down 31
32 Memory Usage of the scull Driver In scull, the device is memory Variable sized Dynamically expanded Use kmalloc() and kfree() void *kmalloc(size_t size, int flags); Flags = = GFP_KERNEL void kfree(void *ptr); 32
33 Memory Usage of the scull Driver Each device is a linked list of pointers Each pointer points to a scull_qset structure scull_dev.qset 33 scull_dev.quantum
34 Scull_trim() int scull_trim(struct scull_dev *dev) { struct scull_qset *next, *dptr; int qset = dev->qset; /* "dev" is not-null */ int i; for (dptr = dev->data; dptr; dptr = next) { /* all the list items */ if (dptr->data) { for (i = 0; i < qset; i++) kfree(dptr->data[i]); // free the quanta in a qset kfree(dptr->data); // free qset s data } dptr->data = NULL; } next = dptr->next; kfree(dptr); } dev->size = 0; dev->quantum = scull_quantum; dev->qset = scull_qset; dev->data = NULL; return 0; // free the qset data structure 34
35 The read and write Methods ssize_t read(struct file *filp, char user *buff, size_t count, loff_t *offp); ssize_t write(struct file *filp, const char user *buff, size_t count, loff_t *offp); The buff argument is user-space pointer May not be directly accessible by kernel May be paged out Oops on directly access May be a wrong/invalid pointer Kernel does not trust the users 35
36 Accessing User Space Data Transferring data with user space unsigned long copy_to_user(void user *to, const void *from, unsigned long count); unsigned long copy_from_user(void *to, const void user *from, unsigned long count); The above functions check whether the user space pointer is valid Returns number of bytes that could NOT be copied perform data transfer may sleep For paging in user pages 36
37 Accessing User Space Data If you are sure the user addresses are fine Use copy_to_user()/ copy_from_user() No checks, faster Be careful Kernel crashes Security holes 37
38 Coming Back to The read and write Methods 38
39 The Read Method The return value R of read R = count ( > 0 ) The specified amount of data is read 0 < R < count Partial of the specified amount of data is read R = 0 EOF R < 0 Error 39
40 Scull_read() // EOF, return 0 40
41 Scull_read() // f_pos should reflect the current RW head 41
42 Scull_write() ssize_t scull_write (struct file *filp, const char user *buf, size_t count, loff_t *f_pos) { struct scull_dev *dev = filp->private_data; struct scull_qset *dptr; int quantum = dev->quantum, qset = dev->qset; int itemsize = quantum * qset; int item, s_pos, q_pos, rest; ssize_t retval = -ENOMEM; /* value used in "goto out" statements */ find listitem, qset index and offset in the quantum skipped dptr = scull_follow(dev, item); if (dptr = = NULL) goto out; if (!dptr->data) { dptr->data = kmalloc (qset * sizeof(char *), GFP_KERNEL); if (!dptr->data) goto out; // no free memory!!! memset (dptr->data, 0, qset * sizeof(char *)); } 42
43 Scull_write() if (!dptr->data[s_pos]) { dptr->data[s_pos] = kmalloc (quantum, GFP_KERNEL); //allocate the quantum if (!dptr->data[s_pos]) goto out; } /* write only up to the end of this quantum */ if (count > quantum - q_pos) count = quantum - q_pos; if (copy_from_user (dptr->data[s_pos]+q_pos, buf, count)) { retval = -EFAULT; goto out; } *f_pos += count; retval = count; // f_pos should reflect the current RW head } /* update the size */ if (dev->size < *f_pos) out: up(&dev->sem); return retval; dev->size = *f_pos; 43
44 Scatter-Gather Read/Write Read/write data from/to multiple buffers in a single operation readv and writev iovec structure Used to specify the address range of a buffer An array of iovec structures is passed to readv() or writev() A driver can implement readv() and writev() methods if it benefits from scatter-gather IO aio_read()/aio_write() in newer kernel versions 44
Introduction Reading Writing scull. Linux Device Drivers - char driver
Overview 1 2 3 4 Major, minor File Operations The file Structure The inode structure Registraction simplest driver, suitable for most simple devices, follow the book. Jernej Figure: Vičič. (Simple Character
More informationThe device driver (DD) implements these user functions, which translate system calls into device-specific operations that act on real hardware
Introduction (Linux Device Drivers, 3rd Edition (www.makelinux.net/ldd3)) Device Drivers -> DD They are a well defined programming interface between the applications and the actual hardware They hide completely
More informationLinux Device Drivers
Linux Device Drivers Modules A piece of code that can be added to the kernel at runtime is called a module A device driver is one kind of module Each module is made up of object code that can be dynamically
More informationDesigning and developing device drivers. Coding drivers
Designing and developing device drivers Coding drivers Registering a driver 2 calls to register a driver defined in int register_chrdev_region(dev_t first, unsigned int count, char *name);
More informationLinux Device Drivers. 3. Char Drivers cont. 3. Char Drivers. 1. Introduction 2. Kernel Modules 3. Char Drivers 4. Advanced Char Drivers 5.
Linux Device Drivers Dr. Wolfgang Koch Friedrich Schiller University Jena Department of Mathematics and Computer Science Jena, Germany wolfgang.koch@uni-jena.de Linux Device Drivers 1. Introduction 2.
More informationREVISION HISTORY NUMBER DATE DESCRIPTION NAME
i ii REVISION HISTORY NUMBER DATE DESCRIPTION NAME iii Contents 1 The structure of a Linux kernel module 1 1.1 Install XV6...................................................... 1 1.2 Compile and load a
More informationLinux Device Drivers. 3. Char Drivers. 1. Introduction 2. Kernel Modules 3. Char Drivers 4. Advanced Char Drivers 5. Interrupts
Linux Device Drivers Dr. Wolfgang Koch Friedrich Schiller University Jena Department of Mathematics and Computer Science Jena, Germany wolfgang.koch@uni-jena.de Linux Device Drivers 1. Introduction 2.
More informationConcurrency and Race Conditions (Linux Device Drivers, 3rd Edition (www.makelinux.net/ldd3))
(Linux Device Drivers, 3rd Edition (www.makelinux.net/ldd3)) Concurrency refers to the situation when the system tries to do more than one thing at once Concurrency-related bugs are some of the easiest
More informationMP3: VIRTUAL MEMORY PAGE FAULT MEASUREMENT
MP3: VIRTUAL MEMORY PAGE FAULT MEASUREMENT University of Illinois at Urbana-Champaign Department of Computer Science CS423 Fall 2011 Keun Soo Yim GOAL A Linux kernel module to profile VM system events
More informationCharacter Device Drivers One Module - Multiple Devices
Review from previous classes Three Types: Block, Character, and Network Interface Device Drivers MAJOR & MINOR numbers assigned register_chrdev_region(), alloc_chrdev_region(), unregister_chrdev_region()
More informationUnix (Linux) Device Drivers
Unix (Linux) Device Drivers Kernel module that handles the interaction with an specific hardware device, hiding its operational details behind a common interface Three basic categories Character Block
More informationDevice Drivers Demystified ESC 117. Doug Abbott, Principal Consultant Intellimetrix. Why device drivers? What s a device driver?
ESC 117, Principal Consultant Intellimetrix Outline Introduction Why device drivers? What s a device driver? Abstract model of device driver OS agnostic What makes drivers seem complicated? Independently
More informationIntroduction to Device Drivers Part-1
Introduction to Device Drivers Part-1 Introduction to Device Drivers-1 Objectives GNU/Linux Learn how to access the hardware similar to the sysfs method but faster Understand the basic techniques of how
More informationWhat is a Linux Device Driver? Kevin Dankwardt, Ph.D. VP Technology Open Source Careers
What is a Linux Device Driver? Kevin Dankwardt, Ph.D. VP Technology Open Source Careers kdankwardt@oscareers.com What does a driver do? Provides a more convenient interface to user-space for the hardware.
More informationLinux drivers - Exercise
Embedded Realtime Software Linux drivers - Exercise Scope Keywords Prerequisites Contact Learn how to implement a device driver for the Linux OS. Linux, driver Linux basic knowledges Roberto Bucher, roberto.bucher@supsi.ch
More informationKernel Modules. Kartik Gopalan
Kernel Modules Kartik Gopalan Kernel Modules Allow code to be added to the kernel, dynamically Only those modules that are needed are loaded. Unload when no longer required - frees up memory and other
More informationIntroduction to Operating Systems. Device Drivers. John Franco. Dept. of Electrical Engineering and Computing Systems University of Cincinnati
Introduction to Operating Systems Device Drivers John Franco Dept. of Electrical Engineering and Computing Systems University of Cincinnati Basic Computer Architecture CPU Main Memory System Bus Channel
More informationCS 378 (Spring 2003)
Department of Computer Sciences THE UNIVERSITY OF TEXAS AT AUSTIN CS 378 (Spring 2003) Linux Kernel Programming Yongguang Zhang (ygz@cs.utexas.edu) Copyright 2003, Yongguang Zhang This Lecture Device Driver
More informationCS5460/6460: Operating Systems. Lecture 24: Device drivers. Anton Burtsev April, 2014
CS5460/6460: Operating Systems Lecture 24: Device drivers Anton Burtsev April, 2014 Device drivers Conceptually Implement interface to hardware Expose some high-level interface to the kernel or applications
More informationLoadable Kernel Module
Instituto Superior de Engenharia do Porto Mestrado em Engenharia Eletrotécnica e de Computadores Arquitetura de Computadores Loadable Kernel Module The objective of this lesson is to analyze, compile and
More informationBLOCK DEVICES. Philipp Dollst
BLOCK DEVICES Philipp Dollst BASICS A block driver provides access to devices that transfer randomly accessible data in fixed-size blocks disk drives, primarily. The Linux kernel sees block devices a being
More informationVirtual File System (VFS) Implementation in Linux. Tushar B. Kute,
Virtual File System (VFS) Implementation in Linux Tushar B. Kute, http://tusharkute.com Virtual File System The Linux kernel implements the concept of Virtual File System (VFS, originally Virtual Filesystem
More informationWorkspace for '5-linux' Page 1 (row 1, column 1)
Workspace for '5-linux' Page 1 (row 1, column 1) Workspace for '5-linux' Page 2 (row 2, column 1) ECEN 449 Microprocessor System Design Introduction to Linux 1 Objectives of this Lecture Unit Learn basics
More informationFinish up OS topics Group plans
Finish up OS topics Group plans Today Finish up and review Linux device driver stuff Walk example again See how it all goes together Discuss talking to MMIO RTOS (on board) Deferred interrupts Discussion
More informationUSB. Development of a USB device driver working on Linux and Control Interface. Takeshi Fukutani, Shoji Kodani and Tomokazu Takahashi
Linux USB Development of a USB device driver working on Linux and Control Interface Takeshi Fukutani, Shoji Kodani and Tomokazu Takahashi Recently, it s becoming more popular to utilize Linux for controlling
More informationAndroid 多核心嵌入式多媒體系統設計與實作
Android 多核心嵌入式多媒體系統設計與實作 Linux Device Driver 架構簡介 賴槿峰 (Chin-Feng Lai) Assistant Professor, institute of CSIE, National Ilan University Sep 29 th 2011 2011 MMN Lab. All Rights Reserved 2011 1 資訊軟體技術人才培訓
More informationSimple char driver. for Linux. my_first.c: headers. my_first.c: file structure. Calcolatori Elettronici e Sistemi Operativi.
Calcolatori Elettronici e Sistemi Operativi Simple char driver Simple char driver for Linux Code organization my_first.c driver code: Headers Macro definitions Device structure definition Globals and module
More informationDriving Me Nuts Device Classes
Driving Me Nuts Device Classes More necessary insructions for making your new device driver play nice in the 2.6 kernel. by Greg Kroah-Hartman In the last Driving Me Nuts column [see LJ, June 2003], we
More informationCS 453: Operating Systems Programming Project 5 (100 points) Linux Device Driver
CS 453: Operating Systems Programming Project 5 (100 points) Linux Device Driver 1 Setup In this assignment, we will write a simple character driver called booga. Please do a git pull --rebase in your
More informationInterrupt handling. Interrupt handling. Deferred work. Interrupt handling. Remove an interrupt handler. 1. Link a struct work to a function
Interrupt handling Interrupt handling error = request_irq(irq_number, interrupt_service_routine, flags, module_name, (void*)dataptr); error: == 0 OK!= 0 FAILED interrupt_service_routine: irqreturn_t interrupt_service_routine(int
More information3 Character Drivers. 3.1 The Design of scullc. Linux Device Drivers in Assembly
3 Character Drivers In this chapter we will develop a simple character driver named SCULL for Simple Character Utility for Loading Localities; again, don t blame me for the name). As in the previous chapter,
More informationFiles and Directories Filesystems from a user s perspective
Files and Directories Filesystems from a user s perspective Unix Filesystems Seminar Alexander Holupirek Database and Information Systems Group Department of Computer & Information Science University of
More informationDriving Me Nuts Writing a Simple USB Driver
Driving Me Nuts Writing a Simple USB Driver Give your Linux box a multicolored light you can see from across the room, and learn how to write a simple driver for the next piece of hardware you want to
More informationCSE 333 SECTION 3. POSIX I/O Functions
CSE 333 SECTION 3 POSIX I/O Functions Administrivia Questions (?) HW1 Due Tonight Exercise 7 due Monday (out later today) POSIX Portable Operating System Interface Family of standards specified by the
More informationDevice Drivers. CS449 Fall 2017
Device Drivers CS449 Fall 2017 Software Layers User-level I/O so7ware & libraries Device-independent OS so7ware Device drivers Interrupt handlers User OperaEng system (kernel) Hardware Device Drivers User
More information7.4 Simple example of Linux drivers
407 7.4 Simple example of Linux drivers In the previous section, we introduce a simple Hello module driver, it is just some information from the serial port output, the board did not correspond to the
More informationOperating System Concepts Ch. 11: File System Implementation
Operating System Concepts Ch. 11: File System Implementation Silberschatz, Galvin & Gagne Introduction When thinking about file system implementation in Operating Systems, it is important to realize the
More informationStep Motor. Step Motor Device Driver. Step Motor. Step Motor (2) Step Motor. Step Motor. source. open loop,
Step Motor Device Driver Step Motor Step Motor Step Motor source Embedded System Lab. II Embedded System Lab. II 2 Step Motor (2) open loop, : : Pulse, Pulse,, -, +5%, step,, Step Motor Step Motor ( ),
More informationRCU. ò Walk through two system calls in some detail. ò Open and read. ò Too much code to cover all FS system calls. ò 3 Cases for a dentry:
Logical Diagram VFS, Continued Don Porter CSE 506 Binary Formats RCU Memory Management File System Memory Allocators System Calls Device Drivers Networking Threads User Today s Lecture Kernel Sync CPU
More informationwe are here I/O & Storage Layers Recall: C Low level I/O Recall: C Low Level Operations CS162 Operating Systems and Systems Programming Lecture 18
I/O & Storage Layers CS162 Operating Systems and Systems Programming Lecture 18 Systems April 2 nd, 2018 Profs. Anthony D. Joseph & Jonathan Ragan-Kelley http://cs162.eecs.berkeley.edu Application / Service
More informationVFS, Continued. Don Porter CSE 506
VFS, Continued Don Porter CSE 506 Logical Diagram Binary Formats Memory Allocators System Calls Threads User Today s Lecture Kernel RCU File System Networking Sync Memory Management Device Drivers CPU
More informationNPTEL Course Jan K. Gopinath Indian Institute of Science
Storage Systems NPTEL Course Jan 2012 (Lecture 17) K. Gopinath Indian Institute of Science Accessing Devices/Device Driver Many ways to access devices under linux Non-block based devices ( char ) - stream
More informationThe bigger picture. File systems. User space operations. What s a file. A file system is the user space implementation of persistent storage.
The bigger picture File systems Johan Montelius KTH 2017 A file system is the user space implementation of persistent storage. a file is persistent i.e. it survives the termination of a process a file
More informationIntroduction to Linux Device Drivers Recreating Life One Driver At a Time
Introduction to Linux Device Drivers Recreating Life One Driver At a Time Muli Ben-Yehuda mulix@mulix.org IBM Haifa Research Labs, Haifa Linux Club Linux Device Drivers, Technion, Jan 2004 p.1/42 why write
More informationLinux Device Drivers - debugging
March 15, 2018 Overview Introduction 1 Introduction 2 3 4 Using /proc file system Method ioctl 5 6 7 8 gdb kdb Kernel Debugger kgdb kgdb Patches User-Mode Linux Port Introduction kernel code cannot be
More informationwe are here Page 1 Recall: How do we Hide I/O Latency? I/O & Storage Layers Recall: C Low level I/O
CS162 Operating Systems and Systems Programming Lecture 18 Systems October 30 th, 2017 Prof. Anthony D. Joseph http://cs162.eecs.berkeley.edu Recall: How do we Hide I/O Latency? Blocking Interface: Wait
More informationLinux Kernel Modules & Device Drivers April 9, 2012
Linux Kernel Modules & Device Drivers April 9, 2012 Pacific University 1 Resources Linux Device Drivers,3rd Edition, Corbet, Rubini, Kroah- Hartman; O'Reilly kernel 2.6.10 we will use 3.1.9 The current
More informationFall 2017 :: CSE 306. File Systems Basics. Nima Honarmand
File Systems Basics Nima Honarmand File and inode File: user-level abstraction of storage (and other) devices Sequence of bytes inode: internal OS data structure representing a file inode stands for index
More informationIntroduction USB Pisanje gonilnika USB. USB drivers
drivers drivers Overview 1 2 Urbs 3 drivers universal serial bus (), connection between the computer and peripherals, primarily intended for slow connections: parallel port, serial port, keyboard,... new
More informationInterprocess Communication. Originally multiple approaches Today more standard some differences between distributions still exist
Interprocess Communication Originally multiple approaches Today more standard some differences between distributions still exist Pipes Oldest form of IPC provided by all distros Limitations Historically
More informationOperating systems. Lecture 7
Operating systems. Lecture 7 Michał Goliński 2018-11-13 Introduction Recall Plan for today History of C/C++ Compiler on the command line Automating builds with make CPU protection rings system calls pointers
More informationCSE 333 SECTION 3. POSIX I/O Functions
CSE 333 SECTION 3 POSIX I/O Functions Administrivia Questions (?) HW1 Due Tonight HW2 Due Thursday, July 19 th Midterm on Monday, July 23 th 10:50-11:50 in TBD (And regular exercises in between) POSIX
More informationCS240: Programming in C
CS240: Programming in C Lecture 15: Unix interface: low-level interface Cristina Nita-Rotaru Lecture 15/Fall 2013 1 Streams Recap Higher-level interface, layered on top of the primitive file descriptor
More informationAutoISES: Automatically Inferring Security Specifications and Detecting Violations
: Automatically Inferring Security Specifications and Detecting Violations (U. of Illinois at Urbana-Champaign) Xiaolan (Catherine) Zhang (IBM Research) Xiao Ma, Weiwei Xiong, Yuanyuan Zhou (U. of Illinois
More information- It must provide a stable programming interfaces that applications can be built upon.
System Utilities sysfs Library - libsysfs ========================================= Version: 1.2.0 September 13, 2004 Contents -------- 1. Introduction 2. Requirements 3. Definitions 4. Overview 5. Data
More informationCS 423 Operating System Design: Introduction to Linux Kernel Programming (MP1 Q&A)
CS 423 Operating System Design: Introduction to Linux Kernel Programming (MP1 Q&A) Professor Adam Bates Fall 2018 Learning Objectives: Talk about the relevant skills required in MP1 Announcements: MP1
More informationLinux Device Drivers IOCTL. March 15, 2018
March 15, 2018 Overview Introduction ioctl system call. ioctl short for: Input Output ConTroL, shared interface for devices, Description of ioctl devices are presented with files, input and output devices,
More informationOperating systems for embedded systems
Operating systems for embedded systems Embedded operating systems How do they differ from desktop operating systems? Programming model Process-based Event-based How is concurrency handled? How are resource
More informationLinux Device Drivers Interrupt Requests
Overview 1 2 3 Installation of an interrupt handler Interface /proc 4 5 6 7 primitive devices can be managed only with I/O regions, most devices require a more complicated approach, devices cooperate with
More informationCMPS 105 Systems Programming. Prof. Darrell Long E2.371
+ CMPS 105 Systems Programming Prof. Darrell Long E2.371 darrell@ucsc.edu + Chapter 3: File I/O 2 + File I/O 3 n What attributes do files need? n Data storage n Byte stream n Named n Non-volatile n Shared
More informationtoorcon 2004 Hooking the Linux ELF Loader Richard Johnson
toorcon 2004 Hooking the Linux ELF Loader Richard Johnson rjohnson@idefense.com About Who am I? Currently employed by idefense Labs 5 years professional security experience Development Projects nologin.org
More informationFile Descriptors and Piping
File Descriptors and Piping CSC209: Software Tools and Systems Programming Furkan Alaca & Paul Vrbik University of Toronto Mississauga https://mcs.utm.utoronto.ca/~209/ Week 8 Today s topics File Descriptors
More informationFile Systems. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University
File Systems Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu SSE3044: Operating Systems, Fall 2016, Jinkyu Jeong (jinkyu@skku.edu) File System Layers
More informationRights to copy. Dongkun Shin, SKKU
Rights to copy Copyright 2004-2019, Bootlin License: Creative Commons Attribution - Share Alike 3.0 https://creativecommons.org/licenses/by-sa/3.0/legalcode You are free: to copy, distribute, display,
More informationSection 3: File I/O, JSON, Generics. Meghan Cowan
Section 3: File I/O, JSON, Generics Meghan Cowan POSIX Family of standards specified by the IEEE Maintains compatibility across variants of Unix-like OS Defines API and standards for basic I/O: file, terminal
More informationSystems Programming. 09. Filesystem in USErspace (FUSE) Alexander Holupirek
Systems Programming 09. Filesystem in USErspace (FUSE) Alexander Holupirek Database and Information Systems Group Department of Computer & Information Science University of Konstanz Summer Term 2008 Schedule
More informationProcesses often need to communicate. CSCB09: Software Tools and Systems Programming. Solution: Pipes. Recall: I/O mechanisms in C
2017-03-06 Processes often need to communicate CSCB09: Software Tools and Systems Programming E.g. consider a shell pipeline: ps wc l ps needs to send its output to wc E.g. the different worker processes
More informationFinal Step #7. Memory mapping For Sunday 15/05 23h59
Final Step #7 Memory mapping For Sunday 15/05 23h59 Remove the packet content print in the rx_handler rx_handler shall not print the first X bytes of the packet anymore nor any per-packet message This
More informationLinux Kernel Development (LKD)
Linux Kernel Development (LKD) Session 1 Loadable Kernel Modules (LKM) Paulo Baltarejo Sousa pbs@isep.ipp.pt 2017 PBS LKD: S1 1 / 66 Disclaimer Material and Slides Some of the material/slides are adapted
More informationRF-IDs in the Kernel -- Episode III: I want to File Away
What s on the menu Software Comprehension and Maintenance June 2005 RF-IDs in the Kernel -- Episode III: I want to File Away Achilleas Anagnostopoulos (archie@istlab.dmst.aueb.gr) Department of Management
More informationOperating systems for embedded systems. Embedded Operating Systems
Operating systems for embedded systems Embedded operating systems How do they differ from desktop operating systems? Programming model Process-based Event-based How is concurrency handled? How are resource
More informationLogical disks. Bach 2.2.1
Logical disks Bach 2.2.1 Physical disk is divided into partitions or logical disks Logical disk linear sequence of fixed size, randomly accessible, blocks disk device driver maps underlying physical storage
More information- Knowledge of basic computer architecture and organization, ECE 445
ECE 446: Device Driver Development Fall 2014 Wednesdays 7:20-10 PM Office hours: Wednesdays 6:15-7:15 PM or by appointment, Adjunct office Engineering Building room 3707/3708 Last updated: 8/24/14 Instructor:
More informationThe EXT2FS Library. The EXT2FS Library Version 1.37 January by Theodore Ts o
The EXT2FS Library The EXT2FS Library Version 1.37 January 2005 by Theodore Ts o Copyright c 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Theodore Ts o Permission is granted to make and distribute
More informationI/O OPERATIONS. UNIX Programming 2014 Fall by Euiseong Seo
I/O OPERATIONS UNIX Programming 2014 Fall by Euiseong Seo Files Files that contain a stream of bytes are called regular files Regular files can be any of followings ASCII text Data Executable code Shell
More informationToolbox Kernel Korner
Toolbox Kernel Korner In this article, Robert offers a refresher on kernel memory allocation and how it has changed for the 2. by Robert Love Unfortunately for kernel developers, allocating memory in the
More informationNPTEL Course Jan K. Gopinath Indian Institute of Science
Storage Systems NPTEL Course Jan 2012 (Lecture 18) K. Gopinath Indian Institute of Science Spinlocks & Semaphores Shared data betw different parts of code in kernel most common: access to data structures
More informationI/O OPERATIONS. UNIX Programming 2014 Fall by Euiseong Seo
I/O OPERATIONS UNIX Programming 2014 Fall by Euiseong Seo Files Files that contain a stream of bytes are called regular files Regular files can be any of followings ASCII text Data Executable code Shell
More informationFile System CS170 Discussion Week 9. *Some slides taken from TextBook Author s Presentation
File System CS170 Discussion Week 9 *Some slides taken from TextBook Author s Presentation File-System Structure File structure Logical storage unit Collection of related information File system resides
More informationVIRTUAL FILE SYSTEM AND FILE SYSTEM CONCEPTS Operating Systems Design Euiseong Seo
VIRTUAL FILE SYSTEM AND FILE SYSTEM CONCEPTS 2016 Operating Systems Design Euiseong Seo (euiseong@skku.edu) File Layout An entity that separates and isolates data Files have meanings only to applications
More informationHyo-bong Son Computer Systems Laboratory Sungkyunkwan University
File I/O Hyo-bong Son (proshb@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Unix Files A Unix file is a sequence of m bytes: B 0, B 1,..., B k,..., B m-1 All I/O
More informationPOSIX Shared Memory. Linux/UNIX IPC Programming. Outline. Michael Kerrisk, man7.org c 2017 November 2017
Linux/UNIX IPC Programming POSIX Shared Memory Michael Kerrisk, man7.org c 2017 mtk@man7.org November 2017 Outline 10 POSIX Shared Memory 10-1 10.1 Overview 10-3 10.2 Creating and opening shared memory
More informationFormal Verification of Linux Device Drivers
Master s Thesis Formal Verification of Linux Device Drivers Thomas Witkowski May 2007 Supervisors: Prof. Dr. Daniel Kroening and Nicolas Blanc Contents 1. Introduction 7 1.1. Related Work...............................
More informationLinux Device Driver in Action (LDDiA)
Linux Device Driver in Action (LDDiA) Duy-Ky Nguyen 2015-04-30 1. On Memory Any unit under user control must have a controller board (CB) with a controller unit (CU) and several devices (Dev.x) doing what
More informationFiles and the Filesystems. Linux Files
Files and the Filesystems Linux Files The file is the most basic and fundamental abstraction in Linux. Linux follows the everything-is-a-file philosophy. Consequently, much interaction occurs via reading
More informationOutline. OS Interface to Devices. System Input/Output. CSCI 4061 Introduction to Operating Systems. System I/O and Files. Instructor: Abhishek Chandra
Outline CSCI 6 Introduction to Operating Systems System I/O and Files File I/O operations File Descriptors and redirection Pipes and FIFOs Instructor: Abhishek Chandra 2 System Input/Output Hardware devices:
More informationCS 378 (Spring 2003)
Department of Computer Sciences THE UNIVERSITY OF TEXAS AT AUSTIN CS 378 (Spring 2003) Linux Kernel Programming Yongguang Zhang (ygz@cs.utexas.edu) Copyright 2003, Yongguang Zhang Linux File System Mounting
More informationGoals of this Lecture
I/O Management 1 Goals of this Lecture Help you to learn about: The Unix stream concept Standard C I/O functions Unix system-level functions for I/O How the standard C I/O functions use the Unix system-level
More informationISA 563: Fundamentals of Systems Programming
ISA 563: Fundamentals of Systems Programming Advanced IO April 9, 2012 Non-blocking IO Data processing can be much faster than data access Waiting for IO to finish can be time consuming, and may not even
More informationI/O Management! Goals of this Lecture!
I/O Management! 1 Goals of this Lecture! Help you to learn about:" The Unix stream concept" Standard C I/O functions" Unix system-level functions for I/O" How the standard C I/O functions use the Unix
More informationI/O Management! Goals of this Lecture!
I/O Management! 1 Goals of this Lecture! Help you to learn about:" The Unix stream concept" Standard C I/O functions" Unix system-level functions for I/O" How the standard C I/O functions use the Unix
More informationIntroduction to the Linux Kernel. Hao-Ran Liu
Introduction to the Linux Kernel Hao-Ran Liu The history Initially developed by Linus Torvalds in 1991 Source code is released under GNU Public License (GPL) If you modify and release a program protected
More informationThe course that gives CMU its Zip! I/O Nov 15, 2001
15-213 The course that gives CMU its Zip! I/O Nov 15, 2001 Topics Files Unix I/O Standard I/O A typical hardware system CPU chip register file ALU system bus memory bus bus interface I/O bridge main memory
More informationHunting Down Data Races in the Linux Kernel
Hunting Down Data Races in the Linux Kernel Eugene A. Shatokhin www.rosalab.com Data Race "Simultaneous access to the same memory location by multiple threads, where at least one of the accesses modifies
More informationProgramming the GPMC driver
Embedded Systems with Linux Programming the GPMC driver Manuel Domínguez-Pumar Embedded Systems with Linux series Volume 3: Manuel Domínguez Pumar Electronic Engineering Department Technical University
More informationFILE SYSTEMS. Jo, Heeseung
FILE SYSTEMS Jo, Heeseung TODAY'S TOPICS File system basics Directory structure File system mounting File sharing Protection 2 BASIC CONCEPTS Requirements for long-term information storage Store a very
More informationFile Systems Overview. Jin-Soo Kim ( Computer Systems Laboratory Sungkyunkwan University
File Systems Overview Jin-Soo Kim ( jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Today s Topics File system basics Directory structure File system mounting
More informationOwning the Network: Adventures in Router Rootkits
Owning the Network: Adventures in Router Rootkits Michael Coppola Who am I? Security Consultant at Virtual Security Research in Boston, MA (we're hiring!) Student at Northeastern University Did some stuff,
More informationFUSD: A Linux Framework for User-Space Devices. Jeremy Elson.
FUSD: A Linux Framework for User-Space Devices Jeremy Elson jelson@circlemud.org http://www.circlemud.org/jelson/software/fusd 19 August 2003 Documentation for FUSD 1.10 Contents 1 Introduction 1 1.1 What
More informationRun time environments
Run time environments 1 What is runtime? Runtime: time during which a program is running (executing). It contrasts to other phases of program as compile time, link time, load time, etc 2 Topics we will
More information