/* * linux/fs/hfs/dir.c * * Copyright (C) 1995-1997 Paul H. Hargrove * (C) 2003 Ardis Technologies <roman@ardistech.com> * This file may be distributed under the terms of the GNU General Public License. * * This file contains directory-related functions independent of which * scheme is being used to represent forks. * * Based on the minix file system code, (C) 1991, 1992 by Linus Torvalds
*/
/* * hfs_create() * * This is the create() entry in the inode_operations structure for * regular HFS directories. The purpose is to create a new file in * a directory and return a corresponding inode, given the inode for * the directory and the name (and its length) of the new file.
*/ staticint hfs_create(struct mnt_idmap *idmap, struct inode *dir, struct dentry *dentry, umode_t mode, bool excl)
{ struct inode *inode; int res;
inode = hfs_new_inode(dir, &dentry->d_name, mode); if (!inode) return -ENOMEM;
/* * hfs_mkdir() * * This is the mkdir() entry in the inode_operations structure for * regular HFS directories. The purpose is to create a new directory * in a directory, given the inode for the parent directory and the * name (and its length) of the new directory.
*/ staticstruct dentry *hfs_mkdir(struct mnt_idmap *idmap, struct inode *dir, struct dentry *dentry, umode_t mode)
{ struct inode *inode; int res;
/* * hfs_remove() * * This serves as both unlink() and rmdir() in the inode_operations * structure for regular HFS directories. The purpose is to delete * an existing child, given the inode for the parent directory and * the name (and its length) of the existing directory. * * HFS does not have hardlinks, so both rmdir and unlink set the * link count to 0. The only difference is the emptiness check.
*/ staticint hfs_remove(struct inode *dir, struct dentry *dentry)
{ struct inode *inode = d_inode(dentry); int res;
if (S_ISDIR(inode->i_mode) && inode->i_size != 2) return -ENOTEMPTY;
res = hfs_cat_delete(inode->i_ino, dir, &dentry->d_name); if (res) return res;
clear_nlink(inode);
inode_set_ctime_current(inode);
hfs_delete_inode(inode);
mark_inode_dirty(inode); return 0;
}
/* * hfs_rename() * * This is the rename() entry in the inode_operations structure for * regular HFS directories. The purpose is to rename an existing * file or directory, given the inode for the current directory and * the name (and its length) of the existing file/directory and the * inode for the new directory and the name (and its length) of the * new file/directory. * XXX: how do you handle must_be dir?
*/ staticint hfs_rename(struct mnt_idmap *idmap, struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry, unsignedint flags)
{ int res;
if (flags & ~RENAME_NOREPLACE) return -EINVAL;
/* Unlink destination if it already exists */ if (d_really_is_positive(new_dentry)) {
res = hfs_remove(new_dir, new_dentry); if (res) return res;
}
res = hfs_cat_move(d_inode(old_dentry)->i_ino,
old_dir, &old_dentry->d_name,
new_dir, &new_dentry->d_name); if (!res)
hfs_cat_build_key(old_dir->i_sb,
(btree_key *)&HFS_I(d_inode(old_dentry))->cat_key,
new_dir->i_ino, &new_dentry->d_name); return res;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.