/*
* YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
*
- * Copyright (C) 2002-2010 Aleph One Ltd.
+ * Copyright (C) 2002-2011 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering
*
* Created by Charles Manning <charles@aleph1.co.uk>
struct yaffs_obj *obj = NULL;
struct yaffs_dev *dev;
struct yaffs_obj *parent = yaffs_inode_to_obj(dir);
- int error = -ENOSPC;
+ int error;
uid_t uid = current->cred->fsuid;
gid_t gid =
(dir->i_mode & S_ISGID) ? dir->i_gid : current->cred->fsgid;
yaffs_gross_lock(dev);
+ if (yaffs_get_n_free_chunks(dev) < 1) {
+ error = -ENOSPC;
+ goto err_out;
+ }
+
switch (mode & S_IFMT) {
default:
/* Special (socket, fifo, device...) */
break;
}
+ if (!obj) {
+ error = -ENOMEM;
+ goto err_out;
+ }
+
/* Can not call yaffs_get_inode() with gross lock held */
yaffs_gross_unlock(dev);
- if (!obj) {
- yaffs_trace(YAFFS_TRACE_OS, "yaffs_mknod failed making object");
- return -ENOMEM;
- }
inode = yaffs_get_inode(dir->i_sb, mode, rdev, obj);
d_instantiate(dentry, inode);
"yaffs_mknod created object %d count = %d",
obj->obj_id, atomic_read(&inode->i_count));
yaffs_fill_inode_from_obj(dir, parent);
-
return 0;
+
+err_out:
+ yaffs_gross_unlock(dev);
+ yaffs_trace(YAFFS_TRACE_OS, "yaffs_mknod error %d", error);
+ return error;
+
}
static int yaffs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
static void yaffs_fill_inode_from_obj(struct inode *inode,
struct yaffs_obj *obj)
{
+ u32 mode;
+
if (!inode || !obj) {
yaffs_trace(YAFFS_TRACE_OS,
"yaffs_fill_inode invalid parameters");
/* Check mode against the variant type
* and attempt to repair if broken. */
- u32 mode = obj->yst_mode;
+ mode = obj->yst_mode;
switch (obj->variant_type) {
case YAFFS_OBJECT_TYPE_FILE:
module_exit(exit_yaffs_fs)
MODULE_DESCRIPTION("YAFFS2 - a NAND specific flash file system");
-MODULE_AUTHOR("Charles Manning, Aleph One Ltd., 2002-2010");
+MODULE_AUTHOR("Charles Manning, Aleph One Ltd., 2002-2011");
MODULE_LICENSE("GPL");