Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  *  linux/fs/hpfs/dentry.c
0004  *
0005  *  Mikulas Patocka (mikulas@artax.karlin.mff.cuni.cz), 1998-1999
0006  *
0007  *  dcache operations
0008  */
0009 
0010 #include "hpfs_fn.h"
0011 
0012 /*
0013  * Note: the dentry argument is the parent dentry.
0014  */
0015 
0016 static int hpfs_hash_dentry(const struct dentry *dentry, struct qstr *qstr)
0017 {
0018     unsigned long    hash;
0019     int      i;
0020     unsigned l = qstr->len;
0021 
0022     if (l == 1) if (qstr->name[0]=='.') goto x;
0023     if (l == 2) if (qstr->name[0]=='.' || qstr->name[1]=='.') goto x;
0024     hpfs_adjust_length(qstr->name, &l);
0025     /*if (hpfs_chk_name(qstr->name,&l))*/
0026         /*return -ENAMETOOLONG;*/
0027         /*return -ENOENT;*/
0028     x:
0029 
0030     hash = init_name_hash(dentry);
0031     for (i = 0; i < l; i++)
0032         hash = partial_name_hash(hpfs_upcase(hpfs_sb(dentry->d_sb)->sb_cp_table,qstr->name[i]), hash);
0033     qstr->hash = end_name_hash(hash);
0034 
0035     return 0;
0036 }
0037 
0038 static int hpfs_compare_dentry(const struct dentry *dentry,
0039         unsigned int len, const char *str, const struct qstr *name)
0040 {
0041     unsigned al = len;
0042     unsigned bl = name->len;
0043 
0044     hpfs_adjust_length(str, &al);
0045     /*hpfs_adjust_length(b->name, &bl);*/
0046 
0047     /*
0048      * 'str' is the nane of an already existing dentry, so the name
0049      * must be valid. 'name' must be validated first.
0050      */
0051 
0052     if (hpfs_chk_name(name->name, &bl))
0053         return 1;
0054     if (hpfs_compare_names(dentry->d_sb, str, al, name->name, bl, 0))
0055         return 1;
0056     return 0;
0057 }
0058 
0059 const struct dentry_operations hpfs_dentry_operations = {
0060     .d_hash     = hpfs_hash_dentry,
0061     .d_compare  = hpfs_compare_dentry,
0062 };