// SPDX-License-Identifier: GPL-2.0+ /* * NILFS directory entry operations * * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. * * Modified for NILFS by Amagai Yoshiji. */ /* * linux/fs/ext2/dir.c * * Copyright (C) 1992, 1993, 1994, 1995 * Remy Card ([email protected]) * Laboratoire MASI - Institut Blaise Pascal * Universite Pierre et Marie Curie (Paris VI) * * from * * linux/fs/minix/dir.c * * Copyright (C) 1991, 1992 Linus Torvalds * * ext2 directory handling functions * * Big-endian to little-endian byte-swapping/bitmaps by * David S. Miller ([email protected]), 1995 * * All code that works with directory layout had been switched to pagecache * and moved here. AV */ #include <linux/pagemap.h> #include "nilfs.h" #include "page.h" static inline unsigned int nilfs_rec_len_from_disk(__le16 dlen) { … } static inline __le16 nilfs_rec_len_to_disk(unsigned int len) { … } /* * nilfs uses block-sized chunks. Arguably, sector-sized ones would be * more robust, but we have what we have */ static inline unsigned int nilfs_chunk_size(struct inode *inode) { … } /* * Return the offset into page `page_nr' of the last valid * byte in that page, plus one. */ static unsigned int nilfs_last_byte(struct inode *inode, unsigned long page_nr) { … } static int nilfs_prepare_chunk(struct folio *folio, unsigned int from, unsigned int to) { … } static void nilfs_commit_chunk(struct folio *folio, struct address_space *mapping, size_t from, size_t to) { … } static bool nilfs_check_folio(struct folio *folio, char *kaddr) { … } static void *nilfs_get_folio(struct inode *dir, unsigned long n, struct folio **foliop) { … } /* * NOTE! unlike strncmp, nilfs_match returns 1 for success, 0 for failure. * * len <= NILFS_NAME_LEN and de != NULL are guaranteed by caller. */ static int nilfs_match(int len, const unsigned char *name, struct nilfs_dir_entry *de) { … } /* * p is at least 6 bytes before the end of page */ static struct nilfs_dir_entry *nilfs_next_entry(struct nilfs_dir_entry *p) { … } static int nilfs_readdir(struct file *file, struct dir_context *ctx) { … } /* * nilfs_find_entry() * * Finds an entry in the specified directory with the wanted name. It * returns the folio in which the entry was found, and the entry itself. * The folio is mapped and unlocked. When the caller is finished with * the entry, it should call folio_release_kmap(). * * On failure, returns an error pointer and the caller should ignore foliop. */ struct nilfs_dir_entry *nilfs_find_entry(struct inode *dir, const struct qstr *qstr, struct folio **foliop) { … } struct nilfs_dir_entry *nilfs_dotdot(struct inode *dir, struct folio **foliop) { … } int nilfs_inode_by_name(struct inode *dir, const struct qstr *qstr, ino_t *ino) { … } void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de, struct folio *folio, struct inode *inode) { … } /* * Parent is locked. */ int nilfs_add_link(struct dentry *dentry, struct inode *inode) { … } /* * nilfs_delete_entry deletes a directory entry by merging it with the * previous entry. Folio is up-to-date. */ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct folio *folio) { … } /* * Set the first fragment of directory. */ int nilfs_make_empty(struct inode *inode, struct inode *parent) { … } /* * routine to check that the specified directory is empty (for rmdir) */ int nilfs_empty_dir(struct inode *inode) { … } const struct file_operations nilfs_dir_operations = …;