Loading fs_mgr/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -92,6 +92,7 @@ cc_library_static { name: "libfstab", name: "libfstab", vendor_available: true, vendor_available: true, recovery_available: true, recovery_available: true, host_supported: true, defaults: ["fs_mgr_defaults"], defaults: ["fs_mgr_defaults"], srcs: [ srcs: [ "fs_mgr_fstab.cpp", "fs_mgr_fstab.cpp", Loading fs_mgr/fs_mgr_fstab.cpp +10 −29 Original line number Original line Diff line number Diff line Loading @@ -209,17 +209,12 @@ static bool read_dt_file(const std::string& file_name, std::string* dt_value) } } static uint64_t parse_flags(char* flags, struct flag_list* fl, struct fs_mgr_flag_values* flag_vals, static uint64_t parse_flags(char* flags, struct flag_list* fl, struct fs_mgr_flag_values* flag_vals, char* fs_options, int fs_options_len) { std::string* fs_options) { uint64_t f = 0; uint64_t f = 0; int i; int i; char *p; char *p; char *savep; char *savep; /* initialize fs_options to the null string */ if (fs_options && (fs_options_len > 0)) { fs_options[0] = '\0'; } p = strtok_r(flags, ",", &savep); p = strtok_r(flags, ",", &savep); while (p) { while (p) { /* Look for the flag "p" in the flag list "fl" /* Look for the flag "p" in the flag list "fl" Loading Loading @@ -356,26 +351,20 @@ static uint64_t parse_flags(char* flags, struct flag_list* fl, struct fs_mgr_fla if (!fl[i].name) { if (!fl[i].name) { if (fs_options) { if (fs_options) { /* It's not a known flag, so it must be a filesystem specific // It's not a known flag, so it must be a filesystem specific * option. Add it to fs_options if it was passed in. // option. Add it to fs_options if it was passed in. */ if (!fs_options->empty()) { strlcat(fs_options, p, fs_options_len); fs_options->append(","); // appends a comma if not the first strlcat(fs_options, ",", fs_options_len); } fs_options->append(p); } else { } else { /* fs_options was not passed in, so if the flag is unknown // fs_options was not passed in, so if the flag is unknown it's an error. * it's an error. */ LERROR << "Warning: unknown flag " << p; LERROR << "Warning: unknown flag " << p; } } } } p = strtok_r(NULL, ",", &savep); p = strtok_r(NULL, ",", &savep); } } if (fs_options && fs_options[0]) { /* remove the last trailing comma from the list of options */ fs_options[strlen(fs_options) - 1] = '\0'; } return f; return f; } } Loading Loading @@ -513,8 +502,6 @@ static bool fs_mgr_read_fstab_file(FILE* fstab_file, bool proc_mounts, Fstab* fs char *save_ptr, *p; char *save_ptr, *p; Fstab fstab; Fstab fstab; struct fs_mgr_flag_values flag_vals; struct fs_mgr_flag_values flag_vals; #define FS_OPTIONS_LEN 1024 char tmp_fs_options[FS_OPTIONS_LEN]; while ((len = getline(&line, &alloc_len, fstab_file)) != -1) { while ((len = getline(&line, &alloc_len, fstab_file)) != -1) { /* if the last character is a newline, shorten the string by 1 byte */ /* if the last character is a newline, shorten the string by 1 byte */ Loading Loading @@ -555,13 +542,7 @@ static bool fs_mgr_read_fstab_file(FILE* fstab_file, bool proc_mounts, Fstab* fs LERROR << "Error parsing mount_flags"; LERROR << "Error parsing mount_flags"; goto err; goto err; } } tmp_fs_options[0] = '\0'; entry.flags = parse_flags(p, mount_flags, nullptr, &entry.fs_options); entry.flags = parse_flags(p, mount_flags, NULL, tmp_fs_options, FS_OPTIONS_LEN); /* fs_options are optional */ if (tmp_fs_options[0]) { entry.fs_options = tmp_fs_options; } // For /proc/mounts, ignore everything after mnt_freq and mnt_passno // For /proc/mounts, ignore everything after mnt_freq and mnt_passno if (proc_mounts) { if (proc_mounts) { Loading @@ -570,7 +551,7 @@ static bool fs_mgr_read_fstab_file(FILE* fstab_file, bool proc_mounts, Fstab* fs LERROR << "Error parsing fs_mgr_options"; LERROR << "Error parsing fs_mgr_options"; goto err; goto err; } } entry.fs_mgr_flags.val = parse_flags(p, fs_mgr_flags, &flag_vals, NULL, 0); entry.fs_mgr_flags.val = parse_flags(p, fs_mgr_flags, &flag_vals, nullptr); entry.key_loc = std::move(flag_vals.key_loc); entry.key_loc = std::move(flag_vals.key_loc); entry.key_dir = std::move(flag_vals.key_dir); entry.key_dir = std::move(flag_vals.key_dir); Loading fs_mgr/libdm/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -18,6 +18,7 @@ cc_library_static { name: "libdm", name: "libdm", defaults: ["fs_mgr_defaults"], defaults: ["fs_mgr_defaults"], recovery_available: true, recovery_available: true, host_supported: true, export_include_dirs: ["include"], export_include_dirs: ["include"], Loading fs_mgr/libdm/dm.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -349,7 +349,7 @@ void DeviceMapper::InitIo(struct dm_ioctl* io, const std::string& name) const { io->data_size = sizeof(*io); io->data_size = sizeof(*io); io->data_start = 0; io->data_start = 0; if (!name.empty()) { if (!name.empty()) { strlcpy(io->name, name.c_str(), sizeof(io->name)); snprintf(io->name, sizeof(io->name), "%s", name.c_str()); } } } } Loading fs_mgr/libdm/dm_target.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -42,7 +42,7 @@ std::string DmTarget::Serialize() const { struct dm_target_spec* spec = reinterpret_cast<struct dm_target_spec*>(&data[0]); struct dm_target_spec* spec = reinterpret_cast<struct dm_target_spec*>(&data[0]); spec->sector_start = start(); spec->sector_start = start(); spec->length = size(); spec->length = size(); strlcpy(spec->target_type, name().c_str(), sizeof(spec->target_type)); snprintf(spec->target_type, sizeof(spec->target_type), "%s", name().c_str()); spec->next = (uint32_t)data.size(); spec->next = (uint32_t)data.size(); return data; return data; } } Loading Loading
fs_mgr/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -92,6 +92,7 @@ cc_library_static { name: "libfstab", name: "libfstab", vendor_available: true, vendor_available: true, recovery_available: true, recovery_available: true, host_supported: true, defaults: ["fs_mgr_defaults"], defaults: ["fs_mgr_defaults"], srcs: [ srcs: [ "fs_mgr_fstab.cpp", "fs_mgr_fstab.cpp", Loading
fs_mgr/fs_mgr_fstab.cpp +10 −29 Original line number Original line Diff line number Diff line Loading @@ -209,17 +209,12 @@ static bool read_dt_file(const std::string& file_name, std::string* dt_value) } } static uint64_t parse_flags(char* flags, struct flag_list* fl, struct fs_mgr_flag_values* flag_vals, static uint64_t parse_flags(char* flags, struct flag_list* fl, struct fs_mgr_flag_values* flag_vals, char* fs_options, int fs_options_len) { std::string* fs_options) { uint64_t f = 0; uint64_t f = 0; int i; int i; char *p; char *p; char *savep; char *savep; /* initialize fs_options to the null string */ if (fs_options && (fs_options_len > 0)) { fs_options[0] = '\0'; } p = strtok_r(flags, ",", &savep); p = strtok_r(flags, ",", &savep); while (p) { while (p) { /* Look for the flag "p" in the flag list "fl" /* Look for the flag "p" in the flag list "fl" Loading Loading @@ -356,26 +351,20 @@ static uint64_t parse_flags(char* flags, struct flag_list* fl, struct fs_mgr_fla if (!fl[i].name) { if (!fl[i].name) { if (fs_options) { if (fs_options) { /* It's not a known flag, so it must be a filesystem specific // It's not a known flag, so it must be a filesystem specific * option. Add it to fs_options if it was passed in. // option. Add it to fs_options if it was passed in. */ if (!fs_options->empty()) { strlcat(fs_options, p, fs_options_len); fs_options->append(","); // appends a comma if not the first strlcat(fs_options, ",", fs_options_len); } fs_options->append(p); } else { } else { /* fs_options was not passed in, so if the flag is unknown // fs_options was not passed in, so if the flag is unknown it's an error. * it's an error. */ LERROR << "Warning: unknown flag " << p; LERROR << "Warning: unknown flag " << p; } } } } p = strtok_r(NULL, ",", &savep); p = strtok_r(NULL, ",", &savep); } } if (fs_options && fs_options[0]) { /* remove the last trailing comma from the list of options */ fs_options[strlen(fs_options) - 1] = '\0'; } return f; return f; } } Loading Loading @@ -513,8 +502,6 @@ static bool fs_mgr_read_fstab_file(FILE* fstab_file, bool proc_mounts, Fstab* fs char *save_ptr, *p; char *save_ptr, *p; Fstab fstab; Fstab fstab; struct fs_mgr_flag_values flag_vals; struct fs_mgr_flag_values flag_vals; #define FS_OPTIONS_LEN 1024 char tmp_fs_options[FS_OPTIONS_LEN]; while ((len = getline(&line, &alloc_len, fstab_file)) != -1) { while ((len = getline(&line, &alloc_len, fstab_file)) != -1) { /* if the last character is a newline, shorten the string by 1 byte */ /* if the last character is a newline, shorten the string by 1 byte */ Loading Loading @@ -555,13 +542,7 @@ static bool fs_mgr_read_fstab_file(FILE* fstab_file, bool proc_mounts, Fstab* fs LERROR << "Error parsing mount_flags"; LERROR << "Error parsing mount_flags"; goto err; goto err; } } tmp_fs_options[0] = '\0'; entry.flags = parse_flags(p, mount_flags, nullptr, &entry.fs_options); entry.flags = parse_flags(p, mount_flags, NULL, tmp_fs_options, FS_OPTIONS_LEN); /* fs_options are optional */ if (tmp_fs_options[0]) { entry.fs_options = tmp_fs_options; } // For /proc/mounts, ignore everything after mnt_freq and mnt_passno // For /proc/mounts, ignore everything after mnt_freq and mnt_passno if (proc_mounts) { if (proc_mounts) { Loading @@ -570,7 +551,7 @@ static bool fs_mgr_read_fstab_file(FILE* fstab_file, bool proc_mounts, Fstab* fs LERROR << "Error parsing fs_mgr_options"; LERROR << "Error parsing fs_mgr_options"; goto err; goto err; } } entry.fs_mgr_flags.val = parse_flags(p, fs_mgr_flags, &flag_vals, NULL, 0); entry.fs_mgr_flags.val = parse_flags(p, fs_mgr_flags, &flag_vals, nullptr); entry.key_loc = std::move(flag_vals.key_loc); entry.key_loc = std::move(flag_vals.key_loc); entry.key_dir = std::move(flag_vals.key_dir); entry.key_dir = std::move(flag_vals.key_dir); Loading
fs_mgr/libdm/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -18,6 +18,7 @@ cc_library_static { name: "libdm", name: "libdm", defaults: ["fs_mgr_defaults"], defaults: ["fs_mgr_defaults"], recovery_available: true, recovery_available: true, host_supported: true, export_include_dirs: ["include"], export_include_dirs: ["include"], Loading
fs_mgr/libdm/dm.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -349,7 +349,7 @@ void DeviceMapper::InitIo(struct dm_ioctl* io, const std::string& name) const { io->data_size = sizeof(*io); io->data_size = sizeof(*io); io->data_start = 0; io->data_start = 0; if (!name.empty()) { if (!name.empty()) { strlcpy(io->name, name.c_str(), sizeof(io->name)); snprintf(io->name, sizeof(io->name), "%s", name.c_str()); } } } } Loading
fs_mgr/libdm/dm_target.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -42,7 +42,7 @@ std::string DmTarget::Serialize() const { struct dm_target_spec* spec = reinterpret_cast<struct dm_target_spec*>(&data[0]); struct dm_target_spec* spec = reinterpret_cast<struct dm_target_spec*>(&data[0]); spec->sector_start = start(); spec->sector_start = start(); spec->length = size(); spec->length = size(); strlcpy(spec->target_type, name().c_str(), sizeof(spec->target_type)); snprintf(spec->target_type, sizeof(spec->target_type), "%s", name().c_str()); spec->next = (uint32_t)data.size(); spec->next = (uint32_t)data.size(); return data; return data; } } Loading