© 2009 IBM Corporation Tianhong Wang 2012/06/28 Android’s udev —— Vold.

Slides:



Advertisements
Similar presentations
Device Drivers. Linux Device Drivers Linux supports three types of hardware device: character, block and network –character devices: R/W without buffering.
Advertisements

CSI 400/500 Operating Systems Spring 2009 Lecture #14 – Device Management and Drivers Monday, March 23 rd, 2009.
USERSPACE I/O Reporter: R 張凱富.
1 OS Structure, Processes & Process Management. 2 Recap OS functions  Coordinator  Protection  Communication  Resource management  Service provider.
Elementary TCP Sockets Computer Networks Computer Networks Term B10 UNIX Network Programming Vol. 1, Second Ed. Stevens Chapter 4.
CS3516 B10 Help Session 1 CS3516 — TCP/IP Socket Programming Presented by Can (John) Tatar.
Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens.
MIGSOCK Migratable TCP Socket in Linux Demonstration of Functionality Karthik Rajan Bryan Kuntz.
Creating WordPress Websites. Creating a site on your computer Local server Local WordPress installation Setting Up Dreamweaver.
RAPIDS Server Author: Anna Bekkerman
Experiment: Step by Step Author: Anna Bekkerman
Comparative Operating Systems Understanding the Kernel Structure Prashant Thuppala.
SKKU Embedded Software Lab Remote Sensor Byunghei Jun Dongsu Kim Dongig Sin.
1 Netfilter in Linux Bing Qi Department of Computer Science and Engineering Auburn university.
Network File System (NFS) in AIX System COSC513 Operation Systems Instructor: Prof. Anvari Yuan Ma SID:
Stan Smith Intel SSG/DPD June, 2015 Kernel Fabric Interface KFI Framework.
Introduction to Linux Network 劉德懿
The Programming Interface. Main Points Creating and managing processes – fork, exec, wait Performing I/O – open, read, write, close Communicating between.
Server Design Discuss Design issues for Servers Review Server Creation in Linux.
Hacking the Bluetooth Pairing Authentication Process Graduate Operating System Mini Project Siyuan Jiang and Haipeng Cai.
Sockets CIS 370 Fall 2009, UMassD. Introduction  Sockets provide a simple programming interface which is consistent for processes on the same machine.
ECE 4110 – Internetwork Programming Client-Server Model.
Assignment 3 A Client/Server Application: Chatroom.
WINDOWS SERVICES. Introduction You often need programs that run continuously in the background Examples: – servers –Print spooler You often need.
Chapter 17 Networking Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.
Introduction to the Atlas Platform Mobile & Pervasive Computing Laboratory Department of Computer and Information Sciences and Engineering University of.
Real-time Systems Lab, Computer Science and Engineering, ASU Linux Input Systems (ESP – Fall 2014) Computer Science & Engineering Department Arizona State.
Business Unit or Product Name © 2007 IBM Corporation Introduction of Autotest Qing Lin.
Socket Swapping for efficient distributed communication between migrating processes MS Final Defense Praveen Ramanan 12 th Dec 2002.
C questions A great programmer codes excellent code in C and Java. The code does video decoding. Java code works faster then C on my computer. how come?
TELE 301 Lecture 10: Scheduled … 1 Overview Last Lecture –Post installation This Lecture –Scheduled tasks and log management Next Lecture –DNS –Readings:
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 6 System Calls OS System.
Lecture 2: Linux devices Roei Ben-Harush Agenda 1 1 Linux Devices About next Assignment Roei Ben-Harush 2015 Reminder.
---- IT Acumens. COM IT Acumens. COMIT Acumens. COM.
Unit - VI. Linux and Real Time: Real Time Tasks Hard and Soft Real Time Tasks Linux Scheduling Latency Kernel Preemption Challenges in Kernel Preemption.
Linux Architecture Overview 1. Initialization Uboot – hardware init, loads kernel Kernel – remaining initialization, calls “init” Init – 1 st process,
DAQ Control GSI, Aug 2005Hans G. Essel CBM - DAQ Control1 MBS monitor (FOPI) (J.Adamczewski, M.Stockmeier)
© 2004 OPNET Technologies, Inc. All rights reserved. OPNET and OPNET product names are trademarks of OPNET Technologies, Inc. ARMing Apache David Carter.
2/26/021 Pegasus Security Architecture Author: Nag Boranna Hewlett-Packard Company.
Linux Kernel Management. Module 9 – Kernel Administration ♦ Overview The innermost layer of Linux operating system is the kernel, which is a thin layer.
Linux Implementation of the TRILL protocol Syed Mohsin Kazmi, Mohsin Sardar, Syed Ali Khayam School of EECS National University of Sciences & Technology.
FTP Server API Implementing the FTP Server Registering FTP Command Callbacks Data and Control Port Close Callbacks Other Server Calls.
Mark E. Fuller Senior Principal Instructor Oracle University Oracle Corporation.
Kernel mode linux. Why? ● The pros – There is a C like interface inside the Linux kernel already. – The speed. – The size of AP. ● The cons – Missing.
Client/Server Socket Programming Project
CS 6401 Introduction to Computer Networks 09/21/2010 Outline - UNIX sockets - A simple client-server program - Project 1 - LAN bridges and learning.
Interfacing Device Drivers with the Kernel
User-Space-to-Kernel Interface
Review: – Why layer architecture? – peer entities – Protocol and service interface – Connection-oriented/connectionless service – Reliable/unreliable service.

Linux Architecture Overview.
FTP Client API FTP in embedded devices Implementing an FTP Client FTP Command APIs Other FTP Client APIs.
Introduction to FUSE (File system in USEr space) Speaker:Zong-shuo Jheng Date:March 14, 2008.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
1 Socket Interface. 2 Basic Sockets API Review Socket Library TCPUDP IP EthernetPPP ARP DHCP, Mail, WWW, TELNET, FTP... Network cardCom Layer 4 / Transport.
Sockets API Developing Applications using the Sockets API.
Lecture 3: Stateless Packet Filtering. 2 Agenda 1 1 Linux file system - networking sk_buff 2 2 Stateless packet filtering 3 3 About next assignment 4.
Tgt: Framework Target Drivers FUJITA Tomonori NTT Cyber Solutions Laboratories Mike Christie Red Hat, Inc Ottawa Linux.
SOCKET PROGRAMMING Presented By : Divya Sharma.
Zero-copy Receive Path in Virtio
EXAM CODE LX0-103 CompTIA Linux+ [Powered by LPI] 1
Karthik Dantu and Steve Ko
Netconf 2006 Tokyo Paul Moore
OPNFV: Support for HA Guest APIs: Introduction
Linux Kernel Driver.
Configuring a Router Module 3 Semester 2.
Socket Program Training
Tiers vs. Layers.
Time Gathering Systems Secure Data Collection for IBM System i Server
Linux Architecture Overview.
Presentation transcript:

© 2009 IBM Corporation Tianhong Wang 2012/06/28 Android’s udev —— Vold

© 2009 IBM Corporation Agenda  Linux Udev Introduction  Udev Usage Example  Android Vold Introduction

© 2009 IBM Corporation Linux Udev Introduction U U Udev is the device manager for the linux kernel. Primarily, it manages device nodes in /dev. It is the successor of devfs and hotplug, which means that it handles the /dev directory and all user space actions when adding/removing devices, including firmware load.

© 2009 IBM Corporation Linux Udev Architecture U T The system is divided into three parts: 1 1. namedev —— parse the naming rule config file /etc/udev/rules.d 2 2. libsysfs —— read the hardware information under /sys/class 3 3. udev —— get the libsysfs info and the namedev info to create the device file under /dev U udev toolsets: udevadm 、 udevcontrol 、 udevinfo 、 udevmonitor 、 udevsettle 、 udevtest 、 udevtrigger

© 2009 IBM Corporation Linux Udev Architecture U

© 2009 IBM Corporation Udev Usage Example U

© 2009 IBM Corporation Udev Usage Example U

© 2009 IBM Corporation Android Vold Introduction Vold has two function: 1) send the kernel message to user space 2) accpet the user space command to do the device mount operation

© 2009 IBM Corporation Android Vold Basic Structure Vold(Volume Daemon) is a new mechanism that can dynamically create the device file according to listen the kernel uevent.

© 2009 IBM Corporation Android Vold Structure in Framework Layer NativeDaemonConnector SocketListener NetlinkListenerCommandListener AutoVolume DirectVolume VolumeManager NetlinkManagerVolume read vold.fstab, create DirectVolume Kernel Mount Command execute JNI

© 2009 IBM Corporation Vold Running Function Step 1: vold init startup Step 2: setup the connection Step 3: load the rule file Step 4: event handler

© 2009 IBM Corporation Step 1: Vold init startup

© 2009 IBM Corporation Step 1: Vold init startup void main(){ VolumeManager *vm; CommandListener *cl; NetlinkManager *nm; mkdir("/dev/block/vold", 0755); /* Create our singleton managers */ if (!(vm = VolumeManager::Instance())) { SLOGE("Unable to create VolumeManager"); exit(1); }; if (!(nm = NetlinkManager::Instance())) { SLOGE("Unable to create NetlinkManager"); exit(1); }; cl = new CommandListener(); vm->setBroadcaster((SocketListener *) cl); nm->setBroadcaster((SocketListener *) cl); if (vm->start()) { SLOGE("Unable to start VolumeManager (%s)", strerror(errno)); exit(1); } if (process_config(vm)) { SLOGE("Error reading configuration (%s)... continuing anyways", strerror(errno)); } if (nm->start()) { SLOGE("Unable to start NetlinkManager (%s)", strerror(errno)); exit(1); } … }

© 2009 IBM Corporation Step 2: setup the connection Two communication socket: 1)Vold socket: communction with vold and framework(FrameworkListener) 2)Sysfs uevent socket: communication with kernel(NetlinkListener)

© 2009 IBM Corporation Step 3: Load Rules file —— vold.fstab

© 2009 IBM Corporation Step 4: Event Handler 1) kernel trigger uevent: call NetlinkHandler::onEvent() after parsing uevent information

© 2009 IBM Corporation Step 4: Event Handler 2) Command Sent from Framework Layer: call VolumeManger function

© 2009 IBM Corporation Netlink Mechanism Kernel SpaceUser Space netlink_proto_init netlink_kernel_create sock_register(&netlink_family_ops) syscall: socket sys_sock netlink_create netlink_rcv_skb netlink_create send_to

© 2009 IBM Corporation static int __inti netlink_proto_init(void) { …… sock_register(&netlink_family_ops); …… } static const struct net_proto_family netlink_family_ops = {.family = PF_NETLINK,.create = netlink_create,.owner= THIS_MODULE,/* for consistency 8) */ }; static int netlink_create(struct net *net, struct socket *sock, int protocol, int kern) { struct module *module = NULL; struct mutex *cb_mutex; struct netlink_sock *nlk; int err = 0; sock->state = SS_UNCONNECTED; if (sock->type != SOCK_RAW && sock->type != SOCK_DGRAM) return -ESOCKTNOSUPPORT; if (protocol = MAX_LINKS) return -EPROTONOSUPPORT; netlink_lock_table(); …… } Client Netlink Socket

© 2009 IBM Corporation struct sock * netlink_kernel_create(struct net *net, int unit, unsigned int groups, void (*input)(struct sk_buff *skb), struct mutex *cb_mutex, struct module *module) { struct socket *sock; struct sock *sk; struct netlink_sock *nlk; struct listeners *listeners = NULL; BUG_ON(!nl_table); if (unit = MAX_LINKS) return NULL; if (sock_create_lite(PF_NETLINK, SOCK_DGRAM, unit, &sock)) return NULL; …… } Server Netlink Socket

© 2009 IBM Corporation