24 .readdir = minix_readdir,
28 static inline void dir_put_page(
struct page *
page)
39 minix_last_byte(
struct inode *
inode,
unsigned long page_nr)
48 static inline unsigned long dir_pages(
struct inode *inode)
53 static int dir_commit_chunk(
struct page *
page, loff_t
pos,
unsigned len)
56 struct inode *
dir = mapping->
host;
60 if (pos+len > dir->
i_size) {
61 i_size_write(dir, pos+len);
62 mark_inode_dirty(dir);
71 static struct page * dir_get_page(
struct inode *dir,
unsigned long n)
74 struct page *page = read_mapping_page(mapping, n,
NULL);
80 static inline void *minix_next_entry(
void *de,
struct minix_sb_info *sbi)
82 return (
void*)((
char*)de + sbi->
s_dirsize);
87 unsigned long pos = filp->
f_pos;
88 struct inode *inode = filp->
f_path.dentry->d_inode;
92 unsigned long npages = dir_pages(inode);
98 pos = (pos + chunk_size-1) & ~(chunk_size-1);
102 for ( ; n < npages; n++, offset = 0) {
104 struct page *page = dir_get_page(inode, n);
110 limit = kaddr + minix_last_byte(inode, n) - chunk_size;
111 for ( ; p <=
limit; p = minix_next_entry(p, sbi)) {
115 inumber = de3->
inode;
126 over = filldir(dirent, name, l,
127 (n << PAGE_CACHE_SHIFT) | offset,
143 static inline int namecompare(
int len,
int maxlen,
144 const char * name,
const char *
buffer)
146 if (len < maxlen && buffer[len])
148 return !
memcmp(name, buffer, len);
161 const char * name = dentry->
d_name.name;
163 struct inode * dir = dentry->
d_parent->d_inode;
167 unsigned long npages = dir_pages(dir);
168 struct page *page =
NULL;
175 for (n = 0; n < npages; n++) {
178 page = dir_get_page(dir, n);
183 limit = kaddr + minix_last_byte(dir, n) - sbi->
s_dirsize;
184 for (p = kaddr; p <=
limit; p = minix_next_entry(p, sbi)) {
188 inumber = de3->
inode;
196 if (namecompare(namelen, sbi->
s_namelen, name, namx))
210 struct inode *dir = dentry->
d_parent->d_inode;
211 const char * name = dentry->
d_name.name;
215 struct page *page =
NULL;
216 unsigned long npages = dir_pages(dir);
231 for (n = 0; n <= npages; n++) {
232 char *
limit, *dir_end;
234 page = dir_get_page(dir, n);
240 dir_end = kaddr + minix_last_byte(dir, n);
242 for (p = kaddr; p <=
limit; p = minix_next_entry(p, sbi)) {
247 inumber = de3->
inode;
263 if (namecompare(namelen, sbi->
s_namelen, name, namx))
277 memcpy (namx, name, namelen);
285 err = dir_commit_chunk(page, pos, sbi->
s_dirsize);
287 mark_inode_dirty(dir);
299 struct inode *inode = page->
mapping->host;
301 loff_t pos =
page_offset(page) + (
char*)de - kaddr;
313 err = dir_commit_chunk(page, pos, len);
319 mark_inode_dirty(inode);
325 struct page *page = grab_cache_page(inode->
i_mapping, 0);
346 de3 = minix_next_entry(de3, sbi);
354 de = minix_next_entry(de, sbi);
360 err = dir_commit_chunk(page, 0, 2 * sbi->
s_dirsize);
371 struct page *page =
NULL;
372 unsigned long i, npages = dir_pages(inode);
377 for (i = 0; i < npages; i++) {
380 page = dir_get_page(inode, i);
385 limit = kaddr + minix_last_byte(inode, i) - sbi->
s_dirsize;
386 for (p = kaddr; p <=
limit; p = minix_next_entry(p, sbi)) {
390 inumber = de3->
inode;
402 if (inumber != inode->
i_ino)
404 }
else if (name[1] !=
'.')
423 struct inode *dir = page->
mapping->host;
436 de->inode = inode->
i_ino;
437 err = dir_commit_chunk(page, pos, sbi->
s_dirsize);
443 mark_inode_dirty(dir);
448 struct page *page = dir_get_page(dir, 0);
467 struct inode *inode = mapping->
host;