blob: d13bbc93b0ef826b0c0655b5a719bcb1f3dce1ac [file] [log] [blame]
Tom Marshallbead2612019-01-04 14:37:31 -08001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 * Copyright (C) 2019 The LineageOS 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#include <errno.h>
19#include <stdio.h>
20#include <string.h>
21
22#define LOG_TAG "Vold"
23
24#include <cutils/log.h>
25
26#include "ResponseCode.h"
27
28int ResponseCode::convertFromErrno() {
29 if (errno == ENODEV) {
30 return (ResponseCode::OpFailedNoMedia);
31 } else if (errno == ENODATA) {
32 return (ResponseCode::OpFailedMediaBlank);
33 } else if (errno == EIO) {
34 return (ResponseCode::OpFailedMediaCorrupt);
35 } else if (errno == EBUSY) {
36 return (ResponseCode::OpFailedStorageBusy);
37 } else if (errno == ENOENT) {
38 return (ResponseCode::OpFailedStorageNotFound);
39 }
40
41 SLOGW("Returning OperationFailed - no handler for errno %d", errno);
42 return (ResponseCode::OperationFailed);
43}