cregit-Linux how code gets into the kernel

Release 4.18 fs/udf/directory.c

Directory: fs/udf
/*
 * directory.c
 *
 * PURPOSE
 *      Directory related functions
 *
 * COPYRIGHT
 *      This file is distributed under the terms of the GNU General Public
 *      License (GPL). Copies of the GPL can be obtained from:
 *              ftp://prep.ai.mit.edu/pub/gnu/GPL
 *      Each contributing author retains all rights to their own work.
 */

#include "udfdecl.h"
#include "udf_i.h"

#include <linux/fs.h>
#include <linux/string.h>
#include <linux/bio.h>


struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos, struct udf_fileident_bh *fibh, struct fileIdentDesc *cfi, struct extent_position *epos, struct kernel_lb_addr *eloc, uint32_t *elen, sector_t *offset) { struct fileIdentDesc *fi; int i, num; udf_pblk_t block; struct buffer_head *tmp, *bha[16]; struct udf_inode_info *iinfo = UDF_I(dir); fibh->soffset = fibh->eoffset; if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { fi = udf_get_fileident(iinfo->i_ext.i_data - (iinfo->i_efe ? sizeof(struct extendedFileEntry) : sizeof(struct fileEntry)), dir->i_sb->s_blocksize, &(fibh->eoffset)); if (!fi) return NULL; *nf_pos += fibh->eoffset - fibh->soffset; memcpy((uint8_t *)cfi, (uint8_t *)fi, sizeof(struct fileIdentDesc)); return fi; } if (fibh->eoffset == dir->i_sb->s_blocksize) { uint32_t lextoffset = epos->offset; unsigned char blocksize_bits = dir->i_sb->s_blocksize_bits; if (udf_next_aext(dir, epos, eloc, elen, 1) != (EXT_RECORDED_ALLOCATED >> 30)) return NULL; block = udf_get_lb_pblock(dir->i_sb, eloc, *offset); (*offset)++; if ((*offset << blocksize_bits) >= *elen) *offset = 0; else epos->offset = lextoffset; brelse(fibh->sbh); fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block); if (!fibh->sbh) return NULL; fibh->soffset = fibh->eoffset = 0; if (!(*offset & ((16 >> (blocksize_bits - 9)) - 1))) { i = 16 >> (blocksize_bits - 9); if (i + *offset > (*elen >> blocksize_bits)) i = (*elen >> blocksize_bits)-*offset; for (num = 0; i > 0; i--) { block = udf_get_lb_pblock(dir->i_sb, eloc, *offset + i); tmp = udf_tgetblk(dir->i_sb, block); if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp)) bha[num++] = tmp; else brelse(tmp); } if (num) { ll_rw_block(REQ_OP_READ, REQ_RAHEAD, num, bha); for (i = 0; i < num; i++) brelse(bha[i]); } } } else if (fibh->sbh != fibh->ebh) { brelse(fibh->sbh); fibh->sbh = fibh->ebh; } fi = udf_get_fileident(fibh->sbh->b_data, dir->i_sb->s_blocksize, &(fibh->eoffset)); if (!fi) return NULL; *nf_pos += fibh->eoffset - fibh->soffset; if (fibh->eoffset <= dir->i_sb->s_blocksize) { memcpy((uint8_t *)cfi, (uint8_t *)fi, sizeof(struct fileIdentDesc)); } else if (fibh->eoffset > dir->i_sb->s_blocksize) { uint32_t lextoffset = epos->offset; if (udf_next_aext(dir, epos, eloc, elen, 1) != (EXT_RECORDED_ALLOCATED >> 30)) return NULL; block = udf_get_lb_pblock(dir->i_sb, eloc, *offset); (*offset)++; if ((*offset << dir->i_sb->s_blocksize_bits) >= *elen) *offset = 0; else epos->offset = lextoffset; fibh->soffset -= dir->i_sb->s_blocksize; fibh->eoffset -= dir->i_sb->s_blocksize; fibh->ebh = udf_tread(dir->i_sb, block); if (!fibh->ebh) return NULL; if (sizeof(struct fileIdentDesc) > -fibh->soffset) { int fi_len; memcpy((uint8_t *)cfi, (uint8_t *)fi, -fibh->soffset); memcpy((uint8_t *)cfi - fibh->soffset, fibh->ebh->b_data, sizeof(struct fileIdentDesc) + fibh->soffset); fi_len = udf_dir_entry_len(cfi); *nf_pos += fi_len - (fibh->eoffset - fibh->soffset); fibh->eoffset = fibh->soffset + fi_len; } else { memcpy((uint8_t *)cfi, (uint8_t *)fi, sizeof(struct fileIdentDesc)); } } /* Got last entry outside of dir size - fs is corrupted! */ if (*nf_pos > dir->i_size) return NULL; return fi; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)49756.74%419.05%
Linus Torvalds17720.21%14.76%
Ben Fennema10912.44%29.52%
Marcin Ślusarz505.71%314.29%
Jan Kara343.88%523.81%
Steven J. Magnani40.46%29.52%
Michael Christie20.23%14.76%
Christoph Hellwig10.11%14.76%
Pekka J Enberg10.11%14.76%
Al Viro10.11%14.76%
Total876100.00%21100.00%


struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset) { struct fileIdentDesc *fi; int lengthThisIdent; uint8_t *ptr; int padlen; if ((!buffer) || (!offset)) { udf_debug("invalidparms, buffer=%p, offset=%p\n", buffer, offset); return NULL; } ptr = buffer; if ((*offset > 0) && (*offset < bufsize)) ptr += *offset; fi = (struct fileIdentDesc *)ptr; if (fi->descTag.tagIdent != cpu_to_le16(TAG_IDENT_FID)) { udf_debug("0x%x != TAG_IDENT_FID\n", le16_to_cpu(fi->descTag.tagIdent)); udf_debug("offset: %d sizeof: %lu bufsize: %d\n", *offset, (unsigned long)sizeof(struct fileIdentDesc), bufsize); return NULL; } if ((*offset + sizeof(struct fileIdentDesc)) > bufsize) lengthThisIdent = sizeof(struct fileIdentDesc); else lengthThisIdent = sizeof(struct fileIdentDesc) + fi->lengthFileIdent + le16_to_cpu(fi->lengthOfImpUse); /* we need to figure padding, too! */ padlen = lengthThisIdent % UDF_NAME_PAD; if (padlen) lengthThisIdent += (UDF_NAME_PAD - padlen); *offset = *offset + lengthThisIdent; return fi; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)20393.12%233.33%
Ben Fennema104.59%116.67%
Marcin Ślusarz31.38%116.67%
Steven J. Magnani10.46%116.67%
Joe Perches10.46%116.67%
Total218100.00%6100.00%


struct short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, uint32_t *offset, int inc) { struct short_ad *sa; if ((!ptr) || (!offset)) { pr_err("%s: invalidparms\n", __func__); return NULL; } if ((*offset + sizeof(struct short_ad)) > maxoffset) return NULL; else { sa = (struct short_ad *)ptr; if (sa->extLength == 0) return NULL; } if (inc) *offset += sizeof(struct short_ad); return sa; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)8074.77%116.67%
Ben Fennema109.35%116.67%
Marcin Ślusarz87.48%233.33%
Pekka J Enberg54.67%116.67%
Joe Perches43.74%116.67%
Total107100.00%6100.00%


struct long_ad *udf_get_filelongad(uint8_t *ptr, int maxoffset, uint32_t *offset, int inc) { struct long_ad *la; if ((!ptr) || (!offset)) { pr_err("%s: invalidparms\n", __func__); return NULL; } if ((*offset + sizeof(struct long_ad)) > maxoffset) return NULL; else { la = (struct long_ad *)ptr; if (la->extLength == 0) return NULL; } if (inc) *offset += sizeof(struct long_ad); return la; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)7973.83%116.67%
Ben Fennema1110.28%116.67%
Marcin Ślusarz87.48%233.33%
Pekka J Enberg54.67%116.67%
Joe Perches43.74%116.67%
Total107100.00%6100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)86865.56%517.24%
Linus Torvalds17713.37%13.45%
Ben Fennema14310.80%26.90%
Marcin Ślusarz695.21%517.24%
Jan Kara342.57%517.24%
Pekka J Enberg110.83%13.45%
Joe Perches90.68%26.90%
Steven J. Magnani50.38%310.34%
Christoph Hellwig40.30%26.90%
Michael Christie20.15%13.45%
Adrian Bunk10.08%13.45%
Al Viro10.08%13.45%
Cyrill V. Gorcunov0.00%00.00%
Total1324100.00%29100.00%
Directory: fs/udf
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.