aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/drivers/ubd_kern.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/drivers/ubd_kern.c')
-rw-r--r--arch/um/drivers/ubd_kern.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index c171d0aa5e9d..101efd26d467 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -1194,15 +1194,16 @@ int open_ubd_file(char *file, struct openflags *openflags,
1194 int fd, err, sectorsize, asked_switch, mode = 0644; 1194 int fd, err, sectorsize, asked_switch, mode = 0644;
1195 1195
1196 fd = os_open_file(file, *openflags, mode); 1196 fd = os_open_file(file, *openflags, mode);
1197 if(fd < 0){ 1197 if (fd < 0) {
1198 if((fd == -ENOENT) && (create_cow_out != NULL)) 1198 if ((fd == -ENOENT) && (create_cow_out != NULL))
1199 *create_cow_out = 1; 1199 *create_cow_out = 1;
1200 if(!openflags->w || 1200 if (!openflags->w ||
1201 ((fd != -EROFS) && (fd != -EACCES))) return(fd); 1201 ((fd != -EROFS) && (fd != -EACCES)))
1202 return fd;
1202 openflags->w = 0; 1203 openflags->w = 0;
1203 fd = os_open_file(file, *openflags, mode); 1204 fd = os_open_file(file, *openflags, mode);
1204 if(fd < 0) 1205 if (fd < 0)
1205 return(fd); 1206 return fd;
1206 } 1207 }
1207 1208
1208 err = os_lock_file(fd, openflags->w); 1209 err = os_lock_file(fd, openflags->w);
@@ -1212,7 +1213,8 @@ int open_ubd_file(char *file, struct openflags *openflags,
1212 } 1213 }
1213 1214
1214 /* Succesful return case! */ 1215 /* Succesful return case! */
1215 if(backing_file_out == NULL) return(fd); 1216 if(backing_file_out == NULL)
1217 return(fd);
1216 1218
1217 err = read_cow_header(file_reader, &fd, &version, &backing_file, &mtime, 1219 err = read_cow_header(file_reader, &fd, &version, &backing_file, &mtime,
1218 &size, &sectorsize, &align, bitmap_offset_out); 1220 &size, &sectorsize, &align, bitmap_offset_out);
@@ -1221,7 +1223,8 @@ int open_ubd_file(char *file, struct openflags *openflags,
1221 "errno = %d\n", file, -err); 1223 "errno = %d\n", file, -err);
1222 goto out_close; 1224 goto out_close;
1223 } 1225 }
1224 if(err) return(fd); 1226 if(err)
1227 return(fd);
1225 1228
1226 asked_switch = path_requires_switch(*backing_file_out, backing_file, file); 1229 asked_switch = path_requires_switch(*backing_file_out, backing_file, file);
1227 1230
@@ -1230,24 +1233,24 @@ int open_ubd_file(char *file, struct openflags *openflags,
1230 printk("Switching backing file to '%s'\n", *backing_file_out); 1233 printk("Switching backing file to '%s'\n", *backing_file_out);
1231 err = write_cow_header(file, fd, *backing_file_out, 1234 err = write_cow_header(file, fd, *backing_file_out,
1232 sectorsize, align, &size); 1235 sectorsize, align, &size);
1233 if(err){ 1236 if (err) {
1234 printk("Switch failed, errno = %d\n", -err); 1237 printk("Switch failed, errno = %d\n", -err);
1235 goto out_close; 1238 goto out_close;
1236 } 1239 }
1237 } 1240 } else {
1238 else {
1239 *backing_file_out = backing_file; 1241 *backing_file_out = backing_file;
1240 err = backing_file_mismatch(*backing_file_out, size, mtime); 1242 err = backing_file_mismatch(*backing_file_out, size, mtime);
1241 if(err) goto out_close; 1243 if (err)
1244 goto out_close;
1242 } 1245 }
1243 1246
1244 cow_sizes(version, size, sectorsize, align, *bitmap_offset_out, 1247 cow_sizes(version, size, sectorsize, align, *bitmap_offset_out,
1245 bitmap_len_out, data_offset_out); 1248 bitmap_len_out, data_offset_out);
1246 1249
1247 return(fd); 1250 return fd;
1248 out_close: 1251 out_close:
1249 os_close_file(fd); 1252 os_close_file(fd);
1250 return(err); 1253 return err;
1251} 1254}
1252 1255
1253int create_cow_file(char *cow_file, char *backing_file, struct openflags flags, 1256int create_cow_file(char *cow_file, char *backing_file, struct openflags flags,