9
0
Fork 0

Move MSC descriptors to a separate file; File 13 char long file names.

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@3983 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2011-09-27 22:04:03 +00:00
parent 79fe4a0ee5
commit 6f0ce181dc
7 changed files with 330 additions and 505 deletions

View File

@ -2107,4 +2107,7 @@
potential crash when using mq_timedreceived() and mq_timedsend().
* sched/mq_sndinternal.c: Related to the above, the send logic was incrementing
the wrong counter when it waited as part of the mq_timedsend.c logic.
* fs/fat: Fix an error in the long file name logic: If the long file name
is an even multiple of 13 bytes in length, then it should not include a
NULL terminating character. Fix contributed by Kaushal Parikh.

View File

@ -46,7 +46,11 @@ ifeq ($(CONFIG_CDCSER),y)
endif
ifeq ($(CONFIG_USBSTRG),y)
CSRCS += usbdev_storage.c usbdev_scsi.c
CSRCS += usbdev_storage.c usbdev_stordesc.c usbdev_scsi.c
endif
ifeq ($(CONFIG_USBDEV_COMPOSITE),y)
CSRCS += usbdev_composite.c
endif
CSRCS += usbdev_trace.c usbdev_trprintf.c

View File

@ -365,14 +365,14 @@ static const struct usb_qualdesc_s g_qualdesc =
****************************************************************************/
/****************************************************************************
* Name: usbclass_mkstrdesc
* Name: cdcser_mkstrdesc
*
* Description:
* Construct a string descriptor
*
****************************************************************************/
int usbclass_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
int cdcser_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
{
const char *str;
int len;
@ -441,20 +441,20 @@ int usbclass_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
}
/****************************************************************************
* Name: usbclass_getepdesc
* Name: cdcser_getepdesc
*
* Description:
* Return a pointer to the raw device descriptor
*
****************************************************************************/
FAR const struct usb_devdesc_s *usbclass_getdevdesc(void)
FAR const struct usb_devdesc_s *cdcser_getdevdesc(void)
{
return &g_devdesc;
}
/****************************************************************************
* Name: usbclass_getepdesc
* Name: cdcser_getepdesc
*
* Description:
* Return a pointer to the raw endpoint struct (used for configuring
@ -462,7 +462,7 @@ FAR const struct usb_devdesc_s *usbclass_getdevdesc(void)
*
****************************************************************************/
FAR const struct usb_epdesc_s *usbclass_getepdesc(enum cdcser_epdesc_e epid)
FAR const struct usb_epdesc_s *cdcser_getepdesc(enum cdcser_epdesc_e epid)
{
switch (epid)
{
@ -481,7 +481,7 @@ FAR const struct usb_epdesc_s *usbclass_getepdesc(enum cdcser_epdesc_e epid)
}
/****************************************************************************
* Name: usbclass_mkepdesc
* Name: cdcser_mkepdesc
*
* Description:
* Construct the endpoint descriptor using the correct max packet size.
@ -489,15 +489,14 @@ FAR const struct usb_epdesc_s *usbclass_getepdesc(enum cdcser_epdesc_e epid)
****************************************************************************/
#ifdef CONFIG_USBDEV_DUALSPEED
void usbclass_mkepdesc(num cdcser_epdesc_e epid,
uint16_t mxpacket,
FAR struct usb_epdesc_s *outdesc)
void cdcser_mkepdesc(num cdcser_epdesc_e epid, uint16_t mxpacket,
FAR struct usb_epdesc_s *outdesc)
{
FAR const struct usb_epdesc_s *indesc;
/* Copy the "canned" descriptor */
indesc = usbclass_getepdesc(epid)
indesc = cdcser_getepdesc(epid)
memcpy(outdesc, indesc, USB_SIZEOF_EPDESC);
/* Then add the correct max packet size */
@ -508,7 +507,7 @@ void usbclass_mkepdesc(num cdcser_epdesc_e epid,
#endif
/****************************************************************************
* Name: usbclass_mkcfgdesc
* Name: cdcser_mkcfgdesc
*
* Description:
* Construct the configuration descriptor
@ -516,9 +515,9 @@ void usbclass_mkepdesc(num cdcser_epdesc_e epid,
****************************************************************************/
#ifdef CONFIG_USBDEV_DUALSPEED
int16_t usbclass_mkcfgdesc(FAR uint8_t *buf, uint8_t speed, uint8_t type)
int16_t cdcser_mkcfgdesc(FAR uint8_t *buf, uint8_t speed, uint8_t type)
#else
int16_t usbclass_mkcfgdesc(FAR uint8_t *buf)
int16_t cdcser_mkcfgdesc(FAR uint8_t *buf)
#endif
{
FAR const struct cfgdecsc_group_s *group;
@ -554,7 +553,7 @@ int16_t usbclass_mkcfgdesc(FAR uint8_t *buf)
#ifdef CONFIG_USBDEV_DUALSPEED
if (highspeed && group->hsepsize != 0)
{
usbclass_mkepdesc(group->desc, group->hsepsize,
cdcser_mkepdesc(group->desc, group->hsepsize,
(FAR struct usb_epdesc_s*)dest);
}
else
@ -576,7 +575,7 @@ int16_t usbclass_mkcfgdesc(FAR uint8_t *buf)
}
/****************************************************************************
* Name: usbclass_getqualdesc
* Name: cdcser_getqualdesc
*
* Description:
* Return a pointer to the raw qual descriptor
@ -584,7 +583,7 @@ int16_t usbclass_mkcfgdesc(FAR uint8_t *buf)
****************************************************************************/
#ifdef CONFIG_USBDEV_DUALSPEED
FAR const struct usb_qualdesc_s *usbclass_getqualdesc(void)
FAR const struct usb_qualdesc_s *cdcser_getqualdesc(void)
{
return &g_qualdesc;
}

File diff suppressed because it is too large Load Diff

View File

@ -118,12 +118,6 @@ static struct usbdev_req_s *usbstrg_allocreq(FAR struct usbdev_ep_s *ep,
uint16_t len);
static void usbstrg_freereq(FAR struct usbdev_ep_s *ep,
FAR struct usbdev_req_s *req);
static int usbstrg_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc);
#ifdef CONFIG_USBDEV_DUALSPEED
static int16_t usbstrg_mkcfgdesc(uint8_t *buf, uint8_t speed, uint8_t type);
#else
static int16_t usbstrg_mkcfgdesc(uint8_t *buf);
#endif
/* Class Driver Operations (most at interrupt level) ************************/
@ -154,125 +148,9 @@ static struct usbdevclass_driverops_s g_driverops =
NULL /* resume */
};
/* Descriptors **************************************************************/
/* Device descriptor */
static const struct usb_devdesc_s g_devdesc =
{
USB_SIZEOF_DEVDESC, /* len */
USB_DESC_TYPE_DEVICE, /* type */
{LSBYTE(0x0200), MSBYTE(0x0200)}, /* usb */
USB_CLASS_PER_INTERFACE, /* class */
0, /* subclass */
0, /* protocol */
CONFIG_USBSTRG_EP0MAXPACKET, /* maxpacketsize */
{ LSBYTE(CONFIG_USBSTRG_VENDORID), /* vendor */
MSBYTE(CONFIG_USBSTRG_VENDORID) },
{ LSBYTE(CONFIG_USBSTRG_PRODUCTID), /* product */
MSBYTE(CONFIG_USBSTRG_PRODUCTID) },
{ LSBYTE(CONFIG_USBSTRG_VERSIONNO), /* device */
MSBYTE(CONFIG_USBSTRG_VERSIONNO) },
USBSTRG_MANUFACTURERSTRID, /* imfgr */
USBSTRG_PRODUCTSTRID, /* iproduct */
USBSTRG_SERIALSTRID, /* serno */
USBSTRG_NCONFIGS /* nconfigs */
};
/* Configuration descriptor */
static const struct usb_cfgdesc_s g_cfgdesc =
{
USB_SIZEOF_CFGDESC, /* len */
USB_DESC_TYPE_CONFIG, /* type */
{0, 0}, /* totallen -- to be provided */
USBSTRG_NINTERFACES, /* ninterfaces */
USBSTRG_CONFIGID, /* cfgvalue */
USBSTRG_CONFIGSTRID, /* icfg */
USB_CONFIG_ATTR_ONE|SELFPOWERED|REMOTEWAKEUP, /* attr */
(CONFIG_USBDEV_MAXPOWER + 1) / 2 /* mxpower */
};
/* Single interface descriptor */
static const struct usb_ifdesc_s g_ifdesc =
{
USB_SIZEOF_IFDESC, /* len */
USB_DESC_TYPE_INTERFACE, /* type */
USBSTRG_INTERFACEID, /* ifno */
USBSTRG_ALTINTERFACEID, /* alt */
USBSTRG_NENDPOINTS, /* neps */
USB_CLASS_MASS_STORAGE, /* class */
USBSTRG_SUBCLASS_SCSI, /* subclass */
USBSTRG_PROTO_BULKONLY, /* protocol */
USBSTRG_CONFIGSTRID /* iif */
};
/* Endpoint descriptors */
static const struct usb_epdesc_s g_fsepbulkoutdesc =
{
USB_SIZEOF_EPDESC, /* len */
USB_DESC_TYPE_ENDPOINT, /* type */
USBSTRG_EPOUTBULK_ADDR, /* addr */
USBSTRG_EPOUTBULK_ATTR, /* attr */
{ LSBYTE(USBSTRG_FSBULKMAXPACKET), /* maxpacket */
MSBYTE(USBSTRG_FSBULKMAXPACKET) },
0 /* interval */
};
static const struct usb_epdesc_s g_fsepbulkindesc =
{
USB_SIZEOF_EPDESC, /* len */
USB_DESC_TYPE_ENDPOINT, /* type */
USBSTRG_EPINBULK_ADDR, /* addr */
USBSTRG_EPINBULK_ATTR, /* attr */
{ LSBYTE(USBSTRG_FSBULKMAXPACKET), /* maxpacket */
MSBYTE(USBSTRG_FSBULKMAXPACKET) },
0 /* interval */
};
#ifdef CONFIG_USBDEV_DUALSPEED
static const struct usb_qualdesc_s g_qualdesc =
{
USB_SIZEOF_QUALDESC, /* len */
USB_DESC_TYPE_DEVICEQUALIFIER, /* type */
{LSBYTE(0x0200), MSBYTE(0x0200) }, /* USB */
USB_CLASS_PER_INTERFACE, /* class */
0, /* subclass */
0, /* protocol */
CONFIG_USBSTRG_EP0MAXPACKET, /* mxpacketsize */
USBSTRG_NCONFIGS, /* nconfigs */
0, /* reserved */
};
static const struct usb_epdesc_s g_hsepbulkoutdesc =
{
USB_SIZEOF_EPDESC, /* len */
USB_DESC_TYPE_ENDPOINT, /* type */
USBSTRG_EPOUTBULK_ADDR, /* addr */
USBSTRG_EPOUTBULK_ATTR, /* attr */
{ LSBYTE(USBSTRG_HSBULKMAXPACKET), /* maxpacket */
MSBYTE(USBSTRG_HSBULKMAXPACKET) },
0 /* interval */
};
static const struct usb_epdesc_s g_hsepbulkindesc =
{
USB_SIZEOF_EPDESC, /* len */
USB_DESC_TYPE_ENDPOINT, /* type */
USBSTRG_EPINBULK_ADDR, /* addr */
USBSTRG_EPINBULK_ATTR, /* attr */
{ LSBYTE(USBSTRG_HSBULKMAXPACKET), /* maxpacket */
MSBYTE(USBSTRG_HSBULKMAXPACKET) },
0 /* interval */
};
#endif
/****************************************************************************
* Public Data
****************************************************************************/
/* String *******************************************************************/
const char g_vendorstr[] = CONFIG_USBSTRG_VENDORSTR;
@ -351,141 +229,6 @@ static void usbstrg_freereq(FAR struct usbdev_ep_s *ep, struct usbdev_req_s *req
}
}
/****************************************************************************
* Name: usbstrg_mkstrdesc
*
* Description:
* Construct a string descriptor
*
****************************************************************************/
static int usbstrg_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
{
const char *str;
int len;
int ndata;
int i;
switch (id)
{
case 0:
{
/* Descriptor 0 is the language id */
strdesc->len = 4;
strdesc->type = USB_DESC_TYPE_STRING;
strdesc->data[0] = LSBYTE(USBSTRG_STR_LANGUAGE);
strdesc->data[1] = MSBYTE(USBSTRG_STR_LANGUAGE);
return 4;
}
case USBSTRG_MANUFACTURERSTRID:
str = g_vendorstr;
break;
case USBSTRG_PRODUCTSTRID:
str = g_productstr;
break;
case USBSTRG_SERIALSTRID:
str = g_serialstr;
break;
case USBSTRG_CONFIGSTRID:
str = CONFIG_USBSTRG_CONFIGSTR;
break;
default:
return -EINVAL;
}
/* The string is utf16-le. The poor man's utf-8 to utf16-le
* conversion below will only handle 7-bit en-us ascii
*/
len = strlen(str);
for (i = 0, ndata = 0; i < len; i++, ndata += 2)
{
strdesc->data[ndata] = str[i];
strdesc->data[ndata+1] = 0;
}
strdesc->len = ndata+2;
strdesc->type = USB_DESC_TYPE_STRING;
return strdesc->len;
}
/****************************************************************************
* Name: usbstrg_mkcfgdesc
*
* Description:
* Construct the configuration descriptor
*
****************************************************************************/
#ifdef CONFIG_USBDEV_DUALSPEED
static int16_t usbstrg_mkcfgdesc(uint8_t *buf, uint8_t speed, uint8_t type)
#else
static int16_t usbstrg_mkcfgdesc(uint8_t *buf)
#endif
{
FAR struct usb_cfgdesc_s *cfgdesc = (struct usb_cfgdesc_s*)buf;
#ifdef CONFIG_USBDEV_DUALSPEED
FAR const struct usb_epdesc_s *epdesc;
bool hispeed = (speed == USB_SPEED_HIGH);
uint16_t bulkmxpacket;
#endif
uint16_t totallen;
/* This is the total length of the configuration (not necessarily the
* size that we will be sending now.
*/
totallen = USB_SIZEOF_CFGDESC + USB_SIZEOF_IFDESC + USBSTRG_NENDPOINTS * USB_SIZEOF_EPDESC;
/* Configuration descriptor -- Copy the canned descriptor and fill in the
* type (we'll also need to update the size below
*/
memcpy(cfgdesc, &g_cfgdesc, USB_SIZEOF_CFGDESC);
buf += USB_SIZEOF_CFGDESC;
/* Copy the canned interface descriptor */
memcpy(buf, &g_ifdesc, USB_SIZEOF_IFDESC);
buf += USB_SIZEOF_IFDESC;
/* Make the two endpoint configurations */
#ifdef CONFIG_USBDEV_DUALSPEED
/* Check for switches between high and full speed */
hispeed = (speed == USB_SPEED_HIGH);
if (type == USB_DESC_TYPE_OTHERSPEEDCONFIG)
{
hispeed = !hispeed;
}
bulkmxpacket = USBSTRG_BULKMAXPACKET(hispeed);
epdesc = USBSTRG_EPBULKINDESC(hispeed);
memcpy(buf, epdesc, USB_SIZEOF_EPDESC);
buf += USB_SIZEOF_EPDESC;
epdesc = USBSTRG_EPBULKOUTDESC(hispeed);
memcpy(buf, epdesc, USB_SIZEOF_EPDESC);
#else
memcpy(buf, &g_fsepbulkoutdesc, USB_SIZEOF_EPDESC);
buf += USB_SIZEOF_EPDESC;
memcpy(buf, &g_fsepbulkindesc, USB_SIZEOF_EPDESC);
#endif
/* Finally, fill in the total size of the configuration descriptor */
cfgdesc->totallen[0] = LSBYTE(totallen);
cfgdesc->totallen[1] = MSBYTE(totallen);
return totallen;
}
/****************************************************************************
* Class Driver Interfaces
****************************************************************************/
@ -795,7 +538,7 @@ static int usbstrg_setup(FAR struct usbdev_s *dev,
case USB_DESC_TYPE_DEVICE:
{
ret = USB_SIZEOF_DEVDESC;
memcpy(ctrlreq->buf, &g_devdesc, ret);
memcpy(ctrlreq->buf, usbstrg_getdevdesc(), ret);
}
break;
@ -803,7 +546,7 @@ static int usbstrg_setup(FAR struct usbdev_s *dev,
case USB_DESC_TYPE_DEVICEQUALIFIER:
{
ret = USB_SIZEOF_QUALDESC;
memcpy(ctrlreq->buf, &g_qualdesc, ret);
memcpy(ctrlreq->buf, usbstrg_getqualdesc(), ret);
}
break;
@ -1151,7 +894,8 @@ int usbstrg_setconfig(FAR struct usbstrg_dev_s *priv, uint8_t config)
epdesc = USBSTRG_EPBULKINDESC(hispeed);
ret = EP_CONFIGURE(priv->epbulkin, epdesc, false);
#else
ret = EP_CONFIGURE(priv->epbulkin, &g_fsepbulkindesc, false);
ret = EP_CONFIGURE(priv->epbulkin,
usbstrg_getepdesc(USBSTRG_EPFSBULKIN), false);
#endif
if (ret < 0)
{
@ -1167,7 +911,8 @@ int usbstrg_setconfig(FAR struct usbstrg_dev_s *priv, uint8_t config)
epdesc = USBSTRG_EPBULKOUTDESC(hispeed);
ret = EP_CONFIGURE(priv->epbulkout, epdesc, true);
#else
ret = EP_CONFIGURE(priv->epbulkout, &g_fsepbulkoutdesc, true);
ret = EP_CONFIGURE(priv->epbulkout,
usbstrg_getepdesc(USBSTRG_EPFSBULKOUT), true);
#endif
if (ret < 0)
{

View File

@ -1,7 +1,7 @@
/****************************************************************************
* drivers/usbdev/usbdev_storage.h
*
* Copyright (C) 2008-2010 Gregory Nutt. All rights reserved.
* Copyright (C) 2008-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Mass storage class device. Bulk-only with SCSI subclass.
@ -57,9 +57,7 @@
/****************************************************************************
* Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* Number of requests in the write queue */
#ifndef CONFIG_USBSTRG_NWRREQS
@ -303,9 +301,11 @@
/* Macros for dual speed vs. full speed only operation */
#ifdef CONFIG_USBDEV_DUALSPEED
# define USBSTRG_EPBULKINDESC(hs) ((hs) ? (&g_hsepbulkindesc) : (&g_fsepbulkindesc))
# define USBSTRG_EPBULKOUTDESC(hs) ((hs) ? (&g_hsepbulkoutdesc) : (&g_fsepbulkoutdesc))
#ifdef CONFIG_USBDEV_DUALSPEED
# define USBSTRG_EPBULKINDESC(hs) \
usbstrg_getepdesc((hs) ? USBSTRG_EPHSBULKIN : USBSTRG_EPFSBULKIN)
# define USBSTRG_EPBULKOUTDESC(hs) \
usbstrg_getepdesc((hs) ? USBSTRG_EPHSBULKOUT : USBSTRG_EPFSBULKOUT)
# define USBSTRG_BULKMAXPACKET(hs) \
((hs) ? USBSTRG_HSBULKMAXPACKET : USBSTRG_FSBULKMAXPACKET)
# define USBSTRG_BULKMXPKTSHIFT(d) \
@ -313,8 +313,8 @@
# define USBSTRG_BULKMXPKTMASK(d) \
(((d)->speed==USB_SPEED_HIGH) ? USBSTRG_HSBULKMXPKTMASK : USBSTRG_FSBULKMXPKTMASK)
#else
# define USBSTRG_EPBULKINDESC(d) (g_fsepbulkindesc))
# define USBSTRG_EPBULKOUTDESC(d) (g_fsepbulkoutdesc))
# define USBSTRG_EPBULKINDESC(d) usbstrg_getepdesc(USBSTRG_EPFSBULKIN)
# define USBSTRG_EPBULKOUTDESC(d) usbstrg_getepdesc(USBSTRG_EPFSBULKOUT)
# define USBSTRG_BULKMAXPACKET(hs) USBSTRG_FSBULKMAXPACKET
# define USBSTRG_BULKMXPKTSHIFT(d) USBSTRG_FSBULKMXPKTSHIFT
# define USBSTRG_BULKMXPKTMASK(d) USBSTRG_FSBULKMXPKTMASK
@ -339,6 +339,18 @@
/****************************************************************************
* Public Types
****************************************************************************/
/* Endpoint descriptors */
enum usbstrg_epdesc_e
{
USBSTRG_EPFSBULKOUT = 0, /* Full speed bulk OUT endpoint descriptor */
USBSTRG_EPFSBULKIN /* Full speed bulk IN endpoint descriptor */
#ifdef CONFIG_USBDEV_DUALSPEED
,
USBSTRG_EPHSBULKOUT, /* High speed bulk OUT endpoint descriptor */
USBSTRG_EPHSBULKIN /* High speed bulk IN endpoint descriptor */
#endif
};
/* Container to support a list of requests */
@ -450,6 +462,64 @@ EXTERN const char g_serialstr[];
* Public Function Prototypes
************************************************************************************/
/************************************************************************************
* Name: usbstrg_mkstrdesc
*
* Description:
* Construct a string descriptor
*
************************************************************************************/
struct usb_strdesc_s;
int usbstrg_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc);
/************************************************************************************
* Name: usbstrg_getepdesc
*
* Description:
* Return a pointer to the raw device descriptor
*
************************************************************************************/
FAR const struct usb_devdesc_s *usbstrg_getdevdesc(void);
/************************************************************************************
* Name: usbstrg_getepdesc
*
* Description:
* Return a pointer to the raw endpoint descriptor (used for configuring endpoints)
*
************************************************************************************/
struct usb_epdesc_s;
FAR const struct usb_epdesc_s *usbstrg_getepdesc(enum usbstrg_epdesc_e epid);
/************************************************************************************
* Name: usbstrg_mkcfgdesc
*
* Description:
* Construct the configuration descriptor
*
************************************************************************************/
#ifdef CONFIG_USBDEV_DUALSPEED
int16_t usbstrg_mkcfgdesc(FAR uint8_t *buf, uint8_t speed, uint8_t type);
#else
int16_t usbstrg_mkcfgdesc(FAR uint8_t *buf);
#endif
/************************************************************************************
* Name: usbstrg_getqualdesc
*
* Description:
* Return a pointer to the raw qual descriptor
*
************************************************************************************/
#ifdef CONFIG_USBDEV_DUALSPEED
FAR const struct usb_qualdesc_s *usbstrg_getqualdesc(void);
#endif
/****************************************************************************
* Name: usbstrg_workerthread
*

View File

@ -1123,25 +1123,31 @@ static bool fat_cmplfname(const uint8_t *direntry, const uint8_t *substr)
int len;
bool match;
/* How much of string do we have to compare? (including the NUL
* terminator).
*/
/* How much of string do we have to compare? */
len = strlen((char*)substr) + 1;
len = strlen((char*)substr);
/* Check bytes 1-5 */
chunk = LDIR_PTRWCHAR1_5(direntry);
match = fat_cmplfnchunk(chunk, substr, 5);
if (match && len > 5)
if (match && len >= 5)
{
/* Check bytes 6-11 */
/* Check bytes 6-11. Note that len == 5, the substring passed to
* fat_cmplfnchunk() will point to the NUL terminator of substr.
* In this case, fat_cmplfnchunk() will only verify that the
* directory entry is also NUL terminated.
*/
chunk = LDIR_PTRWCHAR6_11(direntry);
match = fat_cmplfnchunk(chunk, &substr[5], 6);
if (match && len > 11)
if (match && len >= 11)
{
/* Check bytes 12-13 */
/* Check bytes 12-13. Note that len == 11, the substring passed to
* fat_cmplfnchunk() will point to the NUL terminator of substr.
* In this case, fat_cmplfnchunk() will only verify that the
* directory entry is also NUL terminated.
*/
chunk = LDIR_PTRWCHAR12_13(direntry);
match = fat_cmplfnchunk(chunk, &substr[11], 2);
@ -1181,11 +1187,9 @@ static inline int fat_findlfnentry(struct fat_mountpt_s *fs,
/* Get the length of the long file name (size of the fd_lfname array is
* LDIR_MAXFNAME+1 we do not have to check the length of the string).
* NOTE that the name length is incremented to include the NUL terminating
* character that must also be written to the directory entry.
*/
namelen = strlen((char*)dirinfo->fd_lfname) + 1;
namelen = strlen((char*)dirinfo->fd_lfname);
DEBUGASSERT(namelen <= LDIR_MAXFNAME+1);
/* How many LFN directory entries are we expecting? */
@ -1483,11 +1487,9 @@ static inline int fat_allocatelfnentry(struct fat_mountpt_s *fs,
/* Get the length of the long file name (size of the fd_lfname array is
* LDIR_MAXFNAME+1 we do not have to check the length of the string).
* NOTE that the name length is incremented to include the NUL terminating
* character that must also be written to the directory entry.
*/
namelen = strlen((char *)dirinfo->fd_lfname) + 1;
namelen = strlen((char *)dirinfo->fd_lfname);
DEBUGASSERT(namelen <= LDIR_MAXFNAME+1);
/* How many LFN directory entries are we expecting? */
@ -2018,11 +2020,13 @@ static int fat_putlfname(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo
/* Get the length of the long file name (size of the fd_lfname array is
* LDIR_MAXFNAME+1 we do not have to check the length of the string).
* NOTE that the name length is incremented to include the NUL terminating
* character that must also be written to the directory entry.
* NOTE that remainder is conditionally incremented to include the NUL
* terminating character that may also need be written to the directory
* entry. NUL terminating is not required if length is multiple of
* LDIR_MAXLFNCHARS (13).
*/
namelen = strlen((char*)dirinfo->fd_lfname) + 1;
namelen = strlen((char*)dirinfo->fd_lfname);
DEBUGASSERT(namelen <= LDIR_MAXFNAME+1);
/* How many LFN directory entries do we need to write? */
@ -2033,6 +2037,7 @@ static int fat_putlfname(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo
if (remainder > 0)
{
nentries++;
remainder++;
}
DEBUGASSERT(nentries > 0 && nentries <= LDIR_MAXLFNS);