Merge "fs_mgr: pass sehandle to ext4 format routine"
This commit is contained in:
commit
58ea31cc90
2 changed files with 20 additions and 2 deletions
|
|
@ -10,7 +10,8 @@ common_static_libraries := \
|
||||||
libcrypto_utils_static \
|
libcrypto_utils_static \
|
||||||
libcrypto_static \
|
libcrypto_static \
|
||||||
libext4_utils_static \
|
libext4_utils_static \
|
||||||
libsquashfs_utils
|
libsquashfs_utils \
|
||||||
|
libselinux
|
||||||
|
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
LOCAL_CLANG := true
|
LOCAL_CLANG := true
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,11 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <cutils/partition_utils.h>
|
#include <cutils/partition_utils.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
|
|
||||||
|
#include <selinux/selinux.h>
|
||||||
|
#include <selinux/label.h>
|
||||||
|
#include <selinux/android.h>
|
||||||
|
|
||||||
#include "ext4_utils.h"
|
#include "ext4_utils.h"
|
||||||
#include "ext4.h"
|
#include "ext4.h"
|
||||||
#include "make_ext4fs.h"
|
#include "make_ext4fs.h"
|
||||||
|
|
@ -47,17 +52,29 @@ static int format_ext4(char *fs_blkdev, char *fs_mnt_point)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct selabel_handle *sehandle = selinux_android_file_context_handle();
|
||||||
|
if (!sehandle) {
|
||||||
|
/* libselinux logs specific error */
|
||||||
|
ERROR("Cannot initialize android file_contexts");
|
||||||
|
close(fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Format the partition using the calculated length */
|
/* Format the partition using the calculated length */
|
||||||
reset_ext4fs_info();
|
reset_ext4fs_info();
|
||||||
info.len = (off64_t)dev_sz;
|
info.len = (off64_t)dev_sz;
|
||||||
|
|
||||||
/* Use make_ext4fs_internal to avoid wiping an already-wiped partition. */
|
/* Use make_ext4fs_internal to avoid wiping an already-wiped partition. */
|
||||||
rc = make_ext4fs_internal(fd, NULL, NULL, fs_mnt_point, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL);
|
rc = make_ext4fs_internal(fd, NULL, NULL, fs_mnt_point, 0, 0, 0, 0, 0, 0, sehandle, 0, 0, NULL);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
ERROR("make_ext4fs returned %d.\n", rc);
|
ERROR("make_ext4fs returned %d.\n", rc);
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
|
if (sehandle) {
|
||||||
|
selabel_close(sehandle);
|
||||||
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue