^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * linux/fs/isofs/dir.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * (C) 1992, 1993, 1994 Eric Youngdale Modified for ISO 9660 filesystem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * (C) 1991 Linus Torvalds - minix filesystem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Steve Beynon : Missing last directory entries fixed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * (stephen@askone.demon.co.uk) : 21st June 1996
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * isofs directory handling functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/gfp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "isofs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) int isofs_name_translate(struct iso_directory_record *de, char *new, struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) char * old = de->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) int len = de->name_len[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) for (i = 0; i < len; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) unsigned char c = old[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) if (!c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) if (c >= 'A' && c <= 'Z')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) c |= 0x20; /* lower case */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) /* Drop trailing '.;1' (ISO 9660:1988 7.5.1 requires period) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) if (c == '.' && i == len - 3 && old[i + 1] == ';' && old[i + 2] == '1')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /* Drop trailing ';1' */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) if (c == ';' && i == len - 2 && old[i + 1] == '1')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /* Convert remaining ';' to '.' */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) /* Also '/' to '.' (broken Acorn-generated ISO9660 images) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) if (c == ';' || c == '/')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) c = '.';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) new[i] = c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) return i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) /* Acorn extensions written by Matthew Wilcox <willy@infradead.org> 1998 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) int get_acorn_filename(struct iso_directory_record *de,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) char *retname, struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) int std;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) unsigned char *chr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) int retnamlen = isofs_name_translate(de, retname, inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) if (retnamlen == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) std = sizeof(struct iso_directory_record) + de->name_len[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) if (std & 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) std++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) if (de->length[0] - std != 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) return retnamlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) chr = ((unsigned char *) de) + std;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) if (strncmp(chr, "ARCHIMEDES", 10))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) return retnamlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) if ((*retname == '_') && ((chr[19] & 1) == 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) *retname = '!';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) if (((de->flags[0] & 2) == 0) && (chr[13] == 0xff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) && ((chr[12] & 0xf0) == 0xf0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) retname[retnamlen] = ',';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) sprintf(retname+retnamlen+1, "%3.3x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) ((chr[12] & 0xf) << 8) | chr[11]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) retnamlen += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) return retnamlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * This should _really_ be cleaned up some day..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) static int do_isofs_readdir(struct inode *inode, struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) struct dir_context *ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) char *tmpname, struct iso_directory_record *tmpde)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) unsigned char bufbits = ISOFS_BUFFER_BITS(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) unsigned long block, offset, block_saved, offset_saved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) unsigned long inode_number = 0; /* Quiet GCC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) struct buffer_head *bh = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) int map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) int first_de = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) char *p = NULL; /* Quiet GCC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct iso_directory_record *de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) struct isofs_sb_info *sbi = ISOFS_SB(inode->i_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) offset = ctx->pos & (bufsize - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) block = ctx->pos >> bufbits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) while (ctx->pos < inode->i_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) int de_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) if (!bh) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) bh = isofs_bread(inode, block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) if (!bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) de = (struct iso_directory_record *) (bh->b_data + offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) de_len = *(unsigned char *)de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * If the length byte is zero, we should move on to the next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) * CDROM sector. If we are at the end of the directory, we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) * kick out of the while loop.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) if (de_len == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) bh = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) ctx->pos = (ctx->pos + ISOFS_BLOCK_SIZE) & ~(ISOFS_BLOCK_SIZE - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) block = ctx->pos >> bufbits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) block_saved = block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) offset_saved = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) offset += de_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) /* Make sure we have a full directory entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) if (offset >= bufsize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) int slop = bufsize - offset + de_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) memcpy(tmpde, de, slop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) offset &= bufsize - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) block++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) bh = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) if (offset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) bh = isofs_bread(inode, block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) if (!bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) memcpy((void *) tmpde + slop, bh->b_data, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) de = tmpde;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) /* Basic sanity check, whether name doesn't exceed dir entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) if (de_len < de->name_len[0] +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) sizeof(struct iso_directory_record)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) printk(KERN_NOTICE "iso9660: Corrupted directory entry"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) " in block %lu of inode %lu\n", block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) inode->i_ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) if (first_de) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) isofs_normalize_block_and_offset(de,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) &block_saved,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) &offset_saved);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) inode_number = isofs_get_ino(block_saved,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) offset_saved, bufbits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) if (de->flags[-sbi->s_high_sierra] & 0x80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) first_de = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) ctx->pos += de_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) first_de = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /* Handle the case of the '.' directory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) if (de->name_len[0] == 1 && de->name[0] == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) if (!dir_emit_dot(file, ctx))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) ctx->pos += de_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) /* Handle the case of the '..' directory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) if (de->name_len[0] == 1 && de->name[0] == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) if (!dir_emit_dotdot(file, ctx))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) ctx->pos += de_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) /* Handle everything else. Do name translation if there
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) is no Rock Ridge NM field. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) * Do not report hidden files if so instructed, or associated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) * files unless instructed to do so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) if ((sbi->s_hide && (de->flags[-sbi->s_high_sierra] & 1)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) (!sbi->s_showassoc &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) (de->flags[-sbi->s_high_sierra] & 4))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) ctx->pos += de_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) map = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) if (sbi->s_rock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) len = get_rock_ridge_filename(de, tmpname, inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) if (len != 0) { /* may be -1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) p = tmpname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) map = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) if (map) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) #ifdef CONFIG_JOLIET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) if (sbi->s_joliet_level) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) len = get_joliet_filename(de, tmpname, inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) p = tmpname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) if (sbi->s_mapping == 'a') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) len = get_acorn_filename(de, tmpname, inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) p = tmpname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) if (sbi->s_mapping == 'n') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) len = isofs_name_translate(de, tmpname, inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) p = tmpname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) p = de->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) len = de->name_len[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) if (len > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) if (!dir_emit(ctx, p, len, inode_number, DT_UNKNOWN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) ctx->pos += de_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) if (bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) * Handle allocation of temporary space for name translation and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) * handling split directory entries.. The real work is done by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * "do_isofs_readdir()".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) static int isofs_readdir(struct file *file, struct dir_context *ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) char *tmpname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) struct iso_directory_record *tmpde;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) struct inode *inode = file_inode(file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) tmpname = (char *)__get_free_page(GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) if (tmpname == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) tmpde = (struct iso_directory_record *) (tmpname+1024);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) result = do_isofs_readdir(inode, file, ctx, tmpname, tmpde);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) free_page((unsigned long) tmpname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) const struct file_operations isofs_dir_operations =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) .llseek = generic_file_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) .read = generic_read_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) .iterate_shared = isofs_readdir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) * directories can handle most operations...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) const struct inode_operations isofs_dir_inode_operations =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) .lookup = isofs_lookup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)