X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=direct%2Fyaffsfs.c;h=b57084cb5805ca6b675d9a8287e4a69ece20ef75;hp=290bcf7ecdade668275c0a4565f20c57813cf09a;hb=ce0a5fb9849b6dc0d1347709b28d3a34eefec662;hpb=fc4028b21ae665f45c149e66b10d13374721383c diff --git a/direct/yaffsfs.c b/direct/yaffsfs.c index 290bcf7..b57084c 100644 --- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -124,7 +124,7 @@ static void yaffsfs_InitHandles(void) static yaffsfs_Handle *yaffsfs_HandleToPointer(int h) { - if(h >= 0 && h <= YAFFSFS_N_HANDLES) + if(h >= 0 && h < YAFFSFS_N_HANDLES) return &yaffsfs_handle[h]; return NULL; } @@ -743,7 +743,15 @@ int yaffs_dup(int handle) } +static int yaffsfs_TooManyObjects(struct yaffs_dev *dev) +{ + int current_objects = dev->n_obj - dev->n_deleted_files; + if(dev->param.max_objects && current_objects > dev->param.max_objects) + return 1; + else + return 0; +} int yaffs_open_sharing(const YCHAR *path, int oflag, int mode, int sharing) { @@ -915,6 +923,9 @@ int yaffs_open_sharing(const YCHAR *path, int oflag, int mode, int sharing) if(dir->my_dev->read_only){ yaffsfs_SetError(-EROFS); errorReported = 1; + } else if(yaffsfs_TooManyObjects(dir->my_dev)) { + yaffsfs_SetError(-ENFILE); + errorReported = 1; } else obj = yaffs_create_file(dir,name,mode,0,0); @@ -2366,6 +2377,8 @@ int yaffs_mkdir(const YCHAR *path, mode_t mode) yaffsfs_SetError(-ELOOP); else if(!parent) yaffsfs_SetError(-ENOENT); + else if(yaffsfs_TooManyObjects(parent->my_dev)) + yaffsfs_SetError(-ENFILE); else if(strnlen(name,5) == 0){ /* Trying to make the root itself */ yaffsfs_SetError(-EEXIST); @@ -2425,7 +2438,7 @@ void * yaffs_getdev(const YCHAR *path) return (void *)dev; } -int yaffs_mount2(const YCHAR *path,int read_only) +int yaffs_mount_common(const YCHAR *path,int read_only, int skip_checkpt) { int retVal=-1; int result=YAFFS_FAIL; @@ -2451,7 +2464,15 @@ int yaffs_mount2(const YCHAR *path,int read_only) if(dev){ if(!dev->is_mounted){ dev->read_only = read_only ? 1 : 0; - result = yaffs_guts_initialise(dev); + if(skip_checkpt) { + u8 skip = dev->param.skip_checkpt_rd; + dev->param.skip_checkpt_rd = 1; + result = yaffs_guts_initialise(dev); + dev->param.skip_checkpt_rd = skip; + } else { + result = yaffs_guts_initialise(dev); + } + if(result == YAFFS_FAIL) yaffsfs_SetError(-ENOMEM); retVal = result ? 0 : -1; @@ -2467,9 +2488,13 @@ int yaffs_mount2(const YCHAR *path,int read_only) } +int yaffs_mount2(const YCHAR *path, int readonly) +{ + return yaffs_mount_common(path, readonly, 0); +} int yaffs_mount(const YCHAR *path) { - return yaffs_mount2(path,0); + return yaffs_mount_common(path, 0, 0); } int yaffs_sync(const YCHAR *path) @@ -2707,6 +2732,14 @@ int yaffs_inodecount(const YCHAR *path) void yaffs_add_device(struct yaffs_dev *dev) { + struct list_head *cfg; + /* First check that the device is not in the list. */ + + list_for_each(cfg, &yaffsfs_deviceList){ + if(dev == list_entry(cfg, struct yaffs_dev, dev_list)) + return; + } + dev->is_mounted = 0; dev->param.remove_obj_fn = yaffsfs_RemoveObjectCallback; @@ -2964,6 +2997,8 @@ int yaffs_symlink(const YCHAR *oldpath, const YCHAR *newpath) yaffsfs_SetError(-ELOOP); else if( !parent || strnlen(name,5) < 1) yaffsfs_SetError(-ENOENT); + else if(yaffsfs_TooManyObjects(parent->my_dev)) + yaffsfs_SetError(-ENFILE); else if(parent->my_dev->read_only) yaffsfs_SetError(-EROFS); else if(parent){ @@ -3056,6 +3091,8 @@ int yaffs_link(const YCHAR *oldpath, const YCHAR *linkpath) yaffsfs_SetError(-ENOENT); else if(obj->my_dev->read_only) yaffsfs_SetError(-EROFS); + else if(yaffsfs_TooManyObjects(obj->my_dev)) + yaffsfs_SetError(-ENFILE); else if(lnk) yaffsfs_SetError(-EEXIST); else if(lnk_dir->my_dev != obj->my_dev)