| 
									
										
										
										
											2016-04-09 01:37:38 +08:00
										 |  |  | /* | 
					
						
							| 
									
										
										
										
											2020-06-13 11:04:01 +08:00
										 |  |  |  * MinIO Cloud Storage, (C) 2015-2020 MinIO, Inc. | 
					
						
							| 
									
										
										
										
											2016-04-09 01:37:38 +08:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
					
						
							|  |  |  |  * you may not use this file except in compliance with the License. | 
					
						
							|  |  |  |  * You may obtain a copy of the License at | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *     http://www.apache.org/licenses/LICENSE-2.0
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Unless required by applicable law or agreed to in writing, software | 
					
						
							|  |  |  |  * distributed under the License is distributed on an "AS IS" BASIS, | 
					
						
							|  |  |  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
					
						
							|  |  |  |  * See the License for the specific language governing permissions and | 
					
						
							|  |  |  |  * limitations under the License. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-19 07:23:42 +08:00
										 |  |  | package cmd | 
					
						
							| 
									
										
										
										
											2016-04-09 01:37:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-13 11:04:01 +08:00
										 |  |  | import "os" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-29 06:13:15 +08:00
										 |  |  | // errUnexpected - unexpected error, requires manual intervention.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errUnexpected = StorageErr("Unexpected error, please report this issue at https://github.com/minio/minio/issues") | 
					
						
							| 
									
										
										
										
											2016-05-29 06:13:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-20 17:22:22 +08:00
										 |  |  | // errCorruptedFormat - corrupted backend format.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errCorruptedFormat = StorageErr("corrupted backend format, please join https://slack.min.io for assistance") | 
					
						
							| 
									
										
										
										
											2016-05-20 17:22:22 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // errUnformattedDisk - unformatted disk found.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errUnformattedDisk = StorageErr("unformatted disk found") | 
					
						
							| 
									
										
										
										
											2016-05-20 17:22:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-08 07:12:16 +08:00
										 |  |  | // errUnsupporteDisk - when disk does not support O_DIRECT flag.
 | 
					
						
							|  |  |  | var errUnsupportedDisk = StorageErr("disk does not support O_DIRECT") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-19 17:42:10 +08:00
										 |  |  | // errDiskFull - cannot create volume or files when disk is full.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errDiskFull = StorageErr("disk path full") | 
					
						
							| 
									
										
										
										
											2016-04-09 01:37:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-13 11:04:01 +08:00
										 |  |  | // errDiskNotDir - cannot use storage disk if its not a directory
 | 
					
						
							|  |  |  | var errDiskNotDir = StorageErr("disk is not directory or mountpoint") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-12 02:38:46 +08:00
										 |  |  | // errDiskNotFound - cannot find the underlying configured disk anymore.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errDiskNotFound = StorageErr("disk not found") | 
					
						
							| 
									
										
										
										
											2016-05-10 09:57:39 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-21 08:57:12 +08:00
										 |  |  | // errFaultyRemoteDisk - remote disk is faulty.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errFaultyRemoteDisk = StorageErr("remote disk is faulty") | 
					
						
							| 
									
										
										
										
											2016-11-21 08:57:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // errFaultyDisk - disk is faulty.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errFaultyDisk = StorageErr("disk is faulty") | 
					
						
							| 
									
										
										
										
											2016-11-21 08:57:12 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-02 16:59:28 +08:00
										 |  |  | // errDiskAccessDenied - we don't have write permissions on disk.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errDiskAccessDenied = StorageErr("disk access denied") | 
					
						
							| 
									
										
										
										
											2016-07-02 16:59:28 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-09 01:37:38 +08:00
										 |  |  | // errFileNotFound - cannot find the file.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errFileNotFound = StorageErr("file not found") | 
					
						
							| 
									
										
										
										
											2016-04-09 01:37:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-13 11:04:01 +08:00
										 |  |  | // errFileNotFound - cannot find requested file version.
 | 
					
						
							|  |  |  | var errFileVersionNotFound = StorageErr("file version not found") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-02 22:09:57 +08:00
										 |  |  | // errTooManyOpenFiles - too many open files.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errTooManyOpenFiles = StorageErr("too many open files") | 
					
						
							| 
									
										
										
										
											2019-05-02 22:09:57 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-12 03:55:02 +08:00
										 |  |  | // errFileNameTooLong - given file name is too long than supported length.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errFileNameTooLong = StorageErr("file name too long") | 
					
						
							| 
									
										
										
										
											2016-05-12 03:55:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-09 01:37:38 +08:00
										 |  |  | // errVolumeExists - cannot create same volume again.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errVolumeExists = StorageErr("volume already exists") | 
					
						
							| 
									
										
										
										
											2016-04-09 01:37:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-24 15:36:00 +08:00
										 |  |  | // errIsNotRegular - not of regular file type.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errIsNotRegular = StorageErr("not of regular file type") | 
					
						
							| 
									
										
										
										
											2016-04-09 01:37:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // errVolumeNotFound - cannot find the volume.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errVolumeNotFound = StorageErr("volume not found") | 
					
						
							| 
									
										
										
										
											2016-04-14 02:32:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-17 03:48:41 +08:00
										 |  |  | // errVolumeNotEmpty - volume not empty.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errVolumeNotEmpty = StorageErr("volume is not empty") | 
					
						
							| 
									
										
										
										
											2016-04-17 03:48:41 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-03 07:34:15 +08:00
										 |  |  | // errVolumeAccessDenied - cannot access volume, insufficient permissions.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errVolumeAccessDenied = StorageErr("volume access denied") | 
					
						
							| 
									
										
										
										
											2016-04-14 02:32:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-21 04:06:53 +08:00
										 |  |  | // errFileAccessDenied - cannot access file, insufficient permissions.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errFileAccessDenied = StorageErr("file access denied") | 
					
						
							| 
									
										
										
										
											2017-05-17 05:21:52 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-02 04:12:15 +08:00
										 |  |  | // errFileCorrupt - file has an unexpected size, or is not readable
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errFileCorrupt = StorageErr("file is corrupted") | 
					
						
							| 
									
										
										
										
											2019-07-13 07:29:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-21 04:06:53 +08:00
										 |  |  | // errFileParentIsFile - cannot have overlapping objects, parent is already a file.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errFileParentIsFile = StorageErr("parent is a file") | 
					
						
							| 
									
										
										
										
											2019-03-21 04:06:53 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-17 05:21:52 +08:00
										 |  |  | // errBitrotHashAlgoInvalid - the algo for bit-rot hash
 | 
					
						
							|  |  |  | // verification is empty or invalid.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errBitrotHashAlgoInvalid = StorageErr("bit-rot hash algorithm is invalid") | 
					
						
							| 
									
										
										
										
											2017-05-17 05:21:52 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-16 06:10:50 +08:00
										 |  |  | // errCrossDeviceLink - rename across devices not allowed.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errCrossDeviceLink = StorageErr("Rename across devices not allowed, please fix your backend configuration") | 
					
						
							| 
									
										
										
										
											2017-08-16 06:10:50 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-29 03:01:05 +08:00
										 |  |  | // errMinDiskSize - cannot create volume or files when disk size is less than threshold.
 | 
					
						
							| 
									
										
										
										
											2020-05-08 07:12:16 +08:00
										 |  |  | var errMinDiskSize = StorageErr("The disk size is less than 900MiB threshold") | 
					
						
							| 
									
										
										
										
											2018-06-29 03:01:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-07 06:14:08 +08:00
										 |  |  | // errLessData - returned when less data available than what was requested.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errLessData = StorageErr("less data available than what was requested") | 
					
						
							| 
									
										
										
										
											2018-08-07 06:14:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-17 20:58:18 +08:00
										 |  |  | // errMoreData = returned when more data was sent by the caller than what it was supposed to.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | var errMoreData = StorageErr("more data was sent than what was advertised") | 
					
						
							| 
									
										
										
										
											2019-01-17 20:58:18 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-13 11:04:01 +08:00
										 |  |  | // StorageErr represents error generated by xlStorage call.
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | type StorageErr string | 
					
						
							| 
									
										
										
										
											2017-05-17 05:21:52 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-15 10:45:17 +08:00
										 |  |  | func (h StorageErr) Error() string { | 
					
						
							| 
									
										
										
										
											2019-10-02 04:12:15 +08:00
										 |  |  | 	return string(h) | 
					
						
							| 
									
										
										
										
											2017-05-17 05:21:52 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-11-26 03:58:29 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Collection of basic errors.
 | 
					
						
							|  |  |  | var baseErrs = []error{ | 
					
						
							|  |  |  | 	errDiskNotFound, | 
					
						
							|  |  |  | 	errFaultyDisk, | 
					
						
							|  |  |  | 	errFaultyRemoteDisk, | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var baseIgnoredErrs = baseErrs | 
					
						
							| 
									
										
										
										
											2020-06-13 11:04:01 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Is a one place function which converts all os.PathError
 | 
					
						
							|  |  |  | // into a more FS object layer friendly form, converts
 | 
					
						
							|  |  |  | // known errors into their typed form for top level
 | 
					
						
							|  |  |  | // interpretation.
 | 
					
						
							|  |  |  | func osErrToFileErr(err error) error { | 
					
						
							|  |  |  | 	if err == nil { | 
					
						
							|  |  |  | 		return nil | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if os.IsNotExist(err) { | 
					
						
							|  |  |  | 		return errFileNotFound | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if os.IsPermission(err) { | 
					
						
							|  |  |  | 		return errFileAccessDenied | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if isSysErrNotDir(err) { | 
					
						
							|  |  |  | 		return errFileNotFound | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if isSysErrPathNotFound(err) { | 
					
						
							|  |  |  | 		return errFileNotFound | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if isSysErrTooManyFiles(err) { | 
					
						
							|  |  |  | 		return errTooManyOpenFiles | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if isSysErrHandleInvalid(err) { | 
					
						
							|  |  |  | 		return errFileNotFound | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return err | 
					
						
							|  |  |  | } |