blob: a7f5701394937f3b33999b9a3a9d5de440c35802 [file] [log] [blame]
The Android Open Source Project8ac3a132009-01-20 14:04:01 -08001
2/*
3 * Copyright (C) 2008 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef _VOLMGR_H
19#define _VOLMGR_H
20
21#include <pthread.h>
22
23#include "vold.h"
24#include "blkdev.h"
25#include "media.h"
26
27#define PROP_EXTERNAL_STORAGE_STATE "EXTERNAL_STORAGE_STATE"
28
29// these must match the corresponding states in the MediaState enum.
30// A path to the volume mount point follows the colon
31typedef enum volume_state {
32 volstate_unknown,
33
34 volstate_nomedia,
35#define VOLD_EVT_NOMEDIA "volume_nomedia:"
36#define VOLD_ES_PVAL_NOMEDIA "removed"
37
38 volstate_unmounted,
39#define VOLD_EVT_UNMOUNTED "volume_unmounted:"
40#define VOLD_ES_PVAL_UNMOUNTED "unmounted"
41
42 volstate_checking,
43#define VOLD_EVT_CHECKING "volume_checking:"
44#define VOLD_ES_PVAL_CHECKING "checking"
45
46 volstate_mounted,
47#define VOLD_EVT_MOUNTED "volume_mounted:"
48#define VOLD_ES_PVAL_MOUNTED "mounted"
49
50 volstate_mounted_ro,
51#define VOLD_EVT_MOUNTED_RO "volume_mounted_ro:"
52#define VOLD_ES_PVAL_MOUNTED_RO "mounted_ro"
53
54 volstate_badremoval,
55#define VOLD_EVT_BADREMOVAL "volume_badremoval:"
56#define VOLD_ES_PVAL_BADREMOVAL "bad_removal"
57
58 volstate_damaged,
59#define VOLD_EVT_DAMAGED "volume_damaged:"
60#define VOLD_ES_PVAL_DAMAGED "unmountable"
61
62 volstate_nofs,
63#define VOLD_EVT_NOFS "volume_nofs:"
64#define VOLD_ES_PVAL_NOFS "nofs"
65
66 volstate_ums,
67#define VOLD_EVT_UMS "volume_ums:"
68#define VOLD_ES_PVAL_UMS "shared"
69
70 volstate_ejecting,
71#define VOLD_EVT_EJECTING "volume_ejecting:"
72#define VOLD_ES_PVAL_EJECTING "ejecting"
73} volume_state_t;
74
75struct volume;
76
77struct volmgr_fstable_entry {
78 char *name;
79 int (*identify_fn) (blkdev_t *dev);
80 int (*check_fn) (blkdev_t *dev);
81 int (*mount_fn) (blkdev_t *dev, struct volume *vol);
82};
83
84struct volmgr_start_args {
85 struct volmgr_fstable_entry *fs;
86 blkdev_t *dev;
87};
88
89typedef struct volume {
90 char *media_path;
91 media_type_t media_type;
92 char *mount_point;
93 char *ums_path;
94
95 pthread_mutex_t lock;
96 volume_state_t state;
97 blkdev_t *dev;
98 pid_t worker_pid;
99 pthread_t worker_thread;
100 struct volmgr_start_args worker_args;
101 boolean worker_running;
102 pthread_mutex_t worker_sem;
103
104 struct volume *next;
105} volume_t;
106
107int volmgr_consider_disk(blkdev_t *dev);
108int volmgr_notify_eject(blkdev_t *dev, void (* cb) (blkdev_t *));
109int volmgr_send_states(void);
110int volmgr_enable_ums(boolean enable);
111int volmgr_stop_volume_by_mountpoint(char *mount_point);
112int volmgr_start_volume_by_mountpoint(char *mount_point);
113
114void KillProcessesWithOpenFiles(const char* mountPoint, boolean sigkill, int *excluded, int num_excluded);
115#endif