Changeset bb154c6 in mainline for uspace/srv/sysman/units/unit_mnt.c
- Timestamp:
- 2019-08-03T08:15:25Z (6 years ago)
- Children:
- 09a8006
- Parents:
- 6006f35
- git-author:
- Michal Koutný <xm.koutny+hos@…> (2015-04-15 15:14:58)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2019-08-03 08:15:25)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/sysman/units/unit_mnt.c
r6006f35 rbb154c6 7 7 #include "log.h" 8 8 #include "unit.h" 9 #include "unit_mnt.h" 9 10 static const char *section_name = "Mount"; 11 12 static config_item_t unit_configuration[] = { 13 {"What", &config_parse_string, offsetof(unit_mnt_t, device), NULL}, 14 {"Where", &config_parse_string, offsetof(unit_mnt_t, mountpoint), NULL}, 15 {"Type", &config_parse_string, offsetof(unit_mnt_t, type), NULL}, 16 CONFIGURATION_ITEM_SENTINEL 17 }; 10 18 11 19 static void unit_mnt_init(unit_t *unit) 12 20 { 13 assert(unit->data.mnt.type == NULL); 14 assert(unit->data.mnt.mountpoint == NULL); 15 assert(unit->data.mnt.device == NULL); 21 unit_mnt_t *u_mnt = CAST_MNT(unit); 22 assert(u_mnt); 23 24 u_mnt->type = NULL; 25 u_mnt->mountpoint = NULL; 26 u_mnt->device = NULL; 27 } 28 29 static void unit_mnt_destroy(unit_t *unit) 30 { 31 assert(unit->type == UNIT_MOUNT); 32 unit_mnt_t *u_mnt = CAST_MNT(unit); 33 34 sysman_log(LVL_DEBUG2, "%s, %p, %p, %p", __func__, 35 u_mnt->type, u_mnt->mountpoint, u_mnt->device); 36 free(u_mnt->type); 37 free(u_mnt->mountpoint); 38 free(u_mnt->device); 39 } 40 41 static int unit_mnt_load(unit_t *unit, ini_configuration_t *ini_conf, 42 text_parse_t *text_parse) 43 { 44 unit_mnt_t *u_mnt = CAST_MNT(unit); 45 assert(u_mnt); 46 47 ini_section_t *section = ini_get_section(ini_conf, section_name); 48 if (section == NULL) { 49 sysman_log(LVL_ERROR, 50 "Expected section '%s' in configuration of unit '%s'", 51 section_name, unit_name(unit)); 52 return ENOENT; 53 } 54 55 return config_load_ini_section(unit_configuration, section, u_mnt, 56 text_parse); 16 57 } 17 58 18 59 static int unit_mnt_start(unit_t *unit) 19 60 { 61 unit_mnt_t *u_mnt = CAST_MNT(unit); 62 assert(u_mnt); 63 20 64 fibril_mutex_lock(&unit->state_mtx); 21 65 … … 28 72 29 73 30 unit_mnt_t *data = &unit->data.mnt;31 32 74 // TODO use other mount parameters 33 int rc = mount( data->type, data->mountpoint, data->device, "",75 int rc = mount(u_mnt->type, u_mnt->mountpoint, u_mnt->device, "", 34 76 IPC_FLAG_BLOCKING, 0); 35 77 36 78 if (rc == EOK) { 37 sysman_log(LVL_NOTE, "Mount ( %p) mounted", unit);79 sysman_log(LVL_NOTE, "Mount ('%s') mounted", unit_name(unit)); 38 80 unit_set_state(unit, STATE_STARTED); 39 81 } else { 40 sysman_log(LVL_ERROR, "Mount (%p) failed (%i)", unit, rc); 82 sysman_log(LVL_ERROR, "Mount ('%s') failed (%i)", 83 unit_name(unit), rc); 41 84 unit_set_state(unit, STATE_FAILED); 42 85 } … … 45 88 } 46 89 47 static void unit_mnt_destroy(unit_t *unit) 48 { 49 free(unit->data.mnt.type); 50 free(unit->data.mnt.mountpoint); 51 free(unit->data.mnt.device); 52 } 90 DEFINE_UNIT_VMT(unit_mnt) 53 91 54 55 DEFINE_UNIT_OPS(unit_mnt)56
Note:
See TracChangeset
for help on using the changeset viewer.