aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2013-01-17 16:02:46 -0800
committerH. Peter Anvin <hpa@linux.intel.com>2013-01-17 16:03:17 -0800
commitfcb4cdf5a161495b04a4939297ddc6d8b05cfa20 (patch)
treed5f9569613791dfe0907c28b1fc5594b2b863664
parent193ab58135d38e155e9e04133957f788bef16c1c (diff)
downloadsyslinux-fcb4cdf5a161495b04a4939297ddc6d8b05cfa20.tar.gz
syslinux-fcb4cdf5a161495b04a4939297ddc6d8b05cfa20.tar.xz
syslinux-fcb4cdf5a161495b04a4939297ddc6d8b05cfa20.zip
core/fs: remove some stale functions, inode refcount debug
Remove some stale (16-bit compatibility) functions in fs.c. Add some debugging for inode refcounts. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--core/fs/fs.c118
-rw-r--r--core/include/fs.h3
2 files changed, 9 insertions, 112 deletions
diff --git a/core/fs/fs.c b/core/fs/fs.c
index 2ad33755..2c10fe95 100644
--- a/core/fs/fs.c
+++ b/core/fs/fs.c
@@ -40,9 +40,13 @@ struct inode *alloc_inode(struct fs_info *fs, uint32_t ino, size_t data)
*/
void put_inode(struct inode *inode)
{
- while (inode && --inode->refcnt == 0) {
+ while (inode) {
struct inode *dead = inode;
- inode = inode->parent;
+ int refcnt = --(dead->refcnt);
+ dprintf("put_inode %p name %s refcnt %u\n", dead, dead->name, refcnt);
+ if (refcnt)
+ break; /* We still have references */
+ inode = dead->parent;
if (dead->name)
free((char *)dead->name);
free(dead);
@@ -108,77 +112,11 @@ __export int open_config(void)
return fd;
}
-void pm_mangle_name(com32sys_t *regs)
-{
- const char *src = MK_PTR(regs->ds, regs->esi.w[0]);
- char *dst = MK_PTR(regs->es, regs->edi.w[0]);
-
- mangle_name(dst, src);
-}
-
__export void mangle_name(char *dst, const char *src)
{
this_fs->fs_ops->mangle_name(dst, src);
}
-void getfssec(com32sys_t *regs)
-{
- int sectors;
- bool have_more;
- uint32_t bytes_read;
- char *buf;
- struct file *file;
- uint16_t handle;
-
- sectors = regs->ecx.w[0];
-
- handle = regs->esi.w[0];
- file = handle_to_file(handle);
-
- buf = MK_PTR(regs->es, regs->ebx.w[0]);
- bytes_read = file->fs->fs_ops->getfssec(file, buf, sectors, &have_more);
-
- /*
- * If we reach EOF, the filesystem driver will have already closed
- * the underlying file... this really should be cleaner.
- */
- if (!have_more) {
- _close_file(file);
- regs->esi.w[0] = 0;
- }
-
- regs->ecx.l = bytes_read;
-}
-
-void getfsbytes(com32sys_t *regs)
-{
- int sectors;
- bool have_more;
- uint32_t bytes_read;
- char *buf;
- struct file *file;
- uint16_t handle;
-
- handle = regs->esi.w[0];
- file = handle_to_file(handle);
-
- sectors = regs->ecx.w[0] >> SECTOR_SHIFT(file->fs);
-
- buf = MK_PTR(regs->es, regs->ebx.w[0]);
- bytes_read = file->fs->fs_ops->getfssec(file, buf, sectors, &have_more);
-
- /*
- * If we reach EOF, the filesystem driver will have already closed
- * the underlying file... this really should be cleaner.
- */
- if (!have_more) {
- _close_file(file);
- regs->esi.w[0] = 0;
- }
-
- regs->ecx.l = bytes_read;
-}
-
size_t pmapi_read_file(uint16_t *handle, void *buf, size_t sectors)
{
bool have_more;
@@ -200,23 +138,6 @@ size_t pmapi_read_file(uint16_t *handle, void *buf, size_t sectors)
return bytes_read;
}
-void pm_searchdir(com32sys_t *regs)
-{
- char *name = MK_PTR(regs->ds, regs->edi.w[0]);
- int rv;
-
- rv = searchdir(name);
- if (rv < 0) {
- regs->esi.w[0] = 0;
- regs->eax.l = 0;
- regs->eflags.l |= EFLAGS_ZF;
- } else {
- regs->esi.w[0] = rv;
- regs->eax.l = handle_to_file(rv)->inode->size;
- regs->eflags.l &= ~EFLAGS_ZF;
- }
-}
-
int searchdir(const char *name)
{
static char root_name[] = "/";
@@ -443,28 +364,6 @@ __export int open_file(const char *name, struct com32_filedata *filedata)
return rv;
}
-void pm_open_file(com32sys_t *regs)
-{
- int rv;
- struct file *file;
- const char *name = MK_PTR(regs->es, regs->esi.w[0]);
- char mangled_name[FILENAME_MAX];
-
- dprintf("pm_open_file %s\n", name);
-
- mangle_name(mangled_name, name);
- rv = searchdir(mangled_name);
- if (rv < 0) {
- regs->eflags.l |= EFLAGS_CF;
- } else {
- file = handle_to_file(rv);
- regs->eflags.l &= ~EFLAGS_CF;
- regs->eax.l = file->inode->size;
- regs->ecx.w[0] = SECTOR_SIZE(file->fs);
- regs->esi.w[0] = rv;
- }
-}
-
__export void close_file(uint16_t handle)
{
struct file *file;
@@ -475,11 +374,6 @@ __export void close_file(uint16_t handle)
}
}
-void pm_close_file(com32sys_t *regs)
-{
- close_file(regs->esi.w[0]);
-}
-
/*
* it will do:
* initialize the memory management function;
diff --git a/core/include/fs.h b/core/include/fs.h
index 9d552787..5c13f5b5 100644
--- a/core/include/fs.h
+++ b/core/include/fs.h
@@ -7,6 +7,7 @@
#include <com32.h>
#include <stdio.h>
#include <sys/dirent.h>
+#include <dprintf.h>
#include "core.h"
#include "disk.h"
@@ -158,6 +159,8 @@ static inline void free_inode(struct inode * inode)
static inline struct inode *get_inode(struct inode *inode)
{
inode->refcnt++;
+ dprintf("get_inode %p name %s refcnt %d\n",
+ inode, inode->name, inode->refcnt);
return inode;
}