⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vold.h

📁 linux下自动mount各种即插即用设备的一个小程序源码 文件包含内容: /vold.h /vold.c /split.h /split.c /disktype-6/disktype.c
💻 H
字号:
#ifndef _VOLD_H#define _VOLD_H#include "debug.h"#include "split.h"#include "disktype-6/disktype.h"#include <uuid/uuid.h>#define VOLD_VERSION	"0"#define VOLD_SUBVERSION	"2"#define VOLD_ROOT		"/usr/local"#define VOLD_VOLUMEROOT	"/Volumes"#define VOLD_PIDFILE	"/var/run/vold.pid"#define VOLD_CONFIGFILE	"/etc/vold.conf"#define MAX_STRLEN		255#define SDUP(target_string, value_string) \if(value_string != NULL) { target_string = strdup(value_string); }\else { target_string = NULL; }#define SADD(target_string, value_string) \if(target_string == NULL && value_string != NULL) { target_string = strdup(value_string); }enum {    VOLD_UNKNOWN = 0,    VOLD_UNMOUNTED,    VOLD_MOUNTED,    VOLD_IGNORED,		VOLD_ADD,	VOLD_REMOVE};
/* struct that defines device item used in automatic device test */
typedef struct scan_item_td {
    short	status;		/* Status of the device (unknown, ignored, mounted, unmounted) */
    short	periodic;	/* check this device periodically or only on SIGUSR1 and startup? */ 
    char*	device;		/* devicepath (i.e. /dev/sda1) */    struct	scan_item_td* next;} scan_item;/* hotplug message struct. defines a hotplug message */typedef struct hotplug_msg_td {	short	action;		/* VOLD_ADD | VOLD_REMOVE */	char*	vendor;		/* Vendor of the device just added/removed */	char*	model;		/* ditto for model */	char*	device;		/* device path */} hotplug_msg;/*	about fixed mountpoints: since the user gives us a mount point we need to know	what we actually have to mount. We need a way to identify the correct partition.	The best way to do this is the UUID, but since not all filesystems have a UUID	the user may also give a volume label instead. I will implement a patch    later that all partitions can have a UUID via a file on the device (/.uuid_file) */typedef struct vold_mount_td {    short	fixed;			/* removable media like cdrom or ipod? fixed is set true if we have fstab entry */	char*	device;			/* device path */    char*	mountpoint;		/* mount point it should appear under */	char*	fstype;			/* Filesystem of the mount */    unsigned long	mountflags;	/* mountflags for this device (currently unused) */    char*	data;			/* comma separated options understood by fs */    char*	volumename;		/* Volume label of the source partition */	uuid_t	uuid;			/* UUID of the source partition */    struct vold_mount_td*	next;} vold_mount;/* info struct returned by get_mountpoint that tells us where and how we have to mount */typedef struct mount_info_td {    char*	mountpoint;		/* mountpoint to mount under */    char*	fs;				/* filesystem (i.e. vfat, ntfs, ext3) */    unsigned long	mountflags;	/* general mountflags */    char*	data;			/* comma separated options understood by this filesystem */} mount_info;/* devices for scanning (scan list) */void sdevice_free(scan_item* list);scan_item* sdevice_new(char* device, int periodic);void sdevice_add(scan_item* device);scan_item* sdevice_find(char* device);void sdevice_list();/* functions for internal mount handling	vold maintains a list of all mounted devices */void vmount_free(vold_mount* list);vold_mount* vmount_new();void vmount_add(vold_mount* vm);void vmount_remove(vold_mount* vm);vold_mount* vmount_find(char* device, uuid_t uuid, char* volumename);void vmount_list();/* vold.c *//* returns 1 if device can be opened */int device_exists(char* device);/* loads /etc/fstab and mount all devices */void load_fstab();/* scans all devices in the scan list */int scan_devices(int periodic);/* handles a new device (add / remove) */void handle_device(hotplug_msg* msg, scan_item* dev);/* mounts a device (intelligent wrapper around mount) */int mount_device(vold_mount* vm);/* unmounts a device */int unmount_device(vold_mount* vm);/* finds a suitable mountpoint and saves it in vm */void get_mountpoint(vold_mount* vm);/* validates a mountpoint by creating the apropriate directorys or selecting another mountpoint	returns a valid mountpoint if it can find one */char* validate_mountpoint(char* mountpoint, int recursion_level);/* returns 1 if the device (/dev/sda or /Volumes/mymount) is mounted */int dir_mounted(char* device);/* opens a filesystem and tries to extract the uuid from the uuidfile: /.uuid_file */int get_uuid_from_fs(char* fstype, char* device, uuid_t uuid);void loadconfigfile(char* filename);void exec_config(int argc, char* argv[], int linecount);void showhelp();void showversion();void getconfig(int argc, char* argv[]);void writepidfile(char* filename);
void quit(int errorlevel);
void signal_handler(int signum);

void check_on_signal(int signum);int main(int argc, char* argv[]);#endif /* _VOLD_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -