dosfstools  4.2
About: dosfstools are utilities to create, check and label (MS-DOS) FAT filesystems.
  Fossies Dox: dosfstools-4.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

lfn.c File Reference
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <time.h>
#include "common.h"
#include "io.h"
#include "fsck.fat.h"
#include "lfn.h"
#include "file.h"
Include dependency graph for lfn.c:

Go to the source code of this file.

Data Structures

struct  LFN_ENT
 

Macros

#define LFN_ID_START   0x40
 
#define LFN_ID_SLOTMASK   0x1f
 
#define CHARS_PER_LFN   13
 
#define UNICODE_CONVERTABLE(cl, ch)   (ch == 0 && (cl < 0x80 || cl >= 0xa0))
 
#define UNTIL_0   INT_MAX
 
#define CNV_PARTS_SO_FAR()
 
#define BYTES_TO_WCHAR(cl, ch)   ((wchar_t)((unsigned)(cl) + ((unsigned)(ch) << 8)))
 

Functions

static size_t mbslen (wchar_t x)
 
static size_t wctombs (char *dest, wchar_t x)
 
static char * cnv_unicode (const unsigned char *uni, int maxlen, int use_q)
 
static void copy_lfn_part (unsigned char *dst, LFN_ENT *lfn)
 
static char * cnv_this_part (LFN_ENT *lfn)
 
static void clear_lfn_slots (int start, int end)
 
void lfn_fix_checksum (off_t from, off_t to, const char *short_name)
 
void lfn_reset (void)
 
void lfn_add_slot (DIR_ENT *de, off_t dir_offset)
 
char * lfn_get (DIR_ENT *de, off_t *lfn_offset)
 
void lfn_check_orphaned (void)
 

Variables

unsigned char * lfn_unicode = NULL
 
unsigned char lfn_checksum
 
int lfn_slot = -1
 
off_t * lfn_offsets = NULL
 
int lfn_parts = 0
 
static unsigned char fat_uni2esc [64]
 

Macro Definition Documentation

◆ BYTES_TO_WCHAR

#define BYTES_TO_WCHAR (   cl,
  ch 
)    ((wchar_t)((unsigned)(cl) + ((unsigned)(ch) << 8)))

Definition at line 83 of file lfn.c.

◆ CHARS_PER_LFN

#define CHARS_PER_LFN   13

Definition at line 51 of file lfn.c.

◆ CNV_PARTS_SO_FAR

#define CNV_PARTS_SO_FAR ( )
Value:
int lfn_slot
Definition: lfn.c:56
static char * cnv_unicode(const unsigned char *uni, int maxlen, int use_q)
Definition: lfn.c:102
int lfn_parts
Definition: lfn.c:58
#define CHARS_PER_LFN
Definition: lfn.c:51
unsigned char * lfn_unicode
Definition: lfn.c:54

Definition at line 79 of file lfn.c.

◆ LFN_ID_SLOTMASK

#define LFN_ID_SLOTMASK   0x1f

Definition at line 49 of file lfn.c.

◆ LFN_ID_START

#define LFN_ID_START   0x40

Definition at line 48 of file lfn.c.

◆ UNICODE_CONVERTABLE

#define UNICODE_CONVERTABLE (   cl,
  ch 
)    (ch == 0 && (cl < 0x80 || cl >= 0xa0))

Definition at line 72 of file lfn.c.

◆ UNTIL_0

#define UNTIL_0   INT_MAX

Definition at line 75 of file lfn.c.

Function Documentation

◆ clear_lfn_slots()

static void clear_lfn_slots ( int  start,
int  end 
)
static

Definition at line 158 of file lfn.c.

References DELETED_FLAG, fs_write(), LFN_ENT::id, and lfn_offsets.

Referenced by lfn_add_slot(), lfn_check_orphaned(), and lfn_get().

◆ cnv_this_part()

static char* cnv_this_part ( LFN_ENT lfn)
inlinestatic

Definition at line 151 of file lfn.c.

References CHARS_PER_LFN, cnv_unicode(), and copy_lfn_part().

Referenced by lfn_add_slot().

◆ cnv_unicode()

static char* cnv_unicode ( const unsigned char *  uni,
int  maxlen,
int  use_q 
)
static

Definition at line 102 of file lfn.c.

References alloc(), BYTES_TO_WCHAR, fat_uni2esc, mbslen(), mem_queue, qalloc(), UNICODE_CONVERTABLE, and wctombs().

Referenced by cnv_this_part(), and lfn_get().

◆ copy_lfn_part()

static void copy_lfn_part ( unsigned char *  dst,
LFN_ENT lfn 
)
static

Definition at line 143 of file lfn.c.

References LFN_ENT::name0_4, LFN_ENT::name11_12, and LFN_ENT::name5_10.

Referenced by cnv_this_part(), and lfn_add_slot().

◆ lfn_add_slot()

◆ lfn_check_orphaned()

void lfn_check_orphaned ( void  )

Definition at line 512 of file lfn.c.

References clear_lfn_slots(), CNV_PARTS_SO_FAR, get_choice(), lfn_parts, lfn_reset(), and lfn_slot.

Referenced by add_file(), lfn_add_slot(), scan_dir(), and scan_root().

◆ lfn_fix_checksum()

void lfn_fix_checksum ( off_t  from,
off_t  to,
const char *  short_name 
)

Definition at line 175 of file lfn.c.

References fs_write().

◆ lfn_get()

◆ lfn_reset()

void lfn_reset ( void  )

Definition at line 187 of file lfn.c.

References lfn_offsets, lfn_slot, and lfn_unicode.

Referenced by lfn_add_slot(), lfn_check_orphaned(), lfn_get(), and new_dir().

◆ mbslen()

static size_t mbslen ( wchar_t  x)
static

Definition at line 84 of file lfn.c.

Referenced by cnv_unicode().

◆ wctombs()

static size_t wctombs ( char *  dest,
wchar_t  x 
)
static

Definition at line 90 of file lfn.c.

Referenced by cnv_unicode().

Variable Documentation

◆ fat_uni2esc

unsigned char fat_uni2esc[64]
static
Initial value:
= {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z', '+', '-'
}

Definition at line 60 of file lfn.c.

Referenced by cnv_unicode().

◆ lfn_checksum

unsigned char lfn_checksum

Definition at line 55 of file lfn.c.

Referenced by lfn_add_slot(), and lfn_get().

◆ lfn_offsets

off_t* lfn_offsets = NULL

Definition at line 57 of file lfn.c.

Referenced by clear_lfn_slots(), lfn_add_slot(), lfn_get(), and lfn_reset().

◆ lfn_parts

int lfn_parts = 0

Definition at line 58 of file lfn.c.

Referenced by lfn_add_slot(), lfn_check_orphaned(), and lfn_get().

◆ lfn_slot

int lfn_slot = -1

Definition at line 56 of file lfn.c.

Referenced by lfn_add_slot(), lfn_check_orphaned(), lfn_get(), and lfn_reset().

◆ lfn_unicode

unsigned char* lfn_unicode = NULL

Definition at line 54 of file lfn.c.

Referenced by lfn_add_slot(), lfn_get(), and lfn_reset().