struct dentry *hypfs_mkdir(struct dentry *parent, const char *name) { struct dentry *dentry; dentry = hypfs_create_file(parent, name, NULL, S_IFDIR | DIR_MODE); if (IS_ERR(dentry)) return dentry; hypfs_add_dentry(dentry); return dentry; }
struct dentry *hypfs_mkdir(struct super_block *sb, struct dentry *parent, const char *name) { struct dentry *dentry; dentry = hypfs_create_file(sb, parent, name, NULL, S_IFDIR | DIR_MODE); if (IS_ERR(dentry)) return dentry; hypfs_add_dentry(dentry); parent->d_inode->i_nlink++; return dentry; }
static struct dentry *hypfs_create_update_file(struct dentry *dir) { struct dentry *dentry; dentry = hypfs_create_file(dir, "update", NULL, S_IFREG | UPDATE_FILE_MODE); /* * We do not put the update file on the 'delete' list with * hypfs_add_dentry(), since it should not be removed when the tree * is updated. */ return dentry; }
struct dentry *hypfs_create_str(struct super_block *sb, struct dentry *dir, const char *name, char *string) { char *buffer; struct dentry *dentry; buffer = kmalloc(strlen(string) + 2, GFP_KERNEL); if (!buffer) return ERR_PTR(-ENOMEM); sprintf(buffer, "%s\n", string); dentry = hypfs_create_file(sb, dir, name, buffer, S_IFREG | REG_FILE_MODE); if (IS_ERR(dentry)) { kfree(buffer); return ERR_PTR(-ENOMEM); } hypfs_add_dentry(dentry); return dentry; }
struct dentry *hypfs_create_u64(struct super_block *sb, struct dentry *dir, const char *name, __u64 value) { char *buffer; char tmp[TMP_SIZE]; struct dentry *dentry; snprintf(tmp, TMP_SIZE, "%llu\n", (unsigned long long int)value); buffer = kstrdup(tmp, GFP_KERNEL); if (!buffer) return ERR_PTR(-ENOMEM); dentry = hypfs_create_file(sb, dir, name, buffer, S_IFREG | REG_FILE_MODE); if (IS_ERR(dentry)) { kfree(buffer); return ERR_PTR(-ENOMEM); } hypfs_add_dentry(dentry); return dentry; }