Lines Matching refs:fstab
84 static int AddToFstab(Fstab *fstab, FstabItem *item)
86 if (fstab == NULL || item == NULL) {
89 if (fstab->tail == NULL) {
90 fstab->head = fstab->tail = item;
92 fstab->tail->next = item;
93 fstab->tail = item;
125 void ReleaseFstab(Fstab *fstab)
127 if (fstab != NULL) {
128 FstabItem *item = fstab->head;
134 fstab->head = fstab->tail = NULL;
135 free(fstab);
136 fstab = NULL;
140 int ParseFstabPerLine(char *str, Fstab *fstab, bool procMounts, const char *separator)
142 BEGET_CHECK_RETURN_VALUE(str != NULL && fstab != NULL, -1);
146 BEGET_ERROR_CHECK(separator != NULL && *separator != '\0', return -1, "Invalid separator for parsing fstab");
175 // @fsManagerFlags only for fstab
182 return AddToFstab(fstab, item);
195 Fstab *fstab = NULL;
207 if ((fstab = (Fstab *)calloc(1, sizeof(Fstab))) == NULL) {
214 // Record line number of fstab file
231 if (ParseFstabPerLine(p, fstab, procMounts, " \t") < 0) {
236 // If one line in fstab file parsed with a failure. just give a warning
247 return fstab;
250 FstabItem *FindFstabItemForMountPoint(Fstab fstab, const char *mp)
254 for (item = fstab.head; item != NULL; item = item->next) {
263 FstabItem *FindFstabItemForPath(Fstab fstab, const char *path)
280 item = FindFstabItemForMountPoint(fstab, dir);
296 if (strncpy_s(fileName, size, "/etc/fstab.updater", strlen("/etc/fstab.updater")) != 0) {
307 if (snprintf_s(fileName, size, size - 1, "/vendor/etc/fstab.%s", hardware) == -1) {
308 BEGET_LOGE("Failed to build fstab file, err=%d", errno);
312 BEGET_LOGI("fstab file is %s", fileName);
316 int GetBlockDeviceByMountPoint(const char *mountPoint, const Fstab *fstab, char *deviceName, int nameLen)
318 if (fstab == NULL || mountPoint == NULL || *mountPoint == '\0' || deviceName == NULL) {
321 FstabItem *item = FindFstabItemForMountPoint(*fstab, mountPoint);
323 BEGET_LOGE("Failed to get fstab item from mount point \" %s \"", mountPoint);
333 int GetBlockDeviceByName(const char *deviceName, const Fstab *fstab, char* miscDev, size_t size)
335 for (FstabItem *item = fstab->head; item != NULL; item = item->next) {
461 // If the item configured in fstab contains flag over than 15,
503 Fstab *fstab = LoadFstabFromCommandLine();
504 if (fstab == NULL) {
505 BEGET_LOGI("fstab not found from cmdline, try to get it from file");
508 fstab = ReadFstabFromFile(fstabFile, false);
510 BEGET_CHECK_RETURN_VALUE(fstab != NULL, -1);
511 int ret = GetBlockDeviceByMountPoint(partName, fstab, path, size);
512 BEGET_INFO_CHECK(ret == 0, ret = GetBlockDeviceByName(partName, fstab, path, size),
514 ReleaseFstab(fstab);
521 * We separate them by spaces in fstab.required file, but the separator is '@' in CmdLine.
522 * The prefix "ohos.required_mount." is the flag of required fstab information in CmdLine.
524 * <block device>@<mount point>@<fstype>@<mount options>@<fstab options>
528 static int ParseRequiredMountInfo(const char *item, Fstab *fstab)
533 BEGET_CHECK(!(item == NULL || *item == '\0' || fstab == NULL), return -1);
546 if (ParseFstabPerLine(mountOptions, fstab, false, "@") < 0) {
555 Fstab *fstab = NULL;
561 fstab = (Fstab *)calloc(1, sizeof(Fstab));
562 BEGET_ERROR_CHECK(fstab != NULL, free(cmdline); return NULL,
584 if (ParseRequiredMountInfo(start, fstab) < 0) {
596 ParseRequiredMountInfo(start, fstab) < 0) {
603 ReleaseFstab(fstab);
604 fstab = NULL;
607 return fstab;