// SPDX-License-Identifier: GPL-2.0 /* * linux/fs/isofs/dir.c * * (C) 1992, 1993, 1994 Eric Youngdale Modified for ISO 9660 filesystem. * * (C) 1991 Linus Torvalds - minix filesystem * * Steve Beynon : Missing last directory entries fixed * (stephen@askone.demon.co.uk) : 21st June 1996 * * isofs directory handling functions
*/ #include <linux/gfp.h> #include"isofs.h"
int isofs_name_translate(struct iso_directory_record *de, char *new, struct inode *inode)
{ char * old = de->name; int len = de->name_len[0]; int i;
for (i = 0; i < len; i++) { unsignedchar c = old[i]; if (!c) break;
if (c >= 'A' && c <= 'Z')
c |= 0x20; /* lower case */
/* Drop trailing '.;1' (ISO 9660:1988 7.5.1 requires period) */ if (c == '.' && i == len - 3 && old[i + 1] == ';' && old[i + 2] == '1') break;
/* Drop trailing ';1' */ if (c == ';' && i == len - 2 && old[i + 1] == '1') break;
/* Convert remaining ';' to '.' */ /* Also '/' to '.' (broken Acorn-generated ISO9660 images) */ if (c == ';' || c == '/')
c = '.';
new[i] = c;
} return i;
}
/* Acorn extensions written by Matthew Wilcox <willy@infradead.org> 1998 */ int get_acorn_filename(struct iso_directory_record *de, char *retname, struct inode *inode)
{ int std; unsignedchar *chr; int retnamlen = isofs_name_translate(de, retname, inode);
if (!bh) {
bh = isofs_bread(inode, block); if (!bh) return 0;
}
de = (struct iso_directory_record *) (bh->b_data + offset);
de_len = *(unsignedchar *)de;
/* * If the length byte is zero, we should move on to the next * CDROM sector. If we are at the end of the directory, we * kick out of the while loop.
*/
/* Handle the case of the '.' directory */ if (de->name_len[0] == 1 && de->name[0] == 0) { if (!dir_emit_dot(file, ctx)) break;
ctx->pos += de_len; continue;
}
len = 0;
/* Handle the case of the '..' directory */ if (de->name_len[0] == 1 && de->name[0] == 1) { if (!dir_emit_dotdot(file, ctx)) break;
ctx->pos += de_len; continue;
}
/* Handle everything else. Do name translation if there
is no Rock Ridge NM field. */
/* * Do not report hidden files if so instructed, or associated * files unless instructed to do so
*/ if ((sbi->s_hide && (de->flags[-sbi->s_high_sierra] & 1)) ||
(!sbi->s_showassoc &&
(de->flags[-sbi->s_high_sierra] & 4))) {
ctx->pos += de_len; continue;
}
map = 1; if (sbi->s_rock) {
len = get_rock_ridge_filename(de, tmpname, inode); if (len != 0) { /* may be -1 */
p = tmpname;
map = 0;
}
} if (map) { #ifdef CONFIG_JOLIET if (sbi->s_joliet_level) {
len = get_joliet_filename(de, tmpname, inode);
p = tmpname;
} else #endif if (sbi->s_mapping == 'a') {
len = get_acorn_filename(de, tmpname, inode);
p = tmpname;
} else if (sbi->s_mapping == 'n') {
len = isofs_name_translate(de, tmpname, inode);
p = tmpname;
} else {
p = de->name;
len = de->name_len[0];
}
} if (len > 0) { if (!dir_emit(ctx, p, len, inode_number, DT_UNKNOWN)) break;
}
ctx->pos += de_len;
} if (bh)
brelse(bh); return 0;
}
/* * Handle allocation of temporary space for name translation and * handling split directory entries.. The real work is done by * "do_isofs_readdir()".
*/ staticint isofs_readdir(struct file *file, struct dir_context *ctx)
{ int result; char *tmpname; struct iso_directory_record *tmpde; struct inode *inode = file_inode(file);
tmpname = (char *)__get_free_page(GFP_KERNEL); if (tmpname == NULL) return -ENOMEM;
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.