Linux Audio

Check our new training course

Loading...
v4.6
 
  1/*
  2 *  linux/fs/hpfs/dir.c
  3 *
  4 *  Mikulas Patocka (mikulas@artax.karlin.mff.cuni.cz), 1998-1999
  5 *
  6 *  directory VFS functions
  7 */
  8
  9#include <linux/slab.h>
 10#include "hpfs_fn.h"
 11
 12static int hpfs_dir_release(struct inode *inode, struct file *filp)
 13{
 14	hpfs_lock(inode->i_sb);
 15	hpfs_del_pos(inode, &filp->f_pos);
 16	/*hpfs_write_if_changed(inode);*/
 17	hpfs_unlock(inode->i_sb);
 18	return 0;
 19}
 20
 21/* This is slow, but it's not used often */
 22
 23static loff_t hpfs_dir_lseek(struct file *filp, loff_t off, int whence)
 24{
 25	loff_t new_off = off + (whence == 1 ? filp->f_pos : 0);
 26	loff_t pos;
 27	struct quad_buffer_head qbh;
 28	struct inode *i = file_inode(filp);
 29	struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
 30	struct super_block *s = i->i_sb;
 31
 32	/* Somebody else will have to figure out what to do here */
 33	if (whence == SEEK_DATA || whence == SEEK_HOLE)
 34		return -EINVAL;
 35
 36	inode_lock(i);
 37	hpfs_lock(s);
 38
 39	/*pr_info("dir lseek\n");*/
 40	if (new_off == 0 || new_off == 1 || new_off == 11 || new_off == 12 || new_off == 13) goto ok;
 41	pos = ((loff_t) hpfs_de_as_down_as_possible(s, hpfs_inode->i_dno) << 4) + 1;
 42	while (pos != new_off) {
 43		if (map_pos_dirent(i, &pos, &qbh)) hpfs_brelse4(&qbh);
 44		else goto fail;
 45		if (pos == 12) goto fail;
 46	}
 47	hpfs_add_pos(i, &filp->f_pos);
 
 
 
 
 48ok:
 49	filp->f_pos = new_off;
 50	hpfs_unlock(s);
 51	inode_unlock(i);
 52	return new_off;
 53fail:
 54	/*pr_warn("illegal lseek: %016llx\n", new_off);*/
 55	hpfs_unlock(s);
 56	inode_unlock(i);
 57	return -ESPIPE;
 58}
 59
 60static int hpfs_readdir(struct file *file, struct dir_context *ctx)
 61{
 62	struct inode *inode = file_inode(file);
 63	struct hpfs_inode_info *hpfs_inode = hpfs_i(inode);
 64	struct quad_buffer_head qbh;
 65	struct hpfs_dirent *de;
 66	int lc;
 67	loff_t next_pos;
 68	unsigned char *tempname;
 69	int c1, c2 = 0;
 70	int ret = 0;
 71
 72	hpfs_lock(inode->i_sb);
 73
 74	if (hpfs_sb(inode->i_sb)->sb_chk) {
 75		if (hpfs_chk_sectors(inode->i_sb, inode->i_ino, 1, "dir_fnode")) {
 76			ret = -EFSERROR;
 77			goto out;
 78		}
 79		if (hpfs_chk_sectors(inode->i_sb, hpfs_inode->i_dno, 4, "dir_dnode")) {
 80			ret = -EFSERROR;
 81			goto out;
 82		}
 83	}
 84	if (hpfs_sb(inode->i_sb)->sb_chk >= 2) {
 85		struct buffer_head *bh;
 86		struct fnode *fno;
 87		int e = 0;
 88		if (!(fno = hpfs_map_fnode(inode->i_sb, inode->i_ino, &bh))) {
 89			ret = -EIOERROR;
 90			goto out;
 91		}
 92		if (!fnode_is_dir(fno)) {
 93			e = 1;
 94			hpfs_error(inode->i_sb, "not a directory, fnode %08lx",
 95					(unsigned long)inode->i_ino);
 96		}
 97		if (hpfs_inode->i_dno != le32_to_cpu(fno->u.external[0].disk_secno)) {
 98			e = 1;
 99			hpfs_error(inode->i_sb, "corrupted inode: i_dno == %08x, fnode -> dnode == %08x", hpfs_inode->i_dno, le32_to_cpu(fno->u.external[0].disk_secno));
100		}
101		brelse(bh);
102		if (e) {
103			ret = -EFSERROR;
104			goto out;
105		}
106	}
107	lc = hpfs_sb(inode->i_sb)->sb_lowercase;
108	if (ctx->pos == 12) { /* diff -r requires this (note, that diff -r */
109		ctx->pos = 13; /* also fails on msdos filesystem in 2.0) */
110		goto out;
111	}
112	if (ctx->pos == 13) {
113		ret = -ENOENT;
114		goto out;
115	}
116	
117	while (1) {
118		again:
119		/* This won't work when cycle is longer than number of dirents
120		   accepted by filldir, but what can I do?
121		   maybe killall -9 ls helps */
122		if (hpfs_sb(inode->i_sb)->sb_chk)
123			if (hpfs_stop_cycles(inode->i_sb, ctx->pos, &c1, &c2, "hpfs_readdir")) {
124				ret = -EFSERROR;
125				goto out;
126			}
127		if (ctx->pos == 12)
128			goto out;
129		if (ctx->pos == 3 || ctx->pos == 4 || ctx->pos == 5) {
130			pr_err("pos==%d\n", (int)ctx->pos);
131			goto out;
132		}
133		if (ctx->pos == 0) {
134			if (!dir_emit_dot(file, ctx))
135				goto out;
136			ctx->pos = 11;
137		}
138		if (ctx->pos == 11) {
139			if (!dir_emit(ctx, "..", 2, hpfs_inode->i_parent_dir, DT_DIR))
140				goto out;
141			ctx->pos = 1;
142		}
143		if (ctx->pos == 1) {
 
 
 
144			ctx->pos = ((loff_t) hpfs_de_as_down_as_possible(inode->i_sb, hpfs_inode->i_dno) << 4) + 1;
145			hpfs_add_pos(inode, &file->f_pos);
146			file->f_version = inode->i_version;
147		}
148		next_pos = ctx->pos;
149		if (!(de = map_pos_dirent(inode, &next_pos, &qbh))) {
150			ctx->pos = next_pos;
151			ret = -EIOERROR;
152			goto out;
153		}
154		if (de->first || de->last) {
155			if (hpfs_sb(inode->i_sb)->sb_chk) {
156				if (de->first && !de->last && (de->namelen != 2
157				    || de ->name[0] != 1 || de->name[1] != 1))
158					hpfs_error(inode->i_sb, "hpfs_readdir: bad ^A^A entry; pos = %08lx", (unsigned long)ctx->pos);
159				if (de->last && (de->namelen != 1 || de ->name[0] != 255))
160					hpfs_error(inode->i_sb, "hpfs_readdir: bad \\377 entry; pos = %08lx", (unsigned long)ctx->pos);
161			}
162			hpfs_brelse4(&qbh);
163			ctx->pos = next_pos;
164			goto again;
165		}
166		tempname = hpfs_translate_name(inode->i_sb, de->name, de->namelen, lc, de->not_8x3);
167		if (!dir_emit(ctx, tempname, de->namelen, le32_to_cpu(de->fnode), DT_UNKNOWN)) {
168			if (tempname != de->name) kfree(tempname);
169			hpfs_brelse4(&qbh);
170			goto out;
171		}
172		ctx->pos = next_pos;
173		if (tempname != de->name) kfree(tempname);
174		hpfs_brelse4(&qbh);
175	}
176out:
177	hpfs_unlock(inode->i_sb);
178	return ret;
179}
180
181/*
182 * lookup.  Search the specified directory for the specified name, set
183 * *result to the corresponding inode.
184 *
185 * lookup uses the inode number to tell read_inode whether it is reading
186 * the inode of a directory or a file -- file ino's are odd, directory
187 * ino's are even.  read_inode avoids i/o for file inodes; everything
188 * needed is up here in the directory.  (And file fnodes are out in
189 * the boondocks.)
190 *
191 *    - M.P.: this is over, sometimes we've got to read file's fnode for eas
192 *	      inode numbers are just fnode sector numbers; iget lock is used
193 *	      to tell read_inode to read fnode or not.
194 */
195
196struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
197{
198	const unsigned char *name = dentry->d_name.name;
199	unsigned len = dentry->d_name.len;
200	struct quad_buffer_head qbh;
201	struct hpfs_dirent *de;
202	ino_t ino;
203	int err;
204	struct inode *result = NULL;
205	struct hpfs_inode_info *hpfs_result;
206
207	hpfs_lock(dir->i_sb);
208	if ((err = hpfs_chk_name(name, &len))) {
209		if (err == -ENAMETOOLONG) {
210			hpfs_unlock(dir->i_sb);
211			return ERR_PTR(-ENAMETOOLONG);
212		}
213		goto end_add;
214	}
215
216	/*
217	 * '.' and '..' will never be passed here.
218	 */
219
220	de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, NULL, &qbh);
221
222	/*
223	 * This is not really a bailout, just means file not found.
224	 */
225
226	if (!de) goto end;
227
228	/*
229	 * Get inode number, what we're after.
230	 */
231
232	ino = le32_to_cpu(de->fnode);
233
234	/*
235	 * Go find or make an inode.
236	 */
237
238	result = iget_locked(dir->i_sb, ino);
239	if (!result) {
240		hpfs_error(dir->i_sb, "hpfs_lookup: can't get inode");
 
241		goto bail1;
242	}
243	if (result->i_state & I_NEW) {
244		hpfs_init_inode(result);
245		if (de->directory)
246			hpfs_read_inode(result);
247		else if (le32_to_cpu(de->ea_size) && hpfs_sb(dir->i_sb)->sb_eas)
248			hpfs_read_inode(result);
249		else {
250			result->i_mode |= S_IFREG;
251			result->i_mode &= ~0111;
252			result->i_op = &hpfs_file_iops;
253			result->i_fop = &hpfs_file_ops;
254			set_nlink(result, 1);
255		}
256		unlock_new_inode(result);
257	}
258	hpfs_result = hpfs_i(result);
259	if (!de->directory) hpfs_result->i_parent_dir = dir->i_ino;
260
261	if (de->has_acl || de->has_xtd_perm) if (!(dir->i_sb->s_flags & MS_RDONLY)) {
262		hpfs_error(result->i_sb, "ACLs or XPERM found. This is probably HPFS386. This driver doesn't support it now. Send me some info on these structures");
 
 
263		goto bail1;
264	}
265
266	/*
267	 * Fill in the info from the directory if this is a newly created
268	 * inode.
269	 */
270
271	if (!result->i_ctime.tv_sec) {
272		if (!(result->i_ctime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(de->creation_date))))
273			result->i_ctime.tv_sec = 1;
274		result->i_ctime.tv_nsec = 0;
275		result->i_mtime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(de->write_date));
276		result->i_mtime.tv_nsec = 0;
277		result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(de->read_date));
278		result->i_atime.tv_nsec = 0;
 
 
279		hpfs_result->i_ea_size = le32_to_cpu(de->ea_size);
280		if (!hpfs_result->i_ea_mode && de->read_only)
281			result->i_mode &= ~0222;
282		if (!de->directory) {
283			if (result->i_size == -1) {
284				result->i_size = le32_to_cpu(de->file_size);
285				result->i_data.a_ops = &hpfs_aops;
286				hpfs_i(result)->mmu_private = result->i_size;
287			/*
288			 * i_blocks should count the fnode and any anodes.
289			 * We count 1 for the fnode and don't bother about
290			 * anodes -- the disk heads are on the directory band
291			 * and we want them to stay there.
292			 */
293				result->i_blocks = 1 + ((result->i_size + 511) >> 9);
294			}
295		}
296	}
297
 
298	hpfs_brelse4(&qbh);
299
300	/*
301	 * Made it.
302	 */
303
304	end:
305	end_add:
306	hpfs_unlock(dir->i_sb);
307	d_add(dentry, result);
308	return NULL;
309
310	/*
311	 * Didn't.
312	 */
313	bail1:
314	
315	hpfs_brelse4(&qbh);
316	
317	/*bail:*/
318
319	hpfs_unlock(dir->i_sb);
320	return ERR_PTR(-ENOENT);
321}
322
323const struct file_operations hpfs_dir_ops =
324{
325	.llseek		= hpfs_dir_lseek,
326	.read		= generic_read_dir,
327	.iterate	= hpfs_readdir,
328	.release	= hpfs_dir_release,
329	.fsync		= hpfs_file_fsync,
330	.unlocked_ioctl	= hpfs_ioctl,
 
331};
v6.13.7
  1// SPDX-License-Identifier: GPL-2.0
  2/*
  3 *  linux/fs/hpfs/dir.c
  4 *
  5 *  Mikulas Patocka (mikulas@artax.karlin.mff.cuni.cz), 1998-1999
  6 *
  7 *  directory VFS functions
  8 */
  9
 10#include <linux/slab.h>
 11#include "hpfs_fn.h"
 12
 13static int hpfs_dir_release(struct inode *inode, struct file *filp)
 14{
 15	hpfs_lock(inode->i_sb);
 16	hpfs_del_pos(inode, &filp->f_pos);
 17	/*hpfs_write_if_changed(inode);*/
 18	hpfs_unlock(inode->i_sb);
 19	return 0;
 20}
 21
 22/* This is slow, but it's not used often */
 23
 24static loff_t hpfs_dir_lseek(struct file *filp, loff_t off, int whence)
 25{
 26	loff_t new_off = off + (whence == 1 ? filp->f_pos : 0);
 27	loff_t pos;
 28	struct quad_buffer_head qbh;
 29	struct inode *i = file_inode(filp);
 30	struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
 31	struct super_block *s = i->i_sb;
 32
 33	/* Somebody else will have to figure out what to do here */
 34	if (whence == SEEK_DATA || whence == SEEK_HOLE)
 35		return -EINVAL;
 36
 37	inode_lock(i);
 38	hpfs_lock(s);
 39
 40	/*pr_info("dir lseek\n");*/
 41	if (new_off == 0 || new_off == 1 || new_off == 11 || new_off == 12 || new_off == 13) goto ok;
 42	pos = ((loff_t) hpfs_de_as_down_as_possible(s, hpfs_inode->i_dno) << 4) + 1;
 43	while (pos != new_off) {
 44		if (map_pos_dirent(i, &pos, &qbh)) hpfs_brelse4(&qbh);
 45		else goto fail;
 46		if (pos == 12) goto fail;
 47	}
 48	if (unlikely(hpfs_add_pos(i, &filp->f_pos) < 0)) {
 49		hpfs_unlock(s);
 50		inode_unlock(i);
 51		return -ENOMEM;
 52	}
 53ok:
 54	filp->f_pos = new_off;
 55	hpfs_unlock(s);
 56	inode_unlock(i);
 57	return new_off;
 58fail:
 59	/*pr_warn("illegal lseek: %016llx\n", new_off);*/
 60	hpfs_unlock(s);
 61	inode_unlock(i);
 62	return -ESPIPE;
 63}
 64
 65static int hpfs_readdir(struct file *file, struct dir_context *ctx)
 66{
 67	struct inode *inode = file_inode(file);
 68	struct hpfs_inode_info *hpfs_inode = hpfs_i(inode);
 69	struct quad_buffer_head qbh;
 70	struct hpfs_dirent *de;
 71	int lc;
 72	loff_t next_pos;
 73	unsigned char *tempname;
 74	int c1, c2 = 0;
 75	int ret = 0;
 76
 77	hpfs_lock(inode->i_sb);
 78
 79	if (hpfs_sb(inode->i_sb)->sb_chk) {
 80		if (hpfs_chk_sectors(inode->i_sb, inode->i_ino, 1, "dir_fnode")) {
 81			ret = -EFSERROR;
 82			goto out;
 83		}
 84		if (hpfs_chk_sectors(inode->i_sb, hpfs_inode->i_dno, 4, "dir_dnode")) {
 85			ret = -EFSERROR;
 86			goto out;
 87		}
 88	}
 89	if (hpfs_sb(inode->i_sb)->sb_chk >= 2) {
 90		struct buffer_head *bh;
 91		struct fnode *fno;
 92		int e = 0;
 93		if (!(fno = hpfs_map_fnode(inode->i_sb, inode->i_ino, &bh))) {
 94			ret = -EIOERROR;
 95			goto out;
 96		}
 97		if (!fnode_is_dir(fno)) {
 98			e = 1;
 99			hpfs_error(inode->i_sb, "not a directory, fnode %08lx",
100					(unsigned long)inode->i_ino);
101		}
102		if (hpfs_inode->i_dno != le32_to_cpu(fno->u.external[0].disk_secno)) {
103			e = 1;
104			hpfs_error(inode->i_sb, "corrupted inode: i_dno == %08x, fnode -> dnode == %08x", hpfs_inode->i_dno, le32_to_cpu(fno->u.external[0].disk_secno));
105		}
106		brelse(bh);
107		if (e) {
108			ret = -EFSERROR;
109			goto out;
110		}
111	}
112	lc = hpfs_sb(inode->i_sb)->sb_lowercase;
113	if (ctx->pos == 12) { /* diff -r requires this (note, that diff -r */
114		ctx->pos = 13; /* also fails on msdos filesystem in 2.0) */
115		goto out;
116	}
117	if (ctx->pos == 13) {
118		ret = -ENOENT;
119		goto out;
120	}
121	
122	while (1) {
123		again:
124		/* This won't work when cycle is longer than number of dirents
125		   accepted by filldir, but what can I do?
126		   maybe killall -9 ls helps */
127		if (hpfs_sb(inode->i_sb)->sb_chk)
128			if (hpfs_stop_cycles(inode->i_sb, ctx->pos, &c1, &c2, "hpfs_readdir")) {
129				ret = -EFSERROR;
130				goto out;
131			}
132		if (ctx->pos == 12)
133			goto out;
134		if (ctx->pos == 3 || ctx->pos == 4 || ctx->pos == 5) {
135			pr_err("pos==%d\n", (int)ctx->pos);
136			goto out;
137		}
138		if (ctx->pos == 0) {
139			if (!dir_emit_dot(file, ctx))
140				goto out;
141			ctx->pos = 11;
142		}
143		if (ctx->pos == 11) {
144			if (!dir_emit(ctx, "..", 2, hpfs_inode->i_parent_dir, DT_DIR))
145				goto out;
146			ctx->pos = 1;
147		}
148		if (ctx->pos == 1) {
149			ret = hpfs_add_pos(inode, &file->f_pos);
150			if (unlikely(ret < 0))
151				goto out;
152			ctx->pos = ((loff_t) hpfs_de_as_down_as_possible(inode->i_sb, hpfs_inode->i_dno) << 4) + 1;
 
 
153		}
154		next_pos = ctx->pos;
155		if (!(de = map_pos_dirent(inode, &next_pos, &qbh))) {
156			ctx->pos = next_pos;
157			ret = -EIOERROR;
158			goto out;
159		}
160		if (de->first || de->last) {
161			if (hpfs_sb(inode->i_sb)->sb_chk) {
162				if (de->first && !de->last && (de->namelen != 2
163				    || de ->name[0] != 1 || de->name[1] != 1))
164					hpfs_error(inode->i_sb, "hpfs_readdir: bad ^A^A entry; pos = %08lx", (unsigned long)ctx->pos);
165				if (de->last && (de->namelen != 1 || de ->name[0] != 255))
166					hpfs_error(inode->i_sb, "hpfs_readdir: bad \\377 entry; pos = %08lx", (unsigned long)ctx->pos);
167			}
168			hpfs_brelse4(&qbh);
169			ctx->pos = next_pos;
170			goto again;
171		}
172		tempname = hpfs_translate_name(inode->i_sb, de->name, de->namelen, lc, de->not_8x3);
173		if (!dir_emit(ctx, tempname, de->namelen, le32_to_cpu(de->fnode), DT_UNKNOWN)) {
174			if (tempname != de->name) kfree(tempname);
175			hpfs_brelse4(&qbh);
176			goto out;
177		}
178		ctx->pos = next_pos;
179		if (tempname != de->name) kfree(tempname);
180		hpfs_brelse4(&qbh);
181	}
182out:
183	hpfs_unlock(inode->i_sb);
184	return ret;
185}
186
187/*
188 * lookup.  Search the specified directory for the specified name, set
189 * *result to the corresponding inode.
190 *
191 * lookup uses the inode number to tell read_inode whether it is reading
192 * the inode of a directory or a file -- file ino's are odd, directory
193 * ino's are even.  read_inode avoids i/o for file inodes; everything
194 * needed is up here in the directory.  (And file fnodes are out in
195 * the boondocks.)
196 *
197 *    - M.P.: this is over, sometimes we've got to read file's fnode for eas
198 *	      inode numbers are just fnode sector numbers; iget lock is used
199 *	      to tell read_inode to read fnode or not.
200 */
201
202struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
203{
204	const unsigned char *name = dentry->d_name.name;
205	unsigned len = dentry->d_name.len;
206	struct quad_buffer_head qbh;
207	struct hpfs_dirent *de;
208	ino_t ino;
209	int err;
210	struct inode *result = NULL;
211	struct hpfs_inode_info *hpfs_result;
212
213	hpfs_lock(dir->i_sb);
214	if ((err = hpfs_chk_name(name, &len))) {
215		if (err == -ENAMETOOLONG) {
216			hpfs_unlock(dir->i_sb);
217			return ERR_PTR(-ENAMETOOLONG);
218		}
219		goto end_add;
220	}
221
222	/*
223	 * '.' and '..' will never be passed here.
224	 */
225
226	de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, NULL, &qbh);
227
228	/*
229	 * This is not really a bailout, just means file not found.
230	 */
231
232	if (!de) goto end;
233
234	/*
235	 * Get inode number, what we're after.
236	 */
237
238	ino = le32_to_cpu(de->fnode);
239
240	/*
241	 * Go find or make an inode.
242	 */
243
244	result = iget_locked(dir->i_sb, ino);
245	if (!result) {
246		hpfs_error(dir->i_sb, "hpfs_lookup: can't get inode");
247		result = ERR_PTR(-ENOMEM);
248		goto bail1;
249	}
250	if (result->i_state & I_NEW) {
251		hpfs_init_inode(result);
252		if (de->directory)
253			hpfs_read_inode(result);
254		else if (le32_to_cpu(de->ea_size) && hpfs_sb(dir->i_sb)->sb_eas)
255			hpfs_read_inode(result);
256		else {
257			result->i_mode |= S_IFREG;
258			result->i_mode &= ~0111;
259			result->i_op = &hpfs_file_iops;
260			result->i_fop = &hpfs_file_ops;
261			set_nlink(result, 1);
262		}
263		unlock_new_inode(result);
264	}
265	hpfs_result = hpfs_i(result);
266	if (!de->directory) hpfs_result->i_parent_dir = dir->i_ino;
267
268	if (de->has_acl || de->has_xtd_perm) if (!sb_rdonly(dir->i_sb)) {
269		hpfs_error(result->i_sb, "ACLs or XPERM found. This is probably HPFS386. This driver doesn't support it now. Send me some info on these structures");
270		iput(result);
271		result = ERR_PTR(-EINVAL);
272		goto bail1;
273	}
274
275	/*
276	 * Fill in the info from the directory if this is a newly created
277	 * inode.
278	 */
279
280	if (!inode_get_ctime_sec(result)) {
281		time64_t csec = local_to_gmt(dir->i_sb, le32_to_cpu(de->creation_date));
282
283		inode_set_ctime(result, csec ? csec : 1, 0);
284		inode_set_mtime(result,
285				local_to_gmt(dir->i_sb, le32_to_cpu(de->write_date)),
286				0);
287		inode_set_atime(result,
288				local_to_gmt(dir->i_sb, le32_to_cpu(de->read_date)),
289				0);
290		hpfs_result->i_ea_size = le32_to_cpu(de->ea_size);
291		if (!hpfs_result->i_ea_mode && de->read_only)
292			result->i_mode &= ~0222;
293		if (!de->directory) {
294			if (result->i_size == -1) {
295				result->i_size = le32_to_cpu(de->file_size);
296				result->i_data.a_ops = &hpfs_aops;
297				hpfs_i(result)->mmu_private = result->i_size;
298			/*
299			 * i_blocks should count the fnode and any anodes.
300			 * We count 1 for the fnode and don't bother about
301			 * anodes -- the disk heads are on the directory band
302			 * and we want them to stay there.
303			 */
304				result->i_blocks = 1 + ((result->i_size + 511) >> 9);
305			}
306		}
307	}
308
309bail1:
310	hpfs_brelse4(&qbh);
311
312	/*
313	 * Made it.
314	 */
315
316end:
317end_add:
 
 
 
 
 
 
 
 
 
 
 
 
 
318	hpfs_unlock(dir->i_sb);
319	return d_splice_alias(result, dentry);
320}
321
322const struct file_operations hpfs_dir_ops =
323{
324	.llseek		= hpfs_dir_lseek,
325	.read		= generic_read_dir,
326	.iterate_shared	= hpfs_readdir,
327	.release	= hpfs_dir_release,
328	.fsync		= hpfs_file_fsync,
329	.unlocked_ioctl	= hpfs_ioctl,
330	.compat_ioctl	= compat_ptr_ioctl,
331};