从linux驱动程序中执行二进制文件

时间:2014-05-19 09:03:05

标签: c linux-kernel executable syslog udev

我想在位于here的usb driver.c文件中执行以下行后执行可执行文件:

881         if (!retval)
882                 pr_info("%s: registered new device driver %s\n",
883                         usbcore_name, new_udriver->name);

在寡妇中,我们有system之类的调用,可用于调用和执行二进制文件。所以我希望Linux中也有类似的选项。

我的日志消息如下,我已经提到了我想要执行二进制文件的位置:

        [Mon May 12 18:33:00.027 2014] 
        [Mon May 12 18:33:00.027 2014] U-Boot SPL 2014.01 (May 12 2014 - 16:08:58)
        [Mon May 12 18:33:00.027 2014] mmc boot
        [Mon May 12 18:33:00.074 2014] reading fpga.bin
        [Mon May 12 18:33:00.308 2014] zynq_align_dma_buffer: Bitstream is not swapped(1) - swap it
        [Mon May 12 18:33:00.573 2014] reading system.dtb
        [Mon May 12 18:33:00.589 2014] spl: error reading image system.dtb, err - -1
        [Mon May 12 18:33:00.589 2014] reading u-boot.img
        [Mon May 12 18:33:00.589 2014] reading u-boot.img
        [Mon May 12 18:33:00.651 2014] 
        [Mon May 12 18:33:00.651 2014] 
        [Mon May 12 18:33:00.651 2014] U-Boot 2014.01 (May 12 2014 - 16:08:58)
        [Mon May 12 18:33:00.651 2014] 
        [Mon May 12 18:33:00.651 2014] I2C:   ready
        [Mon May 12 18:33:00.651 2014] Memory: ECC disabled
        [Mon May 12 18:33:00.651 2014] DRAM:  1 GiB
        [Mon May 12 18:33:00.667 2014] MMC:   zynq_sdhci: 0
        [Mon May 12 18:33:00.667 2014] Using default environment
        [Mon May 12 18:33:00.667 2014] 
        [Mon May 12 18:33:00.667 2014] In:    serial
        [Mon May 12 18:33:00.667 2014] Out:   serial
        [Mon May 12 18:33:00.667 2014] Err:   serial
        [Mon May 12 18:33:00.667 2014] Net:   Gem.e000b000
        [Mon May 12 18:33:00.667 2014] 
        [Mon May 12 18:33:00.729 2014] Device: zynq_sdhci
        [Mon May 12 18:33:00.729 2014] Manufacturer ID: 2
        [Mon May 12 18:33:00.729 2014] OEM: 544d
        [Mon May 12 18:33:00.729 2014] Name: SA02G 
        [Mon May 12 18:33:00.729 2014] Tran Speed: 50000000
        [Mon May 12 18:33:00.729 2014] Rd Block Len: 512
        [Mon May 12 18:33:00.729 2014] SD version 3.0
        [Mon May 12 18:33:00.729 2014] High Capacity: No
        [Mon May 12 18:33:00.729 2014] Capacity: 1.8 GiB
        [Mon May 12 18:33:00.729 2014] Bus Width: 4-bit
        [Mon May 12 18:33:00.729 2014] reading uEnv.txt
        [Mon May 12 18:33:00.745 2014] ** Unable to read file uEnv.txt **
        [Mon May 12 18:33:00.745 2014] Copying Linux from SD to RAM...
        [Mon May 12 18:33:00.745 2014] reading uImage
        [Mon May 12 18:33:01.073 2014] 3588280 bytes read in 322 ms (10.6 MiB/s)
        [Mon May 12 18:33:01.073 2014] reading devicetree.dtb
        [Mon May 12 18:33:01.088 2014] 6804 bytes read in 19 ms (349.6 KiB/s)
        [Mon May 12 18:33:01.104 2014] reading uramdisk.image.gz
        [Mon May 12 18:33:01.603 2014] 5310018 bytes read in 470 ms (10.8 MiB/s)
        [Mon May 12 18:33:01.603 2014] ## Booting kernel from Legacy Image at 03000000 ...
        [Mon May 12 18:33:01.603 2014]    Image Name:   Linux-3.13.0-xilinx-dirty
        [Mon May 12 18:33:01.603 2014]    Image Type:   ARM Linux Kernel Image (uncompressed)
        [Mon May 12 18:33:01.603 2014]    Data Size:    3588216 Bytes = 3.4 MiB
        [Mon May 12 18:33:01.603 2014]    Load Address: 00008000
        [Mon May 12 18:33:01.603 2014]    Entry Point:  00008000
        [Mon May 12 18:33:01.603 2014]    Verifying Checksum ... OK
        [Mon May 12 18:33:01.665 2014] ## Loading init Ramdisk from Legacy Image at 02000000 ...
        [Mon May 12 18:33:01.665 2014]    Image Name:   
        [Mon May 12 18:33:01.665 2014]    Image Type:   ARM Linux RAMDisk Image (gzip compressed)
        [Mon May 12 18:33:01.665 2014]    Data Size:    5309954 Bytes = 5.1 MiB
        [Mon May 12 18:33:01.665 2014]    Load Address: 00000000
        [Mon May 12 18:33:01.665 2014]    Entry Point:  00000000
        [Mon May 12 18:33:01.665 2014]    Verifying Checksum ... OK
        [Mon May 12 18:33:01.743 2014] ## Flattened Device Tree blob at 02a00000
        [Mon May 12 18:33:01.743 2014]    Booting using the fdt blob at 0x2a00000
        [Mon May 12 18:33:01.743 2014]    Loading Kernel Image ... OK
        [Mon May 12 18:33:01.790 2014]    Loading Ramdisk to 1faef000, end 1ffff602 ... OK
        [Mon May 12 18:33:01.821 2014]    Loading Device Tree to 1faea000, end 1faeea93 ... OK
        [Mon May 12 18:33:01.821 2014] 
        [Mon May 12 18:33:01.821 2014] Starting kernel ...
        [Mon May 12 18:33:01.821 2014] 
        [Mon May 12 18:33:01.837 2014] Uncompressing Linux... done, booting the kernel.
        [Mon May 12 18:33:02.165 2014] [    0.000000] Booting Linux on physical CPU 0x0
        [Mon May 12 18:33:02.165 2014] [    0.000000] Linux version 3.13.0-xilinx-dirty (root@zaidi) (gcc version 4.7.3 (Sourcery CodeBench Lite 2013.05-40) ) #1 SMP PREEMPT Mon May 12 16:37:39 IST 2014
        [Mon May 12 18:33:02.165 2014] [    0.000000] CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
        [Mon May 12 18:33:02.165 2014] [    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
        [Mon May 12 18:33:02.165 2014] [    0.000000] Machine model: Xilinx Zynq
        [Mon May 12 18:33:02.165 2014] [    0.000000] bootconsole [earlycon0] enabled
        [Mon May 12 18:33:02.165 2014] [    0.000000] Memory policy: Data cache writealloc
        [Mon May 12 18:33:02.274 2014] [    0.000000] PERCPU: Embedded 8 pages/cpu @c143f000 s10688 r8192 d13888 u32768
        [Mon May 12 18:33:02.274 2014] [    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 260624
        [Mon May 12 18:33:02.274 2014] [    0.000000] Kernel command line: console=ttyPS0,115200n8 root=/dev/ram rw initrd=0x00800000,16M earlyprintk mtdparts=physmap-flash.0:512K(nor-fsbl),512K(nor-u-boot),5M(nor-linux),9M(nor-user),1M(nor-scratch),-(nor-rootfs)
        [Mon May 12 18:33:02.274 2014] [    0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes)
        [Mon May 12 18:33:02.289 2014] [    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
        [Mon May 12 18:33:02.289 2014] [    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
        [Mon May 12 18:33:02.508 2014] [    0.000000] Memory: 1021760K/1048576K available (4857K kernel code, 310K rwdata, 1708K rodata, 198K init, 5345K bss, 26816K reserved, 270336K highmem)
        [Mon May 12 18:33:02.508 2014] [    0.000000] Virtual kernel memory layout:
        [Mon May 12 18:33:02.508 2014] [    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
        [Mon May 12 18:33:02.508 2014] [    0.000000]     fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
        [Mon May 12 18:33:02.508 2014] [    0.000000]     vmalloc : 0xf0000000 - 0xff000000   ( 240 MB)
        [Mon May 12 18:33:02.508 2014] [    0.000000]     lowmem  : 0xc0000000 - 0xef800000   ( 760 MB)
        [Mon May 12 18:33:02.508 2014] [    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
        [Mon May 12 18:33:02.523 2014] [    0.000000]     modules : 0xbf000000 - 0xbfe00000   (  14 MB)
        [Mon May 12 18:33:02.523 2014] [    0.000000]       .text : 0xc0008000 - 0xc0671828   (6567 kB)
        [Mon May 12 18:33:02.523 2014] [    0.000000]       .init : 0xc0672000 - 0xc06a39c0   ( 199 kB)
        [Mon May 12 18:33:02.523 2014] [    0.000000]       .data : 0xc06a4000 - 0xc06f1ad0   ( 311 kB)
        [Mon May 12 18:33:02.523 2014] [    0.000000]        .bss : 0xc06f1adc - 0xc0c2a1b0   (5346 kB)
        [Mon May 12 18:33:02.555 2014] [    0.000000] Preemptible hierarchical RCU implementation.
        [Mon May 12 18:33:02.555 2014] [    0.000000]     RCU lockdep checking is enabled.
        [Mon May 12 18:33:02.555 2014] [    0.000000]     Dump stacks of tasks blocking RCU-preempt GP.
        [Mon May 12 18:33:02.555 2014] [    0.000000]     RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
        [Mon May 12 18:33:02.555 2014] [    0.000000] NR_IRQS:16 nr_irqs:16 16
        [Mon May 12 18:33:02.570 2014] [    0.000000] ps7-slcr mapped to f0004000
        [Mon May 12 18:33:02.570 2014] [    0.000000] zynq_clock_init: clkc starts at f0004100
        [Mon May 12 18:33:02.570 2014] [    0.000000] Zynq clock init
        [Mon May 12 18:33:02.586 2014] [    0.000000] sched_clock: 32 bits at 333MHz, resolution 3ns, wraps every 12884901885ns
        [Mon May 12 18:33:02.586 2014] [    0.000000] ps7-ttc #0 at f0006000, irq=43
        [Mon May 12 18:33:02.601 2014] [    0.000000] Console: colour dummy device 80x30
        [Mon May 12 18:33:02.601 2014] [    0.000000] Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar
        [Mon May 12 18:33:02.648 2014] [    0.000000] ... MAX_LOCKDEP_SUBCLASSES:  8
        [Mon May 12 18:33:02.648 2014] [    0.000000] ... MAX_LOCK_DEPTH:          48
        [Mon May 12 18:33:02.648 2014] [    0.000000] ... MAX_LOCKDEP_KEYS:        8191
        [Mon May 12 18:33:02.648 2014] [    0.000000] ... CLASSHASH_SIZE:          4096
        [Mon May 12 18:33:02.648 2014] [    0.000000] ... MAX_LOCKDEP_ENTRIES:     16384
        [Mon May 12 18:33:02.648 2014] [    0.000000] ... MAX_LOCKDEP_CHAINS:      32768
        [Mon May 12 18:33:02.648 2014] [    0.000000] ... CHAINHASH_SIZE:          16384
        [Mon May 12 18:33:02.648 2014] [    0.000000]  memory used by lock dependency info: 3695 kB
        [Mon May 12 18:33:02.648 2014] [    0.000000]  per task-struct memory footprint: 1152 bytes
        [Mon May 12 18:33:02.648 2014] [   12.877213] Calibrating delay loop... 1325.46 BogoMIPS (lpj=6627328)
        [Mon May 12 18:33:02.679 2014] [   12.877220] pid_max: default: 32768 minimum: 301
        [Mon May 12 18:33:02.695 2014] [   12.877221] Mount-cache hash table entries: 512
        [Mon May 12 18:33:02.711 2014] [   12.877223] CPU: Testing write buffer coherency: ok
        [Mon May 12 18:33:02.711 2014] [   12.877224] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
        [Mon May 12 18:33:02.711 2014] [   12.877225] Setting up static identity map for 0x49ad18 - 0x49ad70
        [Mon May 12 18:33:02.726 2014] [   12.877226] L310 cache controller enabled
        [Mon May 12 18:33:02.726 2014] [   12.877227] l2x0: 8 ways, CACHE_ID 0x410000c8, AUX_CTRL 0x72460000, Cache size: 512 kB
        [Mon May 12 18:33:02.929 2014] [   12.877242] CPU1: Booted secondary processor
        [Mon May 12 18:33:02.929 2014] [   12.877256] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
        [Mon May 12 18:33:02.929 2014] [   12.877256] Brought up 2 CPUs
        [Mon May 12 18:33:02.929 2014] [   12.877258] SMP: Total of 2 processors activated.
        [Mon May 12 18:33:02.929 2014] [   12.877259] CPU: All CPU(s) started in SVC mode.
        [Mon May 12 18:33:02.929 2014] [   12.877260] devtmpfs: initialized
        [Mon May 12 18:33:02.945 2014] [   12.877262] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
        [Mon May 12 18:33:02.960 2014] [   12.877264] regulator-dummy: no parameters
        [Mon May 12 18:33:02.960 2014] [   12.877265] NET: Registered protocol family 16
        [Mon May 12 18:33:02.960 2014] [   12.877266] DMA: preallocated 256 KiB pool for atomic coherent allocations
        [Mon May 12 18:33:02.976 2014] [   12.877268] cpuidle: using governor ladder
        [Mon May 12 18:33:02.976 2014] [   12.877269] cpuidle: using governor menu
        [Mon May 12 18:33:03.007 2014] [   12.877273] syscon f8000000.ps7-slcr: regmap [mem 0xf8000000-0xf8000fff] registered
        [Mon May 12 18:33:03.023 2014] [   12.877274] hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
        [Mon May 12 18:33:03.023 2014] [   12.877276] hw-breakpoint: maximum watchpoint size is 4 bytes.
        [Mon May 12 18:33:03.038 2014] [   12.877277] zynq-ocm f800c000.ps7-ocmc: ZYNQ OCM pool: 256 KiB @ 0xf0080000
        [Mon May 12 18:33:03.085 2014] [   12.877287] bio: create slab <bio-0> at 0
        [Mon May 12 18:33:03.101 2014] [   12.877288] vgaarb: loaded
        [Mon May 12 18:33:03.101 2014] [   12.877289] SCSI subsystem initialized



        [Mon May 12 18:33:03.116 2014] [   12.877290] usbcore: registered new interface driver usbfs
        [Mon May 12 18:33:03.116 2014] [   12.877291] usbcore: registered new interface driver hub
        [Mon May 12 18:33:03.116 2014] [   12.877291] usbcore: registered new device driver usb



    /**************************** EXECUTE BINARY HERE ************************/

    /**************************** EXECUTE BINARY HERE ************************/

    /**************************** EXECUTE BINARY HERE ************************/

    /**************************** EXECUTE BINARY HERE ************************/

        [Mon May 12 18:33:03.132 2014] [   12.877293] media: Linux media interface: v0.10
        [Mon May 12 18:33:03.132 2014] [   12.877293] Linux video capture interface: v2.00
        [Mon May 12 18:33:03.147 2014] [   12.877294] pps_core: LinuxPPS API ver. 1 registered
        [Mon May 12 18:33:03.147 2014] [   12.877295] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
        [Mon May 12 18:33:03.147 2014] [   12.877297] PTP clock support registered
        [Mon May 12 18:33:03.163 2014] [   12.877297] EDAC MC: Ver: 3.0.0
        [Mon May 12 18:33:03.179 2014] [   12.877300] DMA-API: preallocated 4096 debug entries
        [Mon May 12 18:33:03.179 2014] [   12.877301] DMA-API: debugging enabled by kernel config
        [Mon May 12 18:33:03.179 2014] [   12.877301] Switched to clocksource arm_global_timer
        [Mon May 12 18:33:03.241 2014] [   12.877310] NET: Registered protocol family 2
        [Mon May 12 18:33:03.241 2014] [   12.877311] TCP established hash table entries: 8192 (order: 3, 32768 bytes)
        [Mon May 12 18:33:03.257 2014] [   12.877313] TCP bind hash table entries: 8192 (order: 6, 294912 bytes)
        [Mon May 12 18:33:03.257 2014] [   12.877314] TCP: Hash tables configured (established 8192 bind 8192)
        [Mon May 12 18:33:03.272 2014] [   12.877315] TCP: reno registered
        [Mon May 12 18:33:03.272 2014] [   12.877316] UDP hash table entries: 512 (order: 3, 40960 bytes)
        [Mon May 12 18:33:03.288 2014] [   12.877317] UDP-Lite hash table entries: 512 (order: 3, 40960 bytes)
        [Mon May 12 18:33:03.288 2014] [   12.877318] NET: Registered protocol family 1
        [Mon May 12 18:33:03.319 2014] [   12.877319] RPC: Registered named UNIX socket transport module.
        [Mon May 12 18:33:03.319 2014] [   12.877320] RPC: Registered udp transport module.
        [Mon May 12 18:33:03.319 2014] [   12.877321] RPC: Registered tcp transport module.
        [Mon May 12 18:33:03.319 2014] [   12.877322] RPC: Registered tcp NFSv4.1 backchannel transport module.
        [Mon May 12 18:33:03.319 2014] [   12.877323] Trying to unpack rootfs image as initramfs...
        [Mon May 12 18:33:03.319 2014] [   12.877324] rootfs image is not initramfs (no cpio magic); looks like an initrd
        [Mon May 12 18:33:03.366 2014] [   12.877331] Freeing initrd memory: 5184K (dfaef000 - dffff000)
        [Mon May 12 18:33:03.381 2014] [   12.877332] hw perfevents: enabled with ARMv7 Cortex-A9 PMU driver, 7 counters available
        [Mon May 12 18:33:03.397 2014] [   12.877335] bounce pool size: 64 pages
        [Mon May 12 18:33:03.397 2014] [   12.877336] jffs2: version 2.2. (NAND) (SUMMARY)  © 2001-2006 Red Hat, Inc.
        [Mon May 12 18:33:03.413 2014] [   12.877338] msgmni has been set to 1477
        [Mon May 12 18:33:03.428 2014] [   12.877339] io scheduler noop registered
        [Mon May 12 18:33:03.428 2014] [   12.877339] io scheduler deadline registered
        [Mon May 12 18:33:03.428 2014] [   12.877340] io scheduler cfq registered (default)
        [Mon May 12 18:33:03.459 2014] [   12.877343] dma-pl330 f8003000.ps7-dma: unable to set the seg size
        [Mon May 12 18:33:03.459 2014] [   12.877344] dma-pl330 f8003000.ps7-dma: Loaded driver for PL330 DMAC-2364208
        [Mon May 12 18:33:03.459 2014] [   12.877345] dma-pl330 f8003000.ps7-dma:     DBUFF-128x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16
        [Mon May 12 18:33:03.475 2014] [   12.877347] e0001000.serial: ttyPS1 at MMIO 0xe0001000 (irq = 82, base_baud = 3124999) is a xuartps
        [Mon May 12 18:33:03.475 2014] [   12.877349] xdevcfg f8007000.ps7-dev-cfg: ioremap 0xf8007000 to f0068000
        [Mon May 12 18:33:03.506 2014] [   12.877355] brd: module loaded
        [Mon May 12 18:33:03.522 2014] [   12.877358] loop: module loaded
        [Mon May 12 18:33:03.553 2014] [   12.877360] zynq-qspi e000d000.ps7-qspi: master is unqueued, this is deprecated
        [Mon May 12 18:33:03.553 2014] [   12.877361] zynq-qspi e000d000.ps7-qspi: at 0xE000D000 mapped to 0xF006A000, irq=51
        [Mon May 12 18:33:03.569 2014] [   12.877364] e1000e: Intel(R) PRO/1000 Network Driver - 2.3.2-k
        [Mon May 12 18:33:03.569 2014] [   12.877365] e1000e: Copyright(c) 1999 - 2013 Intel Corporation.
        [Mon May 12 18:33:03.584 2014] [   12.877366] libphy: XEMACPS mii bus: probed
        [Mon May 12 18:33:03.600 2014] [   12.877367] mdio_bus e000b000: cannot get PHY at address 7
        [Mon May 12 18:33:03.600 2014] [   12.877368] xemacps e000b000.ps7-ethernet: pdev->id -1, baseaddr 0xe000b000, irq 54
        [Mon May 12 18:33:03.600 2014] [   12.877370] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
        [Mon May 12 18:33:03.615 2014] [   12.877371] ehci-pci: EHCI PCI platform driver
        [Mon May 12 18:33:03.615 2014] [   12.877372] zynq-dr e0002000.ps7-usb: Unable to init USB phy, missing?
        [Mon May 12 18:33:03.631 2014] [   12.877373] usbcore: registered new interface driver usb-storage
[Mon May 12 18:33:03.787 2014] [   12.877400] usbhid: USB HID core driver
[Mon May 12 18:33:03.803 2014] [   12.877205] TCP: cubic registered
[Mon May 12 18:33:03.803 2014] [   12.877206] NET: Registered protocol family 17
[Mon May 12 18:33:03.803 2014] [   12.877206] Registering SWP/SWPB emulation handler
[Mon May 12 18:33:03.818 2014] [   12.877207] bootconsole [earlycon0] disabled

抱歉有些困惑(我的同事与我的同事交换过)。

我在带有易失性文件系统的嵌入式系统上运行linux。所以我将无法在/etc/syslog.config中保留任何更改(如果您要求我研究syslog)。

此外,我在源代码中找不到与syslog相关的文件。虽然我找到了一个包含以下内容的文件:

#define SYSLOG_ACTION_CLEAR          5
/* Disable printk's to console */
#define SYSLOG_ACTION_CONSOLE_OFF    6
/* Enable printk's to console */
#define SYSLOG_ACTION_CONSOLE_ON     7
/* Set level of messages printed to console */
#define SYSLOG_ACTION_CONSOLE_LEVEL  8
/* Return number of unread characters in the log buffer */
#define SYSLOG_ACTION_SIZE_UNREAD    9
/* Return size of the log buffer */
#define SYSLOG_ACTION_SIZE_BUFFER   10

#define SYSLOG_FROM_CALL 0
#define SYSLOG_FROM_FILE 1

int do_syslog(int type, char __user *buf, int count, bool from_file);

#endif /* _LINUX_SYSLOG_H */

/include/linux/syslog.h

但我不知道如何从这里运行二进制文件。

我特意跑步exec alsao,但也没有通过。

1 个答案:

答案 0 :(得分:5)

system()也存在于unix上,但是是一个用户空间libc api调用,你不能在内核模式驱动程序中使用它。这也是Windows的情况。如果驱动程序启动二进制可执行文件,它会在两个系统上使用不同的api调用。

可以在linux上启动二进制可执行文件,最好的例子是内核在启动时启动/sbin/init

使用do_execve() api调用可以从kernelmode启动进程,您可以在内核源代码中看到init/main.c

接下来,在这种情况下我会看到2(和恕我直言,更好)选项来启动二进制文件:

  1. 这是一个内核消息,由系统日志记录守护进程捕获。如果发生与给定正则表达式匹配的消息,则这些守护进程几乎可以执行某些操作(例如,运行您的脚本)。这样的syslog守护进程的最佳选择是(imho)syslog-ng或rsyslog。

  2. 有一个名为udev的基础架构,它几乎是所有较新的Linux发行版的核心组件。 udev的作用:实际上监视计算机设备树的更改,如果有任何更改(例如,如果新的usb设备与供应商:插入了modelid)将执行它配置的内容。 (初始化设备驱动程序,调用外部二进制文件,加载备用模块等)。

  3. 在你的位置,我做了(2),虽然udev的配置有点复杂,并没有很好地记录。使用系统日志脚本,您可以更快地完成此任务,尽管它不是那么漂亮的解决方案。

    我几乎可以肯定,您不需要内核模式编程来实现目标。