int umsdos_newentry (struct dentry *parent, struct umsdos_info *info) { int err, ret = -EEXIST; err = umsdos_find (parent, info); if (err && err == -ENOENT) { ret = umsdos_writeentry (parent, info, 0); Printk (("umsdos_writeentry EMD ret = %d\n", ret)); } return ret; }
/* #Specification: hard link / hidden name * When a hard link is created, the original file is renamed * to a hidden name. The name is "..LINKNNN" where NNN is a * number define from the entry offset in the EMD file. */ int umsdos_newhidden (struct dentry *parent, struct umsdos_info *info) { int ret; umsdos_parse ("..LINK", 6, info); info->entry.name_len = 0; ret = umsdos_find (parent, info); if (ret == -ENOENT || ret == 0) { info->entry.name_len = sprintf (info->entry.name, "..LINK%ld", info->f_pos); ret = 0; } return ret; }
/* Add a new entry in the emd file Return 0 if ok or a negative error code. Return -EEXIST if the entry already exist. Complete the information missing in info. */ int umsdos_newentry ( struct inode *dir, struct umsdos_info *info) { struct inode *emd_dir; int ret = umsdos_find (dir,info,&emd_dir); if (ret == 0){ ret = -EEXIST; }else if (ret == -ENOENT){ ret = umsdos_writeentry(dir,emd_dir,info,0); PRINTK (("umsdos_newentry EDM ret = %d\n",ret)); } iput (emd_dir); return ret; }
/* Locate an entry in a EMD directory. Return 0 if ok, errcod if not, generally -ENOENT. */ int umsdos_findentry ( struct inode *dir, struct umsdos_info *info, int expect) /* 0: anything */ /* 1: file */ /* 2: directory */ { struct inode *emd_dir; int ret = umsdos_find (dir,info,&emd_dir); if (ret == 0){ if (expect != 0){ if (S_ISDIR(info->entry.mode)){ if (expect != 2) ret = -EISDIR; }else if (expect == 2){ ret = -ENOTDIR; } } } iput (emd_dir); return ret; }
/* Create a new hidden link. Return 0 if ok, an error code if not. */ int umsdos_newhidden ( struct inode *dir, struct umsdos_info *info) { struct inode *emd_dir; int ret; umsdos_parse ("..LINK",6,info); info->entry.name_len = 0; ret = umsdos_find (dir,info,&emd_dir); iput (emd_dir); if (ret == -ENOENT || ret == 0){ /* #Specification: hard link / hidden name When a hard link is created, the original file is renamed to a hidden name. The name is "..LINKNNN" where NNN is a number define from the entry offset in the EMD file. */ info->entry.name_len = sprintf (info->entry.name,"..LINK%ld" ,info->f_pos); ret = 0; } return ret; }
int umsdos_findentry (struct dentry *parent, struct umsdos_info *info, int expect) { int ret; ret = umsdos_find (parent, info); if (ret) goto out; switch (expect) { case 1: if (S_ISDIR (info->entry.mode)) ret = -EISDIR; break; case 2: if (!S_ISDIR (info->entry.mode)) ret = -ENOTDIR; } out: Printk (("umsdos_findentry: returning %d\n", ret)); return ret; }
int umsdos_delentry (struct dentry *parent, struct umsdos_info *info, int isdir) { int ret; ret = umsdos_find (parent, info); if (ret) goto out; if (info->entry.name_len == 0) goto out; if ((isdir != 0) != (S_ISDIR (info->entry.mode) != 0)) { if (S_ISDIR (info->entry.mode)) { ret = -EISDIR; } else { ret = -ENOTDIR; } goto out; } ret = umsdos_writeentry (parent, info, 1); out: return ret; }
/* Remove an entry from the emd file Return 0 if ok, a negative error code otherwise. Complete the information missing in info. */ int umsdos_delentry ( struct inode *dir, struct umsdos_info *info, int isdir) { struct inode *emd_dir; int ret = umsdos_find (dir,info,&emd_dir); if (ret == 0){ if (info->entry.name_len != 0){ if ((isdir != 0) != (S_ISDIR(info->entry.mode) != 0)){ if (S_ISDIR(info->entry.mode)){ ret = -EISDIR; }else{ ret = -ENOTDIR; } }else{ ret = umsdos_writeentry(dir,emd_dir,info,1); } } } iput(emd_dir); return ret; }