<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>change log for rtems (2010-04-30)</title>
</head>
<body text='#000000' bgcolor='#ffffff'>
<a name='cs1'></a>
<table border='0' cellspacing='0' cellpadding='5' width='100%' bgcolor='#eeeeee'>
<tr><td colspan='3' bgcolor='#dddddd'>
<font color='#bb2222'><strong>sh</strong></font>
</td></tr>
<tr><td colspan='3' bgcolor='#dddddd'><pre>2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
* posix/src/alarm.c, posix/src/psignal.c, posix/src/ualarm.c:
Moved watchdog control objects to reduce dependencies.
</pre></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/ChangeLog.diff?r1=text&tr1=1.2281&r2=text&tr2=1.2282&diff_format=h">M</a></td><td width='1%'>1.2282</td><td width='100%'>cpukit/ChangeLog</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/posix/src/alarm.c.diff?r1=text&tr1=1.15&r2=text&tr2=1.16&diff_format=h">M</a></td><td width='1%'>1.16</td><td width='100%'>cpukit/posix/src/alarm.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/posix/src/psignal.c.diff?r1=text&tr1=1.66&r2=text&tr2=1.67&diff_format=h">M</a></td><td width='1%'>1.67</td><td width='100%'>cpukit/posix/src/psignal.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/posix/src/ualarm.c.diff?r1=text&tr1=1.11&r2=text&tr2=1.12&diff_format=h">M</a></td><td width='1%'>1.12</td><td width='100%'>cpukit/posix/src/ualarm.c</td></tr>
</table>
<pre>
<font color='#006600'>diff -u rtems/cpukit/ChangeLog:1.2281 rtems/cpukit/ChangeLog:1.2282
--- rtems/cpukit/ChangeLog:1.2281 Thu Apr 29 07:24:55 2010
+++ rtems/cpukit/ChangeLog Fri Apr 30 03:37:26 2010
</font><font color='#997700'>@@ -1,3 +1,8 @@
</font><font color='#000088'>+2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
+
+ * posix/src/alarm.c, posix/src/psignal.c, posix/src/ualarm.c:
+ Moved watchdog control objects to reduce dependencies.
+
</font> 2010-04-29 Sebastian Huber <sebastian.huber@embedded-brains.de>
PR 1507/filesystem
<font color='#006600'>diff -u rtems/cpukit/posix/src/alarm.c:1.15 rtems/cpukit/posix/src/alarm.c:1.16
--- rtems/cpukit/posix/src/alarm.c:1.15 Sun Oct 11 17:37:38 2009
+++ rtems/cpukit/posix/src/alarm.c Fri Apr 30 03:37:26 2010
</font><font color='#997700'>@@ -22,8 +22,6 @@
</font> #include <rtems/posix/pthread.h>
#include <rtems/posix/psignal.h>
<font color='#880000'>-Watchdog_Control _POSIX_signals_Alarm_timer;
-
</font> /*PAGE
*
* _POSIX_signals_Alarm_TSR
<font color='#006600'>diff -u rtems/cpukit/posix/src/psignal.c:1.66 rtems/cpukit/posix/src/psignal.c:1.67
--- rtems/cpukit/posix/src/psignal.c:1.66 Sun Oct 4 17:08:43 2009
+++ rtems/cpukit/posix/src/psignal.c Fri Apr 30 03:37:26 2010
</font><font color='#997700'>@@ -89,6 +89,9 @@
</font> Chain_Control _POSIX_signals_Inactive_siginfo;
Chain_Control _POSIX_signals_Siginfo[ SIG_ARRAY_MAX ];
<font color='#000088'>+Watchdog_Control _POSIX_signals_Alarm_timer;
+Watchdog_Control _POSIX_signals_Ualarm_timer;
+
</font> /*PAGE
*
* XXX - move these
<font color='#006600'>diff -u rtems/cpukit/posix/src/ualarm.c:1.11 rtems/cpukit/posix/src/ualarm.c:1.12
--- rtems/cpukit/posix/src/ualarm.c:1.11 Mon Nov 30 09:44:21 2009
+++ rtems/cpukit/posix/src/ualarm.c Fri Apr 30 03:37:27 2010
</font><font color='#997700'>@@ -23,8 +23,6 @@
</font> #include <rtems/posix/psignal.h>
#include <rtems/posix/time.h>
<font color='#880000'>-Watchdog_Control _POSIX_signals_Ualarm_timer;
-
</font> /*PAGE
*
* _POSIX_signals_Ualarm_TSR
</pre>
<p> </p>
<a name='cs2'></a>
<table border='0' cellspacing='0' cellpadding='5' width='100%' bgcolor='#eeeeee'>
<tr><td colspan='3' bgcolor='#dddddd'>
<font color='#bb2222'><strong>sh</strong></font>
</td></tr>
<tr><td colspan='3' bgcolor='#dddddd'><pre>2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
* sapi/inline/rtems/chain.inl: Added missing functions.
</pre></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/ChangeLog.diff?r1=text&tr1=1.2282&r2=text&tr2=1.2283&diff_format=h">M</a></td><td width='1%'>1.2283</td><td width='100%'>cpukit/ChangeLog</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/sapi/inline/rtems/chain.inl.diff?r1=text&tr1=1.7&r2=text&tr2=1.8&diff_format=h">M</a></td><td width='1%'>1.8</td><td width='100%'>cpukit/sapi/inline/rtems/chain.inl</td></tr>
</table>
<pre>
<font color='#006600'>diff -u rtems/cpukit/ChangeLog:1.2282 rtems/cpukit/ChangeLog:1.2283
--- rtems/cpukit/ChangeLog:1.2282 Fri Apr 30 03:37:26 2010
+++ rtems/cpukit/ChangeLog Fri Apr 30 03:39:14 2010
</font><font color='#997700'>@@ -1,5 +1,9 @@
</font> 2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
<font color='#000088'>+ * sapi/inline/rtems/chain.inl: Added missing functions.
+
+2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
+
</font> * posix/src/alarm.c, posix/src/psignal.c, posix/src/ualarm.c:
Moved watchdog control objects to reduce dependencies.
<font color='#006600'>diff -u rtems/cpukit/sapi/inline/rtems/chain.inl:1.7 rtems/cpukit/sapi/inline/rtems/chain.inl:1.8
--- rtems/cpukit/sapi/inline/rtems/chain.inl:1.7 Thu Oct 8 02:07:36 2009
+++ rtems/cpukit/sapi/inline/rtems/chain.inl Fri Apr 30 03:39:15 2010
</font><font color='#997700'>@@ -385,6 +385,16 @@
</font> }
/**
<font color='#000088'>+ * @brief See _Chain_Get_unprotected().
+ */
+RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_get_unprotected(
+ rtems_chain_control *the_chain
+)
+{
+ return _Chain_Get_unprotected( the_chain );
+}
+
+/**
</font> * @brief Insert a node on a chain
*
* This routine inserts @a the_node on a chain immediately following
<font color='#997700'>@@ -402,6 +412,17 @@
</font> }
/**
<font color='#000088'>+ * @brief See _Chain_Insert_unprotected().
+ */
+RTEMS_INLINE_ROUTINE void rtems_chain_insert_unprotected(
+ rtems_chain_node *after_node,
+ rtems_chain_node *the_node
+)
+{
+ _Chain_Insert_unprotected( after_node, the_node );
+}
+
+/**
</font> * @brief Append a node on the end of a chain
*
* This routine appends @a the_node onto the end of @a the_chain.
</pre>
<p> </p>
<a name='cs3'></a>
<table border='0' cellspacing='0' cellpadding='5' width='100%' bgcolor='#eeeeee'>
<tr><td colspan='3' bgcolor='#dddddd'>
<font color='#bb2222'><strong>sh</strong></font>
</td></tr>
<tr><td colspan='3' bgcolor='#dddddd'><pre>2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libblock/src/bdpart.c: Removed file.
* libblock/src/bdpart-create.c, libblock/src/bdpart-dump.c,
libblock/src/bdpart-mount.c, libblock/src/bdpart-read.c,
libblock/src/bdpart-register.c, libblock/src/bdpart-sort.c,
libblock/src/bdpart-write.c: New files.
* libblock/include/rtems/bdpart.h: Moved some definitions from bdpart.c.
* libblock/Makefile.am: Update for file changes.
</pre></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/ChangeLog.diff?r1=text&tr1=1.2283&r2=text&tr2=1.2284&diff_format=h">M</a></td><td width='1%'>1.2284</td><td width='100%'>cpukit/ChangeLog</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libblock/Makefile.am.diff?r1=text&tr1=1.37&r2=text&tr2=1.38&diff_format=h">M</a></td><td width='1%'>1.38</td><td width='100%'>cpukit/libblock/Makefile.am</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libblock/include/rtems/bdpart.h.diff?r1=text&tr1=1.2&r2=text&tr2=1.3&diff_format=h">M</a></td><td width='1%'>1.3</td><td width='100%'>cpukit/libblock/include/rtems/bdpart.h</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libblock/src/bdpart-create.c?rev=1.1&content-type=text/vnd.viewcvs-markup">A</a></td><td width='1%'><font color="#000088">1.1</font></td><td width='100%'><font color="#000088">cpukit/libblock/src/bdpart-create.c</font></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libblock/src/bdpart-dump.c?rev=1.1&content-type=text/vnd.viewcvs-markup">A</a></td><td width='1%'><font color="#000088">1.1</font></td><td width='100%'><font color="#000088">cpukit/libblock/src/bdpart-dump.c</font></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libblock/src/bdpart-mount.c?rev=1.1&content-type=text/vnd.viewcvs-markup">A</a></td><td width='1%'><font color="#000088">1.1</font></td><td width='100%'><font color="#000088">cpukit/libblock/src/bdpart-mount.c</font></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libblock/src/bdpart-read.c?rev=1.1&content-type=text/vnd.viewcvs-markup">A</a></td><td width='1%'><font color="#000088">1.1</font></td><td width='100%'><font color="#000088">cpukit/libblock/src/bdpart-read.c</font></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libblock/src/bdpart-register.c?rev=1.1&content-type=text/vnd.viewcvs-markup">A</a></td><td width='1%'><font color="#000088">1.1</font></td><td width='100%'><font color="#000088">cpukit/libblock/src/bdpart-register.c</font></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libblock/src/bdpart-sort.c?rev=1.1&content-type=text/vnd.viewcvs-markup">A</a></td><td width='1%'><font color="#000088">1.1</font></td><td width='100%'><font color="#000088">cpukit/libblock/src/bdpart-sort.c</font></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libblock/src/bdpart-write.c?rev=1.1&content-type=text/vnd.viewcvs-markup">A</a></td><td width='1%'><font color="#000088">1.1</font></td><td width='100%'><font color="#000088">cpukit/libblock/src/bdpart-write.c</font></td></tr>
</table>
<pre>
<font color='#006600'>diff -u rtems/cpukit/ChangeLog:1.2283 rtems/cpukit/ChangeLog:1.2284
--- rtems/cpukit/ChangeLog:1.2283 Fri Apr 30 03:39:14 2010
+++ rtems/cpukit/ChangeLog Fri Apr 30 03:42:11 2010
</font><font color='#997700'>@@ -1,5 +1,15 @@
</font> 2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
<font color='#000088'>+ * libblock/src/bdpart.c: Removed file.
+ * libblock/src/bdpart-create.c, libblock/src/bdpart-dump.c,
+ libblock/src/bdpart-mount.c, libblock/src/bdpart-read.c,
+ libblock/src/bdpart-register.c, libblock/src/bdpart-sort.c,
+ libblock/src/bdpart-write.c: New files.
+ * libblock/include/rtems/bdpart.h: Moved some definitions from bdpart.c.
+ * libblock/Makefile.am: Update for file changes.
+
+2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
+
</font> * sapi/inline/rtems/chain.inl: Added missing functions.
2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
<font color='#006600'>diff -u rtems/cpukit/libblock/Makefile.am:1.37 rtems/cpukit/libblock/Makefile.am:1.38
--- rtems/cpukit/libblock/Makefile.am:1.37 Fri Oct 16 03:44:50 2009
+++ rtems/cpukit/libblock/Makefile.am Fri Apr 30 03:42:12 2010
</font><font color='#997700'>@@ -13,7 +13,13 @@
</font> src/ide_part_table.c \
src/nvdisk.c \
src/nvdisk-sram.c \
<font color='#880000'>- src/bdpart.c \
</font><font color='#000088'>+ src/bdpart-create.c \
+ src/bdpart-dump.c \
+ src/bdpart-mount.c \
+ src/bdpart-read.c \
+ src/bdpart-register.c \
+ src/bdpart-sort.c \
+ src/bdpart-write.c \
</font> include/rtems/bdbuf.h include/rtems/blkdev.h \
include/rtems/diskdevs.h include/rtems/flashdisk.h \
include/rtems/ramdisk.h include/rtems/nvdisk.h include/rtems/nvdisk-sram.h \
<font color='#006600'>diff -u rtems/cpukit/libblock/include/rtems/bdpart.h:1.2 rtems/cpukit/libblock/include/rtems/bdpart.h:1.3
--- rtems/cpukit/libblock/include/rtems/bdpart.h:1.2 Fri May 15 07:52:12 2009
+++ rtems/cpukit/libblock/include/rtems/bdpart.h Fri Apr 30 03:42:12 2010
</font><font color='#997700'>@@ -7,7 +7,7 @@
</font> */
/*
<font color='#880000'>- * Copyright (c) 2009
</font><font color='#000088'>+ * Copyright (c) 2009, 2010
</font> * embedded brains GmbH
* Obere Lagerstr. 30
* D-82178 Puchheim
<font color='#997700'>@@ -355,6 +355,50 @@
</font>
/** @} */
<font color='#000088'>+#define RTEMS_BDPART_MBR_CYLINDER_SIZE 63
+
+#define RTEMS_BDPART_NUMBER_SIZE 4
+
+#define RTEMS_BDPART_BLOCK_SIZE 512
+
+#define RTEMS_BDPART_MBR_TABLE_ENTRY_SIZE 16
+
+#define RTEMS_BDPART_MBR_OFFSET_TABLE_0 446
+
+#define RTEMS_BDPART_MBR_OFFSET_TABLE_1 \
+ (RTEMS_BDPART_MBR_OFFSET_TABLE_0 + RTEMS_BDPART_MBR_TABLE_ENTRY_SIZE)
+
+#define RTEMS_BDPART_MBR_OFFSET_DISK_ID 440
+
+#define RTEMS_BDPART_MBR_OFFSET_SIGNATURE_0 510
+
+#define RTEMS_BDPART_MBR_OFFSET_SIGNATURE_1 511
+
+#define RTEMS_BDPART_MBR_SIGNATURE_0 0x55U
+
+#define RTEMS_BDPART_MBR_SIGNATURE_1 0xaaU
+
+#define RTEMS_BDPART_MBR_OFFSET_BEGIN 8
+
+#define RTEMS_BDPART_MBR_OFFSET_SIZE 12
+
+#define RTEMS_BDPART_MBR_OFFSET_TYPE 4
+
+#define RTEMS_BDPART_MBR_OFFSET_FLAGS 0
+
+static inline uint8_t rtems_bdpart_mbr_partition_type(
+ const uuid_t type
+)
+{
+ return type [0];
+}
+
+rtems_status_code rtems_bdpart_get_disk_data(
+ const char *disk_name,
+ dev_t *disk,
+ rtems_blkdev_bnum *disk_end
+);
+
</font> #ifdef __cplusplus
}
#endif /* __cplusplus */
<font color='#006600'>diff -u /dev/null rtems/cpukit/libblock/src/bdpart-create.c:1.1
--- /dev/null Fri Apr 30 04:12:03 2010
+++ rtems/cpukit/libblock/src/bdpart-create.c Fri Apr 30 03:42:12 2010
</font><font color='#997700'>@@ -0,0 +1,160 @@
</font><font color='#000088'>+/**
+ * @file
+ *
+ * @ingroup rtems_bdpart
+ *
+ * Block device partition management.
+ */
+
+/*
+ * Copyright (c) 2009, 2010
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * D-82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems.h>
+#include <rtems/bdpart.h>
+
+rtems_status_code rtems_bdpart_create(
+ const char *disk_name,
+ const rtems_bdpart_format *format,
+ rtems_bdpart_partition *pt,
+ const unsigned *dist,
+ size_t count
+)
+{
+ rtems_status_code sc = RTEMS_SUCCESSFUL;
+ bool dos_compatibility = format != NULL
+ && format->type == RTEMS_BDPART_FORMAT_MBR
+ && format->mbr.dos_compatibility;
+ rtems_blkdev_bnum disk_end = 0;
+ rtems_blkdev_bnum pos = 0;
+ rtems_blkdev_bnum dist_sum = 0;
+ rtems_blkdev_bnum record_space =
+ dos_compatibility ? RTEMS_BDPART_MBR_CYLINDER_SIZE : 1;
+ rtems_blkdev_bnum overhead = 0;
+ rtems_blkdev_bnum free_space = 0;
+ dev_t disk = 0;
+ size_t i = 0;
+
+ /* Check if we have something to do */
+ if (count == 0) {
+ /* Nothing to do */
+ return RTEMS_SUCCESSFUL;
+ }
+
+ /* Check parameter */
+ if (format == NULL || pt == NULL || dist == NULL) {
+ return RTEMS_INVALID_ADDRESS;
+ }
+
+ /* Get disk data */
+ sc = rtems_bdpart_get_disk_data( disk_name, &disk, &disk_end);
+ if (sc != RTEMS_SUCCESSFUL) {
+ return sc;
+ }
+
+ /* Get distribution sum and check for overflow */
+ for (i = 0; i < count; ++i) {
+ unsigned prev_sum = dist_sum;
+
+ dist_sum += dist [i];
+
+ if (dist_sum < prev_sum) {
+ return RTEMS_INVALID_NUMBER;
+ }
+
+ if (dist [i] == 0) {
+ return RTEMS_INVALID_NUMBER;
+ }
+ }
+
+ /* Check format */
+ if (format->type != RTEMS_BDPART_FORMAT_MBR) {
+ return RTEMS_NOT_IMPLEMENTED;
+ }
+
+ /* Align end of disk on cylinder boundary if necessary */
+ if (dos_compatibility) {
+ disk_end -= (disk_end % record_space);
+ }
+
+ /*
+ * We need at least space for the MBR and the compatibility space for the
+ * first primary partition.
+ */
+ overhead += record_space;
+
+ /*
+ * In case we need an extended partition and logical partitions we have to
+ * account for the space of each EBR.
+ */
+ if (count > 4) {
+ overhead += (count - 3) * record_space;
+ }
+
+ /*
+ * Account space to align every partition on cylinder boundaries if
+ * necessary.
+ */
+ if (dos_compatibility) {
+ overhead += (count - 1) * record_space;
+ }
+
+ /* Check disk space */
+ if ((overhead + count) > disk_end) {
+ return RTEMS_IO_ERROR;
+ }
+
+ /* Begin of first primary partition */
+ pos = record_space;
+
+ /* Space for partitions */
+ free_space = disk_end - overhead;
+
+ for (i = 0; i < count; ++i) {
+ rtems_bdpart_partition *p = pt + i;
+
+ /* Partition size */
+ rtems_blkdev_bnum s = free_space * dist [i];
+ if (s < free_space || s < dist [i]) {
+ /* TODO: Calculate without overflow */
+ return RTEMS_INVALID_NUMBER;
+ }
+ s /= dist_sum;
+
+ /* Ensure that the partition is not empty */
+ if (s == 0) {
+ s = 1;
+ }
+
+ /* Align partition upwards */
+ s += record_space - (s % record_space);
+
+ /* Partition begin and end */
+ p->begin = pos;
+ pos += s;
+ p->end = pos;
+
+ /* Reserve space for the EBR if necessary */
+ if (count > 4 && i > 2) {
+ p->begin += record_space;
+ }
+ }
+
+ /* Expand the last partition to the disk end */
+ pt [count - 1].end = disk_end;
+
+ return RTEMS_SUCCESSFUL;
+}
</font>
<font color='#006600'>diff -u /dev/null rtems/cpukit/libblock/src/bdpart-dump.c:1.1
--- /dev/null Fri Apr 30 04:12:03 2010
+++ rtems/cpukit/libblock/src/bdpart-dump.c Fri Apr 30 03:42:12 2010
</font><font color='#997700'>@@ -0,0 +1,97 @@
</font><font color='#000088'>+/**
+ * @file
+ *
+ * @ingroup rtems_bdpart
+ *
+ * Block device partition management.
+ */
+
+/*
+ * Copyright (c) 2009, 2010
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * D-82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <inttypes.h>
+
+#include <rtems.h>
+#include <rtems/bdpart.h>
+
+static void rtems_bdpart_type_to_string(
+ const uuid_t type,
+ char str [37]
+)
+{
+ uuid_unparse_lower( type, str);
+}
+
+void rtems_bdpart_dump( const rtems_bdpart_partition *pt, size_t count)
+{
+ size_t i = 0;
+
+ printf(
+ "-------------------------------------------------------------------------------\n"
+ " PARTITION TABLE\n"
+ "------------+------------+-----------------------------------------------------\n"
+ " BEGIN | END | TYPE\n"
+ "------------+------------+-----------------------------------------------------\n"
+ );
+
+ for (i = 0; i < count; ++i) {
+ const rtems_bdpart_partition *p = pt + i;
+ const char *type = NULL;
+ char type_buffer [52];
+ uint8_t type_mbr = 0;
+
+ if (rtems_bdpart_to_mbr_partition_type( p->type, &type_mbr)) {
+ switch (type_mbr) {
+ case RTEMS_BDPART_MBR_FAT_12:
+ type = "FAT 12";
+ break;
+ case RTEMS_BDPART_MBR_FAT_16:
+ type = "FAT 16";
+ break;
+ case RTEMS_BDPART_MBR_FAT_16_LBA:
+ type = "FAT 16 LBA";
+ break;
+ case RTEMS_BDPART_MBR_FAT_32:
+ type = "FAT 32";
+ break;
+ case RTEMS_BDPART_MBR_FAT_32_LBA:
+ type = "FAT 32 LBA";
+ break;
+ case RTEMS_BDPART_MBR_DATA:
+ type = "DATA";
+ break;
+ default:
+ snprintf( type_buffer, sizeof( type_buffer), "0x%02" PRIx8, type_mbr);
+ type = type_buffer;
+ break;
+ }
+ } else {
+ rtems_bdpart_type_to_string( p->type, type_buffer);
+ type = type_buffer;
+ }
+
+ printf(
+ " %10" PRIu32 " | %10" PRIu32 " |%52s\n",
+ p->begin,
+ p->end,
+ type
+ );
+ }
+
+ puts( "------------+------------+-----------------------------------------------------");
+}
</font>
<font color='#006600'>diff -u /dev/null rtems/cpukit/libblock/src/bdpart-mount.c:1.1
--- /dev/null Fri Apr 30 04:12:03 2010
+++ rtems/cpukit/libblock/src/bdpart-mount.c Fri Apr 30 03:42:12 2010
</font><font color='#997700'>@@ -0,0 +1,185 @@
</font><font color='#000088'>+/**
+ * @file
+ *
+ * @ingroup rtems_bdpart
+ *
+ * Block device partition management.
+ */
+
+/*
+ * Copyright (c) 2009, 2010
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * D-82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <rtems.h>
+#include <rtems/bdpart.h>
+#include <rtems/dosfs.h>
+#include <rtems/fsmount.h>
+
+rtems_status_code rtems_bdpart_mount(
+ const char *disk_name,
+ const rtems_bdpart_partition *pt __attribute__((unused)),
+ size_t count,
+ const char *mount_base
+)
+{
+ rtems_status_code esc = RTEMS_SUCCESSFUL;
+ const char *disk_file_name = strrchr( disk_name, '/');
+ char *logical_disk_name = NULL;
+ char *logical_disk_marker = NULL;
+ char *mount_point = NULL;
+ char *mount_marker = NULL;
+ size_t disk_file_name_size = 0;
+ size_t disk_name_size = strlen( disk_name);
+ size_t mount_base_size = strlen( mount_base);
+ size_t i = 0;
+
+ /* Create logical disk name base */
+ logical_disk_name = malloc( disk_name_size + RTEMS_BDPART_NUMBER_SIZE);
+ if (logical_disk_name == NULL) {
+ return RTEMS_NO_MEMORY;
+ }
+ strncpy( logical_disk_name, disk_name, disk_name_size);
+
+ /* Get disk file name */
+ if (disk_file_name != NULL) {
+ disk_file_name += 1;
+ disk_file_name_size = strlen( disk_file_name);
+ } else {
+ disk_file_name = disk_name;
+ disk_file_name_size = disk_name_size;
+ }
+
+ /* Create mount point base */
+ mount_point = malloc( mount_base_size + 1 + disk_file_name_size + RTEMS_BDPART_NUMBER_SIZE);
+ if (mount_point == NULL) {
+ esc = RTEMS_NO_MEMORY;
+ goto cleanup;
+ }
+ strncpy( mount_point, mount_base, mount_base_size);
+ mount_point [mount_base_size] = '/';
+ strncpy( mount_point + mount_base_size + 1, disk_file_name, disk_file_name_size);
+
+ /* Markers */
+ logical_disk_marker = logical_disk_name + disk_name_size;
+ mount_marker = mount_point + mount_base_size + 1 + disk_file_name_size;
+
+ /* Mount supported file systems for each partition */
+ for (i = 0; i < count; ++i) {
+ /* Create logical disk name */
+ int rv = snprintf( logical_disk_marker, RTEMS_BDPART_NUMBER_SIZE, "%zu", i + 1);
+ if (rv >= RTEMS_BDPART_NUMBER_SIZE) {
+ esc = RTEMS_INVALID_NAME;
+ goto cleanup;
+ }
+
+ /* Create mount point */
+ strncpy( mount_marker, logical_disk_marker, RTEMS_BDPART_NUMBER_SIZE);
+ rv = rtems_fsmount_create_mount_point( mount_point);
+ if (rv != 0) {
+ esc = RTEMS_IO_ERROR;
+ goto cleanup;
+ }
+
+ /* Mount */
+ rv = mount(
+ NULL,
+ &msdos_ops,
+ 0,
+ logical_disk_name,
+ mount_point
+ );
+ if (rv != 0) {
+ rmdir( mount_point);
+ }
+ }
+
+cleanup:
+
+ free( logical_disk_name);
+ free( mount_point);
+
+ return esc;
+}
+
+rtems_status_code rtems_bdpart_unmount(
+ const char *disk_name,
+ const rtems_bdpart_partition *pt __attribute__((unused)),
+ size_t count,
+ const char *mount_base
+)
+{
+ rtems_status_code esc = RTEMS_SUCCESSFUL;
+ const char *disk_file_name = strrchr( disk_name, '/');
+ char *mount_point = NULL;
+ char *mount_marker = NULL;
+ size_t disk_file_name_size = 0;
+ size_t disk_name_size = strlen( disk_name);
+ size_t mount_base_size = strlen( mount_base);
+ size_t i = 0;
+
+ /* Get disk file name */
+ if (disk_file_name != NULL) {
+ disk_file_name += 1;
+ disk_file_name_size = strlen( disk_file_name);
+ } else {
+ disk_file_name = disk_name;
+ disk_file_name_size = disk_name_size;
+ }
+
+ /* Create mount point base */
+ mount_point = malloc( mount_base_size + 1 + disk_file_name_size + RTEMS_BDPART_NUMBER_SIZE);
+ if (mount_point == NULL) {
+ esc = RTEMS_NO_MEMORY;
+ goto cleanup;
+ }
+ strncpy( mount_point, mount_base, mount_base_size);
+ mount_point [mount_base_size] = '/';
+ strncpy( mount_point + mount_base_size + 1, disk_file_name, disk_file_name_size);
+
+ /* Marker */
+ mount_marker = mount_point + mount_base_size + 1 + disk_file_name_size;
+
+ /* Mount supported file systems for each partition */
+ for (i = 0; i < count; ++i) {
+ /* Create mount point */
+ int rv = snprintf( mount_marker, RTEMS_BDPART_NUMBER_SIZE, "%zu", i + 1);
+ if (rv >= RTEMS_BDPART_NUMBER_SIZE) {
+ esc = RTEMS_INVALID_NAME;
+ goto cleanup;
+ }
+
+ /* Unmount */
+ rv = unmount( mount_point);
+ if (rv == 0) {
+ /* Remove mount point */
+ rv = rmdir( mount_point);
+ if (rv != 0) {
+ esc = RTEMS_IO_ERROR;
+ goto cleanup;
+ }
+ }
+ }
+
+cleanup:
+
+ free( mount_point);
+
+ return esc;
+}
</font>
<font color='#006600'>diff -u /dev/null rtems/cpukit/libblock/src/bdpart-read.c:1.1
--- /dev/null Fri Apr 30 04:12:03 2010
+++ rtems/cpukit/libblock/src/bdpart-read.c Fri Apr 30 03:42:13 2010
</font><font color='#997700'>@@ -0,0 +1,348 @@
</font><font color='#000088'>+/**
+ * @file
+ *
+ * @ingroup rtems_bdpart
+ *
+ * Block device partition management.
+ */
+
+/*
+ * Copyright (c) 2009, 2010
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * D-82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems.h>
+#include <rtems/bdbuf.h>
+#include <rtems/bdpart.h>
+#include <rtems/endian.h>
+
+#define RTEMS_BDPART_MBR_PARTITION_TYPE( type) \
+ { \
+ (type), 0xa2U, 0x2eU, 0x38U, \
+ 0x38U, 0xb5U, 0xdeU, 0x11U, \
+ 0xbcU, 0x13U, 0x00U, 0x1dU, \
+ 0x09U, 0xb0U, 0x5fU, 0xa4U \
+ }
+
+static const uuid_t RTEMS_BDPART_MBR_MASTER_TYPE =
+ RTEMS_BDPART_MBR_PARTITION_TYPE( RTEMS_BDPART_MBR_EMPTY);
+
+void rtems_bdpart_to_partition_type( uint8_t mbr_type, uuid_t type)
+{
+ type [0] = mbr_type;
+ memcpy( type + 1, RTEMS_BDPART_MBR_MASTER_TYPE + 1, sizeof( uuid_t) - 1);
+}
+
+bool rtems_bdpart_to_mbr_partition_type(
+ const uuid_t type,
+ uint8_t *mbr_type
+)
+{
+ *mbr_type = rtems_bdpart_mbr_partition_type( type);
+
+ return memcmp(
+ type + 1,
+ RTEMS_BDPART_MBR_MASTER_TYPE + 1,
+ sizeof( uuid_t) - 1
+ ) == 0;
+}
+
+/*
+ * FIXME: This code should the deviceio interface and not the bdbug interface.
+ */
+rtems_status_code rtems_bdpart_get_disk_data(
+ const char *disk_name,
+ dev_t *disk,
+ rtems_blkdev_bnum *disk_end
+)
+{
+ rtems_status_code sc = RTEMS_SUCCESSFUL;
+ int rv = 0;
+ rtems_blkdev_bnum disk_begin = 0;
+ rtems_blkdev_bnum block_size = 0;
+ rtems_disk_device *dd = NULL;
+ struct stat st;
+
+ /* Get disk handle */
+ rv = stat( disk_name, &st);
+ if (rv != 0) {
+ return RTEMS_INVALID_NAME;
+ }
+ *disk = st.st_rdev;
+
+ /* Get disk begin, end and block size */
+ dd = rtems_disk_obtain( *disk);
+ if (dd == NULL) {
+ return RTEMS_INVALID_NAME;
+ }
+ disk_begin = dd->start;
+ *disk_end = dd->size;
+ block_size = dd->block_size;
+ sc = rtems_disk_release( dd);
+ if (sc != RTEMS_SUCCESSFUL) {
+ return sc;
+ }
+
+ /* Check block size */
+ if (block_size < RTEMS_BDPART_BLOCK_SIZE) {
+ return RTEMS_IO_ERROR;
+ }
+
+ /* Check that we have do not have a logical disk */
+ if (disk_begin != 0) {
+ return RTEMS_IO_ERROR;
+ }
+
+ return RTEMS_SUCCESSFUL;
+}
+
+static bool rtems_bdpart_is_valid_record( const uint8_t *data)
+{
+ return data [RTEMS_BDPART_MBR_OFFSET_SIGNATURE_0]
+ == RTEMS_BDPART_MBR_SIGNATURE_0
+ && data [RTEMS_BDPART_MBR_OFFSET_SIGNATURE_1]
+ == RTEMS_BDPART_MBR_SIGNATURE_1;
+}
+
+static rtems_blkdev_bnum rtems_bdpart_next_ebr( const uint8_t *data)
+{
+ rtems_blkdev_bnum begin =
+ rtems_uint32_from_little_endian( data + RTEMS_BDPART_MBR_OFFSET_BEGIN);
+ uint8_t type = data [RTEMS_BDPART_MBR_OFFSET_TYPE];
+
+ if (type == RTEMS_BDPART_MBR_EXTENDED) {
+ return begin;
+ } else {
+ return 0;
+ }
+}
+
+static rtems_status_code rtems_bdpart_read_mbr_partition(
+ const uint8_t *data,
+ rtems_bdpart_partition **p,
+ const rtems_bdpart_partition *p_end,
+ rtems_blkdev_bnum *ep_begin
+)
+{
+ rtems_blkdev_bnum begin =
+ rtems_uint32_from_little_endian( data + RTEMS_BDPART_MBR_OFFSET_BEGIN);
+ rtems_blkdev_bnum size =
+ rtems_uint32_from_little_endian( data + RTEMS_BDPART_MBR_OFFSET_SIZE);
+ rtems_blkdev_bnum end = begin + size;
+ uint8_t type = data [RTEMS_BDPART_MBR_OFFSET_TYPE];
+
+ if (type == RTEMS_BDPART_MBR_EMPTY) {
+ return RTEMS_SUCCESSFUL;
+ } else if (*p == p_end) {
+ return RTEMS_TOO_MANY;
+ } else if (begin >= end) {
+ return RTEMS_IO_ERROR;
+ } else if (type == RTEMS_BDPART_MBR_EXTENDED) {
+ if (ep_begin != NULL) {
+ *ep_begin = begin;
+ }
+ } else {
+ /* Increment partition index */
+ ++(*p);
+
+ /* Clear partition */
+ memset( *p, 0, sizeof( rtems_bdpart_partition));
+
+ /* Set values */
+ (*p)->begin = begin;
+ (*p)->end = end;
+ rtems_bdpart_to_partition_type( type, (*p)->type);
+ (*p)->flags = data [RTEMS_BDPART_MBR_OFFSET_FLAGS];
+ }
+
+ return RTEMS_SUCCESSFUL;
+}
+
+static rtems_status_code rtems_bdpart_read_record(
+ dev_t disk,
+ rtems_blkdev_bnum index,
+ rtems_bdbuf_buffer **block
+)
+{
+ rtems_status_code sc = RTEMS_SUCCESSFUL;
+
+ /* Release previous block if necessary */
+ if (*block != NULL) {
+ sc = rtems_bdbuf_release( *block);
+ if (sc != RTEMS_SUCCESSFUL) {
+ return sc;
+ }
+ }
+
+ /* Read the record block */
+ sc = rtems_bdbuf_read( disk, index, block);
+ if (sc != RTEMS_SUCCESSFUL) {
+ return sc;
+ }
+
+ /* just in case block did not get filled in */
+ if ( *block == NULL ) {
+ return RTEMS_INVALID_ADDRESS;
+ }
+
+ /* Check MBR signature */
+ if (!rtems_bdpart_is_valid_record( (*block)->buffer)) {
+ return RTEMS_IO_ERROR;
+ }
+
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_status_code rtems_bdpart_read(
+ const char *disk_name,
+ rtems_bdpart_format *format,
+ rtems_bdpart_partition *pt,
+ size_t *count
+)
+{
+ rtems_status_code sc = RTEMS_SUCCESSFUL;
+ rtems_status_code esc = RTEMS_SUCCESSFUL;
+ rtems_bdbuf_buffer *block = NULL;
+ rtems_bdpart_partition *p = pt - 1;
+ const rtems_bdpart_partition *p_end = pt + (count != NULL ? *count : 0);
+ rtems_blkdev_bnum ep_begin = 0; /* Extended partition begin */
+ rtems_blkdev_bnum ebr = 0; /* Extended boot record block index */
+ rtems_blkdev_bnum disk_end = 0;
+ dev_t disk = 0;
+ size_t i = 0;
+ const uint8_t *data = NULL;
+
+ /* Check parameter */
+ if (format == NULL || pt == NULL || count == NULL) {
+ return RTEMS_INVALID_ADDRESS;
+ }
+
+ /* Set count to a save value */
+ *count = 0;
+
+ /* Get disk data */
+ sc = rtems_bdpart_get_disk_data( disk_name, &disk, &disk_end);
+ if (sc != RTEMS_SUCCESSFUL) {
+ return sc;
+ }
+
+ /* Read MBR */
+ sc = rtems_bdpart_read_record( disk, 0, &block);
+ if (sc != RTEMS_SUCCESSFUL) {
+ esc = sc;
+ goto cleanup;
+ }
+
+ /* Read the first partition entry */
+ data = block->buffer + RTEMS_BDPART_MBR_OFFSET_TABLE_0;
+ sc = rtems_bdpart_read_mbr_partition( data, &p, p_end, &ep_begin);
+ if (sc != RTEMS_SUCCESSFUL) {
+ esc = sc;
+ goto cleanup;
+ }
+
+ /* Determine if we have a MBR or GPT format */
+ if (rtems_bdpart_mbr_partition_type( p->type) == RTEMS_BDPART_MBR_GPT) {
+ esc = RTEMS_NOT_IMPLEMENTED;
+ goto cleanup;
+ }
+
+ /* Set format */
+ format->type = RTEMS_BDPART_FORMAT_MBR;
+ format->mbr.disk_id = rtems_uint32_from_little_endian(
+ block->buffer + RTEMS_BDPART_MBR_OFFSET_DISK_ID
+ );
+ format->mbr.dos_compatibility = true;
+
+ /* Iterate through the rest of the primary partition table */
+ for (i = 1; i < 4; ++i) {
+ data += RTEMS_BDPART_MBR_TABLE_ENTRY_SIZE;
+
+ sc = rtems_bdpart_read_mbr_partition( data, &p, p_end, &ep_begin);
+ if (sc != RTEMS_SUCCESSFUL) {
+ esc = sc;
+ goto cleanup;
+ }
+ }
+
+ /* Iterate through the logical partitions within the extended partition */
+ ebr = ep_begin;
+ while (ebr != 0) {
+ rtems_blkdev_bnum tmp = 0;
+
+ /* Read EBR */
+ sc = rtems_bdpart_read_record( disk, ebr, &block);
+ if (sc != RTEMS_SUCCESSFUL) {
+ esc = sc;
+ goto cleanup;
+ }
+
+ /* Read first partition entry */
+ sc = rtems_bdpart_read_mbr_partition(
+ block->buffer + RTEMS_BDPART_MBR_OFFSET_TABLE_0,
+ &p,
+ p_end,
+ NULL
+ );
+ if (sc != RTEMS_SUCCESSFUL) {
+ esc = sc;
+ goto cleanup;
+ }
+
+ /* Adjust partition begin */
+ tmp = p->begin + ebr;
+ if (tmp > p->begin) {
+ p->begin = tmp;
+ } else {
+ esc = RTEMS_IO_ERROR;
+ goto cleanup;
+ }
+
+ /* Adjust partition end */
+ tmp = p->end + ebr;
+ if (tmp > p->end) {
+ p->end = tmp;
+ } else {
+ esc = RTEMS_IO_ERROR;
+ goto cleanup;
+ }
+
+ /* Read second partition entry for next EBR block */
+ ebr = rtems_bdpart_next_ebr(
+ block->buffer + RTEMS_BDPART_MBR_OFFSET_TABLE_1
+ );
+ if (ebr != 0) {
+ /* Adjust partition EBR block index */
+ tmp = ebr + ep_begin;
+ if (tmp > ebr) {
+ ebr = tmp;
+ } else {
+ esc = RTEMS_IO_ERROR;
+ goto cleanup;
+ }
+ }
+ }
+
+ /* Return partition count */
+ *count = (size_t) (p - pt + 1);
+
+cleanup:
+
+ if (block != NULL) {
+ rtems_bdbuf_release( block);
+ }
+
+ return esc;
+}
</font>
<font color='#006600'>diff -u /dev/null rtems/cpukit/libblock/src/bdpart-register.c:1.1
--- /dev/null Fri Apr 30 04:12:03 2010
+++ rtems/cpukit/libblock/src/bdpart-register.c Fri Apr 30 03:42:13 2010
</font><font color='#997700'>@@ -0,0 +1,163 @@
</font><font color='#000088'>+/**
+ * @file
+ *
+ * @ingroup rtems_bdpart
+ *
+ * Block device partition management.
+ */
+
+/*
+ * Copyright (c) 2009, 2010
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * D-82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <rtems.h>
+#include <rtems/bdpart.h>
+
+rtems_status_code rtems_bdpart_register(
+ const char *disk_name,
+ const rtems_bdpart_partition *pt,
+ size_t count
+)
+{
+ rtems_status_code sc = RTEMS_SUCCESSFUL;
+ rtems_status_code esc = RTEMS_SUCCESSFUL;
+ rtems_device_major_number major = 0;
+ rtems_device_minor_number minor = 0;
+ rtems_blkdev_bnum disk_end = 0;
+ dev_t disk = 0;
+ dev_t logical_disk = 0;
+ char *logical_disk_name = NULL;
+ char *logical_disk_marker = NULL;
+ size_t disk_name_size = strlen( disk_name);
+ size_t i = 0;
+
+ /* Get disk data */
+ sc = rtems_bdpart_get_disk_data( disk_name, &disk, &disk_end);
+ if (sc != RTEMS_SUCCESSFUL) {
+ return sc;
+ }
+
+ /* Get the disk device identifier */
+ rtems_filesystem_split_dev_t( disk, major, minor);
+
+ /* Create logical disk name */
+ logical_disk_name = malloc( disk_name_size + RTEMS_BDPART_NUMBER_SIZE);
+ if (logical_disk_name == NULL) {
+ return RTEMS_NO_MEMORY;
+ }
+ strncpy( logical_disk_name, disk_name, disk_name_size);
+ logical_disk_marker = logical_disk_name + disk_name_size;
+
+ /* Create a logical disk for each partition */
+ for (i = 0; i < count; ++i) {
+ const rtems_bdpart_partition *p = pt + i;
+ int rv = 0;
+
+ /* New minor number */
+ ++minor;
+
+ /* Create a new device identifier */
+ logical_disk = rtems_filesystem_make_dev_t( major, minor);
+
+ /* Set partition number for logical disk name */
+ rv = snprintf( logical_disk_marker, RTEMS_BDPART_NUMBER_SIZE, "%zu", i + 1);
+ if (rv >= RTEMS_BDPART_NUMBER_SIZE) {
+ esc = RTEMS_INVALID_NAME;
+ goto cleanup;
+ }
+
+ /* Create logical disk */
+ sc = rtems_disk_create_log(
+ logical_disk,
+ disk,
+ p->begin,
+ p->end - p->begin,
+ logical_disk_name
+ );
+ if (sc != RTEMS_SUCCESSFUL) {
+ esc = sc;
+ goto cleanup;
+ }
+ }
+
+cleanup:
+
+ free( logical_disk_name);
+
+ return esc;
+}
+
+rtems_status_code rtems_bdpart_register_from_disk( const char *disk_name)
+{
+ rtems_status_code sc = RTEMS_SUCCESSFUL;
+ rtems_bdpart_format format;
+ rtems_bdpart_partition pt [RTEMS_BDPART_PARTITION_NUMBER_HINT];
+ size_t count = RTEMS_BDPART_PARTITION_NUMBER_HINT;
+
+ /* Read partitions */
+ sc = rtems_bdpart_read( disk_name, &format, pt, &count);
+ if (sc != RTEMS_SUCCESSFUL) {
+ return sc;
+ }
+
+ /* Register partitions */
+ return rtems_bdpart_register( disk_name, pt, count);
+}
+
+rtems_status_code rtems_bdpart_unregister(
+ const char *disk_name,
+ const rtems_bdpart_partition *pt __attribute__((unused)),
+ size_t count
+)
+{
+ rtems_status_code sc = RTEMS_SUCCESSFUL;
+ rtems_device_major_number major = 0;
+ rtems_device_minor_number minor = 0;
+ rtems_blkdev_bnum disk_end = 0;
+ dev_t disk = 0;
+ dev_t logical_disk = 0;
+ size_t i = 0;
+
+ /* Get disk data */
+ sc = rtems_bdpart_get_disk_data( disk_name, &disk, &disk_end);
+ if (sc != RTEMS_SUCCESSFUL) {
+ return sc;
+ }
+
+ /* Get the disk device identifier */
+ rtems_filesystem_split_dev_t( disk, major, minor);
+
+ /* Create a logical disk for each partition */
+ for (i = 0; i < count; ++i) {
+ /* New minor number */
+ ++minor;
+
+ /* Get the device identifier */
+ logical_disk = rtems_filesystem_make_dev_t( major, minor);
+
+ /* Delete logical disk */
+ sc = rtems_disk_delete( logical_disk);
+ if (sc != RTEMS_SUCCESSFUL) {
+ return sc;
+ }
+ }
+
+ return RTEMS_SUCCESSFUL;
+}
</font>
<font color='#006600'>diff -u /dev/null rtems/cpukit/libblock/src/bdpart-sort.c:1.1
--- /dev/null Fri Apr 30 04:12:03 2010
+++ rtems/cpukit/libblock/src/bdpart-sort.c Fri Apr 30 03:42:13 2010
</font><font color='#997700'>@@ -0,0 +1,48 @@
</font><font color='#000088'>+/**
+ * @file
+ *
+ * @ingroup rtems_bdpart
+ *
+ * Block device partition management.
+ */
+
+/*
+ * Copyright (c) 2009, 2010
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * D-82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+
+#include <rtems.h>
+#include <rtems/bdpart.h>
+
+static int rtems_bdpart_partition_compare( const void *aa, const void *bb)
+{
+ const rtems_bdpart_partition *a = aa;
+ const rtems_bdpart_partition *b = bb;
+
+ if (a->begin < b->begin) {
+ return -1;
+ } else if (a->begin == b->begin) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+void rtems_bdpart_sort( rtems_bdpart_partition *pt, size_t count)
+{
+ qsort( pt, count, sizeof( *pt), rtems_bdpart_partition_compare);
+}
</font>
<font color='#006600'>diff -u /dev/null rtems/cpukit/libblock/src/bdpart-write.c:1.1
--- /dev/null Fri Apr 30 04:12:03 2010
+++ rtems/cpukit/libblock/src/bdpart-write.c Fri Apr 30 03:42:13 2010
</font><font color='#997700'>@@ -0,0 +1,302 @@
</font><font color='#000088'>+/**
+ * @file
+ *
+ * @ingroup rtems_bdpart
+ *
+ * Block device partition management.
+ */
+
+/*
+ * Copyright (c) 2009, 2010
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * D-82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+
+#include <rtems.h>
+#include <rtems/bdbuf.h>
+#include <rtems/bdpart.h>
+#include <rtems/endian.h>
+
+static void rtems_bdpart_write_mbr_partition(
+ uint8_t *data,
+ uint32_t begin,
+ uint32_t size,
+ uint8_t type,
+ uint8_t flags
+)
+{
+ rtems_uint32_to_little_endian( begin, data + RTEMS_BDPART_MBR_OFFSET_BEGIN);
+ rtems_uint32_to_little_endian( size, data + RTEMS_BDPART_MBR_OFFSET_SIZE);
+ data [RTEMS_BDPART_MBR_OFFSET_TYPE] = type;
+ data [RTEMS_BDPART_MBR_OFFSET_FLAGS] = flags;
+}
+
+static rtems_status_code rtems_bdpart_new_record(
+ dev_t disk,
+ rtems_blkdev_bnum index,
+ rtems_bdbuf_buffer **block
+)
+{
+ rtems_status_code sc = RTEMS_SUCCESSFUL;
+
+ /* Synchronize previous block if necessary */
+ if (*block != NULL) {
+ sc = rtems_bdbuf_sync( *block);
+ if (sc != RTEMS_SUCCESSFUL) {
+ return sc;
+ }
+ }
+
+ /* Read the new record block (this accounts for disk block sizes > 512) */
+ sc = rtems_bdbuf_read( disk, index, block);
+ if (sc != RTEMS_SUCCESSFUL) {
+ return sc;
+ }
+
+ /* just in case block did not get filled in */
+ if ( *block == NULL ) {
+ return RTEMS_INVALID_ADDRESS;
+ }
+
+ /* Clear record */
+ memset( (*block)->buffer, 0, RTEMS_BDPART_BLOCK_SIZE);
+
+ /* Write signature */
+ (*block)->buffer [RTEMS_BDPART_MBR_OFFSET_SIGNATURE_0] =
+ RTEMS_BDPART_MBR_SIGNATURE_0;
+ (*block)->buffer [RTEMS_BDPART_MBR_OFFSET_SIGNATURE_1] =
+ RTEMS_BDPART_MBR_SIGNATURE_1;
+
+ return RTEMS_SUCCESSFUL;
+}
+
+rtems_status_code rtems_bdpart_write(
+ const char *disk_name,
+ const rtems_bdpart_format *format,
+ const rtems_bdpart_partition *pt,
+ size_t count
+)
+{
+ rtems_status_code sc = RTEMS_SUCCESSFUL;
+ rtems_status_code esc = RTEMS_SUCCESSFUL;
+ bool dos_compatibility = format != NULL
+ && format->type == RTEMS_BDPART_FORMAT_MBR
+ && format->mbr.dos_compatibility;
+ rtems_bdbuf_buffer *block = NULL;
+ rtems_blkdev_bnum disk_end = 0;
+ rtems_blkdev_bnum record_space =
+ dos_compatibility ? RTEMS_BDPART_MBR_CYLINDER_SIZE : 1;
+ dev_t disk = 0;
+ size_t ppc = 0; /* Primary partition count */
+ size_t i = 0;
+ uint8_t *data = NULL;
+
+ /* Check if we have something to do */
+ if (count == 0) {
+ /* Nothing to do */
+ return RTEMS_SUCCESSFUL;
+ }
+
+ /* Check parameter */
+ if (format == NULL || pt == NULL) {
+ return RTEMS_INVALID_ADDRESS;
+ }
+
+ /* Get disk data */
+ sc = rtems_bdpart_get_disk_data( disk_name, &disk, &disk_end);
+ if (sc != RTEMS_SUCCESSFUL) {
+ return sc;
+ }
+
+ /* Align end of disk on cylinder boundary if necessary */
+ if (dos_compatibility) {
+ disk_end -= (disk_end % record_space);
+ }
+
+ /* Check that we have a consistent partition table */
+ for (i = 0; i < count; ++i) {
+ const rtems_bdpart_partition *p = pt + i;
+
+ /* Check that begin and end are proper within the disk */
+ if (p->begin >= disk_end || p->end > disk_end) {
+ esc = RTEMS_INVALID_NUMBER;
+ goto cleanup;
+ }
+
+ /* Check that begin and end are valid */
+ if (p->begin >= p->end) {
+ esc = RTEMS_INVALID_NUMBER;
+ goto cleanup;
+ }
+
+ /* Check that partitions do not overlap */
+ if (i > 0 && pt [i - 1].end > p->begin) {
+ esc = RTEMS_INVALID_NUMBER;
+ goto cleanup;
+ }
+ }
+
+ /* Check format */
+ if (format->type != RTEMS_BDPART_FORMAT_MBR) {
+ esc = RTEMS_NOT_IMPLEMENTED;
+ goto cleanup;
+ }
+
+ /*
+ * Set primary partition count. If we have more than four partitions we need
+ * an extended partition which will contain the partitions of number four and
+ * above as logical partitions. If we have four or less partitions we can
+ * use the primary partition table.
+ */
+ ppc = count <= 4 ? count : 3;
+
+ /*
+ * Check that the first primary partition starts at head one and sector one
+ * under the virtual one head and 63 sectors geometry if necessary.
+ */
+ if (dos_compatibility && pt [0].begin != RTEMS_BDPART_MBR_CYLINDER_SIZE) {
+ esc = RTEMS_INVALID_NUMBER;
+ goto cleanup;
+ }
+
+ /*
+ * Check that we have enough space for the EBRs. The partitions with number
+ * four and above are logical partitions if we have more than four partitions
+ * in total. The logical partitions are contained in the extended partition.
+ * Each logical partition is described via one EBR preceding the partition.
+ * The space for the EBR and maybe some space which is needed for DOS
+ * compatibility resides between the partitions. So there have to be gaps of
+ * the appropriate size between the partitions.
+ */
+ for (i = ppc; i < count; ++i) {
+ if ((pt [i].begin - pt [i - 1].end) < record_space) {
+ esc = RTEMS_INVALID_NUMBER;
+ goto cleanup;
+ }
+ }
+
+ /* Check that we can convert the parition descriptions to the MBR format */
+ for (i = 0; i < count; ++i) {
+ uint8_t type = 0;
+
+ const rtems_bdpart_partition *p = pt + i;
+
+ /* Check type */
+ if (!rtems_bdpart_to_mbr_partition_type( p->type, &type)) {
+ esc = RTEMS_INVALID_ID;
+ goto cleanup;
+ }
+
+ /* Check flags */
+ if (p->flags > 0xffU) {
+ esc = RTEMS_INVALID_ID;
+ goto cleanup;
+ }
+
+ /* Check ID */
+ /* TODO */
+ }
+
+ /* New MBR */
+ sc = rtems_bdpart_new_record( disk, 0, &block);
+ if (sc != RTEMS_SUCCESSFUL) {
+ esc = sc;
+ goto cleanup;
+ }
+
+ /* Write disk ID */
+ rtems_uint32_to_little_endian(
+ format->mbr.disk_id,
+ block->buffer + RTEMS_BDPART_MBR_OFFSET_DISK_ID
+ );
+
+ /* Write primary partition table */
+ data = block->buffer + RTEMS_BDPART_MBR_OFFSET_TABLE_0;
+ for (i = 0; i < ppc; ++i) {
+ const rtems_bdpart_partition *p = pt + i;
+
+ /* Write partition entry */
+ rtems_bdpart_write_mbr_partition(
+ data,
+ p->begin,
+ p->end - p->begin,
+ rtems_bdpart_mbr_partition_type( p->type),
+ (uint8_t) p->flags
+ );
+
+ data += RTEMS_BDPART_MBR_TABLE_ENTRY_SIZE;
+ }
+
+ /* Write extended partition with logical partitions if necessary */
+ if (ppc != count) {
+ rtems_blkdev_bnum ebr = 0; /* Extended boot record block index */
+
+ /* Begin of extended partition */
+ rtems_blkdev_bnum ep_begin = pt [ppc].begin - record_space;
+
+ /* Write extended partition */
+ rtems_bdpart_write_mbr_partition(
+ data,
+ ep_begin,
+ disk_end - ep_begin,
+ RTEMS_BDPART_MBR_EXTENDED,
+ 0
+ );
+
+ /* Write logical partitions */
+ for (i = ppc; i < count; ++i) {
+ const rtems_bdpart_partition *p = pt + i;
+
+ /* Write second partition entry */
+ if (i > ppc) {
+ rtems_blkdev_bnum begin = p->begin - record_space;
+
+ rtems_bdpart_write_mbr_partition(
+ block->buffer + RTEMS_BDPART_MBR_OFFSET_TABLE_1,
+ begin - ep_begin,
+ disk_end - begin,
+ RTEMS_BDPART_MBR_EXTENDED,
+ 0
+ );
+ }
+
+ /* New EBR */
+ ebr = p->begin - record_space;
+ sc = rtems_bdpart_new_record( disk, ebr, &block);
+ if (sc != RTEMS_SUCCESSFUL) {
+ esc = sc;
+ goto cleanup;
+ }
+
+ /* Write first partition entry */
+ rtems_bdpart_write_mbr_partition(
+ block->buffer + RTEMS_BDPART_MBR_OFFSET_TABLE_0,
+ record_space,
+ p->end - p->begin,
+ rtems_bdpart_mbr_partition_type( p->type),
+ (uint8_t) p->flags
+ );
+ }
+ }
+
+cleanup:
+
+ if (block != NULL) {
+ rtems_bdbuf_sync( block);
+ }
+
+ return esc;
+}
</font></pre>
<p> </p>
<a name='cs4'></a>
<table border='0' cellspacing='0' cellpadding='5' width='100%' bgcolor='#eeeeee'>
<tr><td colspan='3' bgcolor='#dddddd'>
<font color='#bb2222'><strong>sh</strong></font>
</td></tr>
<tr><td colspan='3' bgcolor='#dddddd'><pre>2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libfs/src/dosfs/msdos_format.c: Added missing va_end().
</pre></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/ChangeLog.diff?r1=text&tr1=1.2284&r2=text&tr2=1.2285&diff_format=h">M</a></td><td width='1%'>1.2285</td><td width='100%'>cpukit/ChangeLog</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libfs/src/dosfs/msdos_format.c.diff?r1=text&tr1=1.16&r2=text&tr2=1.17&diff_format=h">M</a></td><td width='1%'>1.17</td><td width='100%'>cpukit/libfs/src/dosfs/msdos_format.c</td></tr>
</table>
<pre>
<font color='#006600'>diff -u rtems/cpukit/ChangeLog:1.2284 rtems/cpukit/ChangeLog:1.2285
--- rtems/cpukit/ChangeLog:1.2284 Fri Apr 30 03:42:11 2010
+++ rtems/cpukit/ChangeLog Fri Apr 30 03:43:30 2010
</font><font color='#997700'>@@ -1,5 +1,9 @@
</font> 2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
<font color='#000088'>+ * libfs/src/dosfs/msdos_format.c: Added missing va_end().
+
+2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
+
</font> * libblock/src/bdpart.c: Removed file.
* libblock/src/bdpart-create.c, libblock/src/bdpart-dump.c,
libblock/src/bdpart-mount.c, libblock/src/bdpart-read.c,
<font color='#006600'>diff -u rtems/cpukit/libfs/src/dosfs/msdos_format.c:1.16 rtems/cpukit/libfs/src/dosfs/msdos_format.c:1.17
--- rtems/cpukit/libfs/src/dosfs/msdos_format.c:1.16 Fri Mar 12 10:26:14 2010
+++ rtems/cpukit/libfs/src/dosfs/msdos_format.c Fri Apr 30 03:43:31 2010
</font><font color='#997700'>@@ -81,6 +81,7 @@
</font> vfprintf (stdout, format, args);
fflush (stdout);
}
<font color='#000088'>+ va_end (args);
</font> }
/*=========================================================================*\
</pre>
<p> </p>
<a name='cs5'></a>
<table border='0' cellspacing='0' cellpadding='5' width='100%' bgcolor='#eeeeee'>
<tr><td colspan='3' bgcolor='#dddddd'>
<font color='#bb2222'><strong>sh</strong></font>
</td></tr>
<tr><td colspan='3' bgcolor='#dddddd'><pre>2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libnetworking/lib/ftpfs.c: Format changes. Fixed pathname
allocation in rtems_ftpfs_eval_path(). Send QUIT command during
file close.
</pre></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/ChangeLog.diff?r1=text&tr1=1.2285&r2=text&tr2=1.2286&diff_format=h">M</a></td><td width='1%'>1.2286</td><td width='100%'>cpukit/ChangeLog</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libnetworking/lib/ftpfs.c.diff?r1=text&tr1=1.26&r2=text&tr2=1.27&diff_format=h">M</a></td><td width='1%'>1.27</td><td width='100%'>cpukit/libnetworking/lib/ftpfs.c</td></tr>
</table>
<pre>
<font color='#006600'>diff -u rtems/cpukit/ChangeLog:1.2285 rtems/cpukit/ChangeLog:1.2286
--- rtems/cpukit/ChangeLog:1.2285 Fri Apr 30 03:43:30 2010
+++ rtems/cpukit/ChangeLog Fri Apr 30 03:52:28 2010
</font><font color='#997700'>@@ -1,5 +1,11 @@
</font> 2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
<font color='#000088'>+ * libnetworking/lib/ftpfs.c: Format changes. Fixed pathname
+ allocation in rtems_ftpfs_eval_path(). Send QUIT command during
+ file close.
+
+2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
+
</font> * libfs/src/dosfs/msdos_format.c: Added missing va_end().
2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
<font color='#006600'>diff -u rtems/cpukit/libnetworking/lib/ftpfs.c:1.26 rtems/cpukit/libnetworking/lib/ftpfs.c:1.27
--- rtems/cpukit/libnetworking/lib/ftpfs.c:1.26 Mon Apr 12 07:50:25 2010
+++ rtems/cpukit/libnetworking/lib/ftpfs.c Fri Apr 30 03:52:29 2010
</font><font color='#997700'>@@ -5,7 +5,7 @@
</font> */
/*
<font color='#880000'>- * Copyright (c) 2009
</font><font color='#000088'>+ * Copyright (c) 2009, 2010
</font> * embedded brains GmbH
* Obere Lagerstr. 30
* D-82178 Puchheim
<font color='#997700'>@@ -59,9 +59,9 @@
</font> #include <rtems/seterr.h>
#ifdef DEBUG
<font color='#880000'>- #define DEBUG_PRINTF( ...) printf( __VA_ARGS__)
</font><font color='#000088'>+ #define DEBUG_PRINTF(...) printf(__VA_ARGS__)
</font> #else
<font color='#880000'>- #define DEBUG_PRINTF( ...)
</font><font color='#000088'>+ #define DEBUG_PRINTF(...)
</font> #endif
/**
<font color='#997700'>@@ -103,7 +103,7 @@
</font>
static const rtems_filesystem_file_handlers_r rtems_ftpfs_root_handlers;
<font color='#880000'>-static bool rtems_ftpfs_use_timeout( const struct timeval *to)
</font><font color='#000088'>+static bool rtems_ftpfs_use_timeout(const struct timeval *to)
</font> {
return to->tv_sec != 0 || to->tv_usec != 0;
}
<font color='#997700'>@@ -113,15 +113,15 @@
</font> const struct timeval *to
)
{
<font color='#880000'>- if (rtems_ftpfs_use_timeout( to)) {
</font><font color='#000088'>+ if (rtems_ftpfs_use_timeout(to)) {
</font> int rv = 0;
<font color='#880000'>- rv = setsockopt( socket, SOL_SOCKET, SO_SNDTIMEO, to, sizeof( *to));
</font><font color='#000088'>+ rv = setsockopt(socket, SOL_SOCKET, SO_SNDTIMEO, to, sizeof(*to));
</font> if (rv != 0) {
return EIO;
}
<font color='#880000'>- rv = setsockopt( socket, SOL_SOCKET, SO_RCVTIMEO, to, sizeof( *to));
</font><font color='#000088'>+ rv = setsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, to, sizeof(*to));
</font> if (rv != 0) {
return EIO;
}
<font color='#997700'>@@ -130,7 +130,7 @@
</font> return 0;
}
<font color='#880000'>-rtems_status_code rtems_ftpfs_mount( const char *mount_point)
</font><font color='#000088'>+rtems_status_code rtems_ftpfs_mount(const char *mount_point)
</font> {
int rv = 0;
<font color='#997700'>@@ -138,7 +138,7 @@
</font> mount_point = RTEMS_FTPFS_MOUNT_POINT_DEFAULT;
}
<font color='#880000'>- rv = mkdir( mount_point, S_IRWXU | S_IRWXG | S_IRWXO);
</font><font color='#000088'>+ rv = mkdir(mount_point, S_IRWXU | S_IRWXG | S_IRWXO);
</font> if (rv != 0) {
return RTEMS_IO_ERROR;
}
<font color='#997700'>@@ -172,19 +172,19 @@
</font> mount_point = RTEMS_FTPFS_MOUNT_POINT_DEFAULT;
}
<font color='#880000'>- fd = open( mount_point, O_RDWR);
</font><font color='#000088'>+ fd = open(mount_point, O_RDWR);
</font> if (fd < 0) {
return RTEMS_INVALID_NAME;
}
<font color='#880000'>- va_start( ap, req);
- rv = ioctl( fd, req, va_arg( ap, void *));
- va_end( ap);
</font><font color='#000088'>+ va_start(ap, req);
+ rv = ioctl(fd, req, va_arg(ap, void *));
+ va_end(ap);
</font> if (rv != 0) {
sc = RTEMS_INVALID_NUMBER;
}
<font color='#880000'>- rv = close( fd);
</font><font color='#000088'>+ rv = close(fd);
</font> if (rv != 0 && sc == RTEMS_SUCCESSFUL) {
sc = RTEMS_IO_ERROR;
}
<font color='#997700'>@@ -192,7 +192,7 @@
</font> return sc;
}
<font color='#880000'>-rtems_status_code rtems_ftpfs_get_verbose( const char *mount_point, bool *verbose)
</font><font color='#000088'>+rtems_status_code rtems_ftpfs_get_verbose(const char *mount_point, bool *verbose)
</font> {
return rtems_ftpfs_do_ioctl(
mount_point,
<font color='#997700'>@@ -201,7 +201,7 @@
</font> );
}
<font color='#880000'>-rtems_status_code rtems_ftpfs_set_verbose( const char *mount_point, bool verbose)
</font><font color='#000088'>+rtems_status_code rtems_ftpfs_set_verbose(const char *mount_point, bool verbose)
</font> {
return rtems_ftpfs_do_ioctl(
mount_point,
<font color='#997700'>@@ -234,11 +234,11 @@
</font> );
}
<font color='#880000'>-int rtems_bsdnet_initialize_ftp_filesystem( void)
</font><font color='#000088'>+int rtems_bsdnet_initialize_ftp_filesystem(void)
</font> {
rtems_status_code sc = RTEMS_SUCCESSFUL;
<font color='#880000'>- sc = rtems_ftpfs_mount( NULL);
</font><font color='#000088'>+ sc = rtems_ftpfs_mount(NULL);
</font>
if (sc == RTEMS_SUCCESSFUL) {
return 0;
<font color='#997700'>@@ -290,7 +290,7 @@
</font> while (true) {
/* Receive reply fragment from socket */
ssize_t i = 0;
<font color='#880000'>- ssize_t rv = recv( socket, buf, sizeof( buf), 0);
</font><font color='#000088'>+ ssize_t rv = recv(socket, buf, sizeof(buf), 0);
</font>
if (rv <= 0) {
return RTEMS_FTPFS_REPLY_ERROR;
<font color='#997700'>@@ -298,12 +298,12 @@
</font>
/* Be verbose if necessary */
if (verbose) {
<font color='#880000'>- write( STDERR_FILENO, buf, (size_t) rv);
</font><font color='#000088'>+ write(STDERR_FILENO, buf, (size_t) rv);
</font> }
/* Invoke parser if necessary */
if (parser != NULL) {
<font color='#880000'>- parser( buf, (size_t) rv, parser_arg);
</font><font color='#000088'>+ parser(buf, (size_t) rv, parser_arg);
</font> }
/* Parse reply fragment */
<font color='#997700'>@@ -350,9 +350,9 @@
</font> /* Check reply */
if (state == RTEMS_FTPFS_REPLY_SINGLE_LINE_DONE) {
if (
<font color='#880000'>- isdigit( reply_first [0])
- && isdigit( reply_first [1])
- && isdigit( reply_first [2])
</font><font color='#000088'>+ isdigit(reply_first [0])
+ && isdigit(reply_first [1])
+ && isdigit(reply_first [2])
</font> ) {
break;
} else {
<font color='#997700'>@@ -364,7 +364,7 @@
</font> for (i = 0; i < RTEMS_FTPFS_REPLY_SIZE; ++i) {
ok = ok
&& reply_first [i] == reply_last [i]
<font color='#880000'>- && isdigit( reply_first [i]);
</font><font color='#000088'>+ && isdigit(reply_first [i]);
</font> }
if (ok) {
<font color='#997700'>@@ -389,36 +389,36 @@
</font> int rv = 0;
/* Send command */
<font color='#880000'>- rv = send( socket, cmd, strlen( cmd), 0);
</font><font color='#000088'>+ rv = send(socket, cmd, strlen(cmd), 0);
</font> if (rv < 0) {
return RTEMS_FTPFS_REPLY_ERROR;
}
if (verbose) {
<font color='#880000'>- write( STDERR_FILENO, cmd, strlen( cmd));
</font><font color='#000088'>+ write(STDERR_FILENO, cmd, strlen(cmd));
</font> }
/* Send command argument if necessary */
if (arg != NULL) {
<font color='#880000'>- rv = send( socket, arg, strlen( arg), 0);
</font><font color='#000088'>+ rv = send(socket, arg, strlen(arg), 0);
</font> if (rv < 0) {
return RTEMS_FTPFS_REPLY_ERROR;
}
if (verbose) {
<font color='#880000'>- write( STDERR_FILENO, arg, strlen( arg));
</font><font color='#000088'>+ write(STDERR_FILENO, arg, strlen(arg));
</font> }
}
/* Send end of line */
<font color='#880000'>- rv = send( socket, eol, 2, 0);
</font><font color='#000088'>+ rv = send(socket, eol, 2, 0);
</font> if (rv < 0) {
return RTEMS_FTPFS_REPLY_ERROR;
}
if (verbose) {
<font color='#880000'>- write( STDERR_FILENO, &eol [1], 1);
</font><font color='#000088'>+ write(STDERR_FILENO, &eol [1], 1);
</font> }
/* Return reply */
<font color='#880000'>- return rtems_ftpfs_get_reply( socket, parser, parser_arg, verbose);
</font><font color='#000088'>+ return rtems_ftpfs_get_reply(socket, parser, parser_arg, verbose);
</font> }
static rtems_ftpfs_reply rtems_ftpfs_send_command(
<font color='#997700'>@@ -459,7 +459,7 @@
</font> )
{
split_state state = STATE_USER_NAME;
<font color='#880000'>- size_t len = strlen( s);
</font><font color='#000088'>+ size_t len = strlen(s);
</font> size_t i = 0;
*user = s;
<font color='#997700'>@@ -543,28 +543,29 @@
</font> unsigned short port
)
{
<font color='#880000'>- memset( sa, sizeof( *sa), 0);
</font><font color='#000088'>+ memset(sa, sizeof(*sa), 0);
</font>
sa->sin_family = AF_INET;
sa->sin_addr.s_addr = address;
sa->sin_port = port;
<font color='#880000'>- sa->sin_len = sizeof( *sa);
</font><font color='#000088'>+ sa->sin_len = sizeof(*sa);
</font>
<font color='#880000'>- return sizeof( *sa);
</font><font color='#000088'>+ return sizeof(*sa);
</font> }
<font color='#880000'>-static int rtems_ftpfs_terminate( rtems_libio_t *iop, bool error)
</font><font color='#000088'>+static int rtems_ftpfs_terminate(rtems_libio_t *iop, bool error)
</font> {
int eno = 0;
int rv = 0;
rtems_ftpfs_entry *e = iop->data1;
rtems_ftpfs_mount_entry *me = iop->pathinfo.mt_entry->fs_info;
bool verbose = me->verbose;
<font color='#000088'>+ rtems_ftpfs_reply reply = RTEMS_FTPFS_REPLY_ERROR;
</font>
if (e != NULL) {
/* Close data connection if necessary */
if (e->data_socket >= 0) {
<font color='#880000'>- rv = close( e->data_socket);
</font><font color='#000088'>+ rv = close(e->data_socket);
</font> if (rv != 0) {
eno = EIO;
}
<font color='#997700'>@@ -575,9 +576,7 @@
</font> && (iop->flags & LIBIO_FLAGS_WRITE) != 0
&& !error
) {
<font color='#880000'>- rtems_ftpfs_reply reply =
- rtems_ftpfs_get_reply( e->ctrl_socket, NULL, NULL, verbose);
-
</font><font color='#000088'>+ reply = rtems_ftpfs_get_reply(e->ctrl_socket, NULL, NULL, verbose);
</font> if (reply != RTEMS_FTPFS_REPLY_2) {
eno = EIO;
}
<font color='#997700'>@@ -586,14 +585,24 @@
</font>
/* Close control connection if necessary */
if (e->ctrl_socket >= 0) {
<font color='#880000'>- rv = close( e->ctrl_socket);
</font><font color='#000088'>+ reply = rtems_ftpfs_send_command(
+ e->ctrl_socket,
+ "QUIT",
+ NULL,
+ verbose
+ );
+ if (reply != RTEMS_FTPFS_REPLY_2) {
+ eno = EIO;
+ }
+
+ rv = close(e->ctrl_socket);
</font> if (rv != 0) {
eno = EIO;
}
}
/* Free connection entry */
<font color='#880000'>- free( e);
</font><font color='#000088'>+ free(e);
</font> }
/* Invalidate IO entry */
<font color='#997700'>@@ -620,46 +629,46 @@
</font> socklen_t size = 0;
/* Create the socket for the control connection */
<font color='#880000'>- e->ctrl_socket = socket( AF_INET, SOCK_STREAM, 0);
</font><font color='#000088'>+ e->ctrl_socket = socket(AF_INET, SOCK_STREAM, 0);
</font> if (e->ctrl_socket < 0) {
return ENOMEM;
}
/* Set up the server address from the hostname */
<font color='#880000'>- if (hostname == NULL || strlen( hostname) == 0) {
</font><font color='#000088'>+ if (hostname == NULL || strlen(hostname) == 0) {
</font> /* Default to BOOTP server address */
address = rtems_bsdnet_bootp_server_address;
<font color='#880000'>- } else if (inet_aton( hostname, &address) == 0) {
</font><font color='#000088'>+ } else if (inet_aton(hostname, &address) == 0) {
</font> /* Try to get the address by name */
<font color='#880000'>- struct hostent *he = gethostbyname( hostname);
</font><font color='#000088'>+ struct hostent *he = gethostbyname(hostname);
</font>
if (he != NULL) {
<font color='#880000'>- memcpy( &address, he->h_addr, sizeof( address));
</font><font color='#000088'>+ memcpy(&address, he->h_addr, sizeof(address));
</font> } else {
return ENOENT;
}
}
<font color='#880000'>- rtems_ftpfs_create_address( &sa, address.s_addr, htons( RTEMS_FTPFS_CTRL_PORT));
- DEBUG_PRINTF( "server = %s\n", inet_ntoa( sa.sin_addr));
</font><font color='#000088'>+ rtems_ftpfs_create_address(&sa, address.s_addr, htons(RTEMS_FTPFS_CTRL_PORT));
+ DEBUG_PRINTF("server = %s\n", inet_ntoa(sa.sin_addr));
</font>
/* Open control connection */
rv = connect(
e->ctrl_socket,
(struct sockaddr *) &sa,
<font color='#880000'>- sizeof( sa)
</font><font color='#000088'>+ sizeof(sa)
</font> );
if (rv != 0) {
return ENOENT;
}
/* Set control connection timeout */
<font color='#880000'>- eno = rtems_ftpfs_set_connection_timeout( e->ctrl_socket, timeout);
</font><font color='#000088'>+ eno = rtems_ftpfs_set_connection_timeout(e->ctrl_socket, timeout);
</font> if (eno != 0) {
return eno;
}
/* Get client address */
<font color='#880000'>- size = rtems_ftpfs_create_address( &sa, INADDR_ANY, 0);
</font><font color='#000088'>+ size = rtems_ftpfs_create_address(&sa, INADDR_ANY, 0);
</font> rv = getsockname(
e->ctrl_socket,
(struct sockaddr *) &sa,
<font color='#997700'>@@ -668,17 +677,17 @@
</font> if (rv != 0) {
return ENOMEM;
}
<font color='#880000'>- *client_address = ntohl( sa.sin_addr.s_addr);
- DEBUG_PRINTF( "client = %s\n", inet_ntoa( sa.sin_addr));
</font><font color='#000088'>+ *client_address = ntohl(sa.sin_addr.s_addr);
+ DEBUG_PRINTF("client = %s\n", inet_ntoa(sa.sin_addr));
</font>
/* Now we should get a welcome message from the server */
<font color='#880000'>- reply = rtems_ftpfs_get_reply( e->ctrl_socket, NULL, NULL, verbose);
</font><font color='#000088'>+ reply = rtems_ftpfs_get_reply(e->ctrl_socket, NULL, NULL, verbose);
</font> if (reply != RTEMS_FTPFS_REPLY_2) {
return ENOENT;
}
/* Send USER command */
<font color='#880000'>- reply = rtems_ftpfs_send_command( e->ctrl_socket, "USER ", user, verbose);
</font><font color='#000088'>+ reply = rtems_ftpfs_send_command(e->ctrl_socket, "USER ", user, verbose);
</font> if (reply == RTEMS_FTPFS_REPLY_3) {
/* Send PASS command */
reply = rtems_ftpfs_send_command(
<font color='#997700'>@@ -697,7 +706,7 @@
</font> }
/* Send TYPE command to set binary mode for all data transfers */
<font color='#880000'>- reply = rtems_ftpfs_send_command( e->ctrl_socket, "TYPE I", NULL, verbose);
</font><font color='#000088'>+ reply = rtems_ftpfs_send_command(e->ctrl_socket, "TYPE I", NULL, verbose);
</font> if (reply != RTEMS_FTPFS_REPLY_2) {
return EIO;
}
<font color='#997700'>@@ -724,18 +733,18 @@
</font> uint16_t data_port = 0;
/* Create port socket to establish a data data connection */
<font color='#880000'>- port_socket = socket( AF_INET, SOCK_STREAM, 0);
</font><font color='#000088'>+ port_socket = socket(AF_INET, SOCK_STREAM, 0);
</font> if (port_socket < 0) {
eno = ENOMEM;
goto cleanup;
}
/* Bind port socket */
<font color='#880000'>- rtems_ftpfs_create_address( &sa, INADDR_ANY, 0);
</font><font color='#000088'>+ rtems_ftpfs_create_address(&sa, INADDR_ANY, 0);
</font> rv = bind(
port_socket,
(struct sockaddr *) &sa,
<font color='#880000'>- sizeof( sa)
</font><font color='#000088'>+ sizeof(sa)
</font> );
if (rv != 0) {
eno = EBUSY;
<font color='#997700'>@@ -743,7 +752,7 @@
</font> }
/* Get port number for data socket */
<font color='#880000'>- size = rtems_ftpfs_create_address( &sa, INADDR_ANY, 0);
</font><font color='#000088'>+ size = rtems_ftpfs_create_address(&sa, INADDR_ANY, 0);
</font> rv = getsockname(
port_socket,
(struct sockaddr *) &sa,
<font color='#997700'>@@ -753,12 +762,12 @@
</font> eno = ENOMEM;
goto cleanup;
}
<font color='#880000'>- data_port = ntohs( sa.sin_port);
</font><font color='#000088'>+ data_port = ntohs(sa.sin_port);
</font>
/* Send PORT command to set data connection port for server */
snprintf(
port_command,
<font color='#880000'>- sizeof( port_command),
</font><font color='#000088'>+ sizeof(port_command),
</font> "PORT %lu,%lu,%lu,%lu,%lu,%lu",
(client_address >> 24) & 0xffUL,
(client_address >> 16) & 0xffUL,
<font color='#997700'>@@ -779,7 +788,7 @@
</font> }
/* Listen on port socket for incoming data connections */
<font color='#880000'>- rv = listen( port_socket, 1);
</font><font color='#000088'>+ rv = listen(port_socket, 1);
</font> if (rv != 0) {
eno = EBUSY;
goto cleanup;
<font color='#997700'>@@ -798,14 +807,14 @@
</font> }
/* Wait for connect on data connection if necessary */
<font color='#880000'>- if (rtems_ftpfs_use_timeout( timeout)) {
</font><font color='#000088'>+ if (rtems_ftpfs_use_timeout(timeout)) {
</font> struct timeval to = *timeout;
fd_set fds;
<font color='#880000'>- FD_ZERO( &fds);
- FD_SET( port_socket, &fds);
</font><font color='#000088'>+ FD_ZERO(&fds);
+ FD_SET(port_socket, &fds);
</font>
<font color='#880000'>- rv = select( port_socket + 1, &fds, NULL, NULL, &to);
</font><font color='#000088'>+ rv = select(port_socket + 1, &fds, NULL, NULL, &to);
</font> if (rv <= 0) {
eno = EIO;
goto cleanup;
<font color='#997700'>@@ -813,7 +822,7 @@
</font> }
/* Accept data connection */
<font color='#880000'>- size = sizeof( sa);
</font><font color='#000088'>+ size = sizeof(sa);
</font> e->data_socket = accept(
port_socket,
(struct sockaddr *) &sa,
<font color='#997700'>@@ -828,7 +837,7 @@
</font>
/* Close port socket if necessary */
if (port_socket >= 0) {
<font color='#880000'>- rv = close( port_socket);
</font><font color='#000088'>+ rv = close(port_socket);
</font> if (rv != 0) {
eno = EIO;
}
<font color='#997700'>@@ -864,23 +873,23 @@
</font>
switch (e->state) {
case RTEMS_FTPFS_PASV_START:
<font color='#880000'>- if (!isdigit( c)) {
</font><font color='#000088'>+ if (!isdigit(c)) {
</font> e->state = RTEMS_FTPFS_PASV_JUNK;
e->index = 0;
}
break;
case RTEMS_FTPFS_PASV_JUNK:
<font color='#880000'>- if (isdigit( c)) {
</font><font color='#000088'>+ if (isdigit(c)) {
</font> e->state = RTEMS_FTPFS_PASV_DATA;
e->data [e->index] = (uint8_t) (c - '0');
}
break;
case RTEMS_FTPFS_PASV_DATA:
<font color='#880000'>- if (isdigit( c)) {
</font><font color='#000088'>+ if (isdigit(c)) {
</font> e->data [e->index] = (uint8_t) (e->data [e->index] * 10 + c - '0');
} else if (c == ',') {
++e->index;
<font color='#880000'>- if (e->index < sizeof( e->data)) {
</font><font color='#000088'>+ if (e->index < sizeof(e->data)) {
</font> e->data [e->index] = 0;
} else {
e->state = RTEMS_FTPFS_PASV_DONE;
<font color='#997700'>@@ -929,15 +938,15 @@
</font> data_address = ((uint32_t)(pe.data [0]) << 24) + ((uint32_t)(pe.data [1]) << 16)
+ ((uint32_t)(pe.data [2]) << 8) + ((uint32_t)(pe.data [3]));
data_port = (uint16_t) ((pe.data [4] << 8) + pe.data [5]);
<font color='#880000'>- rtems_ftpfs_create_address( &sa, htonl( data_address), htons( data_port));
</font><font color='#000088'>+ rtems_ftpfs_create_address(&sa, htonl(data_address), htons(data_port));
</font> DEBUG_PRINTF(
"server data = %s:%u\n",
<font color='#880000'>- inet_ntoa( sa.sin_addr),
- (unsigned) ntohs( sa.sin_port)
</font><font color='#000088'>+ inet_ntoa(sa.sin_addr),
+ (unsigned) ntohs(sa.sin_port)
</font> );
/* Create data socket */
<font color='#880000'>- e->data_socket = socket( AF_INET, SOCK_STREAM, 0);
</font><font color='#000088'>+ e->data_socket = socket(AF_INET, SOCK_STREAM, 0);
</font> if (e->data_socket < 0) {
return ENOMEM;
}
<font color='#997700'>@@ -946,7 +955,7 @@
</font> rv = connect(
e->data_socket,
(struct sockaddr *) &sa,
<font color='#880000'>- sizeof( sa)
</font><font color='#000088'>+ sizeof(sa)
</font> );
if (rv != 0) {
return EIO;
<font color='#997700'>@@ -994,7 +1003,7 @@
</font>
/* Check location, it was allocated during path evaluation */
if (location == NULL) {
<font color='#880000'>- rtems_set_errno_and_return_minus_one( ENOMEM);
</font><font color='#000088'>+ rtems_set_errno_and_return_minus_one(ENOMEM);
</font> }
/* Split location into parts */
<font color='#997700'>@@ -1006,7 +1015,7 @@
</font> &filename
);
if (!ok) {
<font color='#880000'>- if (strlen( location) == 0) {
</font><font color='#000088'>+ if (strlen(location) == 0) {
</font> /*
* This is an access to the root node that will be used for file system
* option settings.
<font color='#997700'>@@ -1015,7 +1024,7 @@
</font>
return 0;
} else {
<font color='#880000'>- rtems_set_errno_and_return_minus_one( ENOENT);
</font><font color='#000088'>+ rtems_set_errno_and_return_minus_one(ENOENT);
</font> }
}
DEBUG_PRINTF(
<font color='#997700'>@@ -1030,13 +1039,13 @@
</font> (iop->flags & LIBIO_FLAGS_WRITE) != 0
&& (iop->flags & LIBIO_FLAGS_READ) != 0
) {
<font color='#880000'>- rtems_set_errno_and_return_minus_one( ENOTSUP);
</font><font color='#000088'>+ rtems_set_errno_and_return_minus_one(ENOTSUP);
</font> }
/* Allocate connection entry */
<font color='#880000'>- e = malloc( sizeof( *e));
</font><font color='#000088'>+ e = malloc(sizeof(*e));
</font> if (e == NULL) {
<font color='#880000'>- rtems_set_errno_and_return_minus_one( ENOMEM);
</font><font color='#000088'>+ rtems_set_errno_and_return_minus_one(ENOMEM);
</font> }
/* Initialize connection entry */
<font color='#997700'>@@ -1086,7 +1095,7 @@
</font> }
/* Set data connection timeout */
<font color='#880000'>- eno = rtems_ftpfs_set_connection_timeout( e->data_socket, timeout);
</font><font color='#000088'>+ eno = rtems_ftpfs_set_connection_timeout(e->data_socket, timeout);
</font>
cleanup:
<font color='#997700'>@@ -1094,9 +1103,9 @@
</font> return 0;
} else {
/* Free all resources if an error occured */
<font color='#880000'>- rtems_ftpfs_terminate( iop, true);
</font><font color='#000088'>+ rtems_ftpfs_terminate(iop, true);
</font>
<font color='#880000'>- rtems_set_errno_and_return_minus_one( eno);
</font><font color='#000088'>+ rtems_set_errno_and_return_minus_one(eno);
</font> }
}
<font color='#997700'>@@ -1117,12 +1126,12 @@
</font> }
while (todo > 0) {
<font color='#880000'>- ssize_t rv = recv( e->data_socket, in, todo, 0);
</font><font color='#000088'>+ ssize_t rv = recv(e->data_socket, in, todo, 0);
</font>
if (rv <= 0) {
if (rv == 0) {
rtems_ftpfs_reply reply =
<font color='#880000'>- rtems_ftpfs_get_reply( e->ctrl_socket, NULL, NULL, verbose);
</font><font color='#000088'>+ rtems_ftpfs_get_reply(e->ctrl_socket, NULL, NULL, verbose);
</font>
if (reply == RTEMS_FTPFS_REPLY_2) {
e->eof = true;
<font color='#997700'>@@ -1130,7 +1139,7 @@
</font> }
}
<font color='#880000'>- rtems_set_errno_and_return_minus_one( EIO);
</font><font color='#000088'>+ rtems_set_errno_and_return_minus_one(EIO);
</font> }
in += rv;
<font color='#997700'>@@ -1151,13 +1160,13 @@
</font> size_t todo = count;
while (todo > 0) {
<font color='#880000'>- ssize_t rv = send( e->data_socket, out, todo, 0);
</font><font color='#000088'>+ ssize_t rv = send(e->data_socket, out, todo, 0);
</font>
if (rv <= 0) {
if (rv == 0) {
break;
} else {
<font color='#880000'>- rtems_set_errno_and_return_minus_one( EIO);
</font><font color='#000088'>+ rtems_set_errno_and_return_minus_one(EIO);
</font> }
}
<font color='#997700'>@@ -1168,19 +1177,19 @@
</font> return (ssize_t) (count - todo);
}
<font color='#880000'>-static int rtems_ftpfs_close( rtems_libio_t *iop)
</font><font color='#000088'>+static int rtems_ftpfs_close(rtems_libio_t *iop)
</font> {
<font color='#880000'>- int eno = rtems_ftpfs_terminate( iop, false);
</font><font color='#000088'>+ int eno = rtems_ftpfs_terminate(iop, false);
</font>
if (eno == 0) {
return 0;
} else {
<font color='#880000'>- rtems_set_errno_and_return_minus_one( eno);
</font><font color='#000088'>+ rtems_set_errno_and_return_minus_one(eno);
</font> }
}
<font color='#880000'>-/* Dummy version to let fopen( *,"w") work properly */
-static int rtems_ftpfs_ftruncate( rtems_libio_t *iop, rtems_off64_t count)
</font><font color='#000088'>+/* Dummy version to let fopen(*,"w") work properly */
+static int rtems_ftpfs_ftruncate(rtems_libio_t *iop, rtems_off64_t count)
</font> {
return 0;
}
<font color='#997700'>@@ -1197,19 +1206,21 @@
</font> * We need to store this path here or otherwise we would have to do this job
* again. The path is used in rtems_ftpfs_open() via iop->file_info.
*/
<font color='#880000'>- pathloc->node_access = malloc(pathnamelen + 1);
- if (pathloc->node_access) {
- memset(pathloc->node_access, 0, pathnamelen + 1);
- memcpy(pathloc->node_access, pathname, pathnamelen);
- }<span style="background-color: #FF0000"> </span>
- pathloc->node_access = strdup( pathname);
</font><font color='#000088'>+ char *pathname_dup = malloc(pathnamelen + 1);
+
+ if (pathname_dup != NULL) {
+ memcpy(pathname_dup, pathname, pathnamelen);
+ pathname_dup [pathnamelen] = '\0';
+ }
+
+ pathloc->node_access = pathname_dup;
</font>
return 0;
}
<font color='#880000'>-static int rtems_ftpfs_free_node( rtems_filesystem_location_info_t *pathloc)
</font><font color='#000088'>+static int rtems_ftpfs_free_node(rtems_filesystem_location_info_t *pathloc)
</font> {
<font color='#880000'>- free( pathloc->node_access);
</font><font color='#000088'>+ free(pathloc->node_access);
</font>
return 0;
}
<font color='#997700'>@@ -1225,12 +1236,12 @@
</font> rtems_filesystem_mount_table_entry_t *e
)
{
<font color='#880000'>- rtems_ftpfs_mount_entry *me = malloc( sizeof( rtems_ftpfs_mount_entry));
</font><font color='#000088'>+ rtems_ftpfs_mount_entry *me = malloc(sizeof(rtems_ftpfs_mount_entry));
</font>
/* Mount entry for FTP file system instance */
e->fs_info = me;
if (e->fs_info == NULL) {
<font color='#880000'>- rtems_set_errno_and_return_minus_one( ENOMEM);
</font><font color='#000088'>+ rtems_set_errno_and_return_minus_one(ENOMEM);
</font> }
me->verbose = false;
me->timeout.tv_sec = 0;
<font color='#997700'>@@ -1253,7 +1264,7 @@
</font> rtems_filesystem_mount_table_entry_t *e
)
{
<font color='#880000'>- free( e->fs_info);
</font><font color='#000088'>+ free(e->fs_info);
</font>
return 0;
}
<font color='#997700'>@@ -1269,7 +1280,7 @@
</font> struct timeval *timeout = arg;
if (arg == NULL) {
<font color='#880000'>- rtems_set_errno_and_return_minus_one( EINVAL);
</font><font color='#000088'>+ rtems_set_errno_and_return_minus_one(EINVAL);
</font> }
switch (command) {
<font color='#997700'>@@ -1305,11 +1316,11 @@
</font> {
static unsigned ino = 0;
<font color='#880000'>- memset( st, 0, sizeof( *st));
</font><font color='#000088'>+ memset(st, 0, sizeof(*st));
</font>
/* FIXME */
st->st_ino = ++ino;
<font color='#880000'>- st->st_dev = rtems_filesystem_make_dev_t( 0xcc494cd6U, 0x1d970b4dU);
</font><font color='#000088'>+ st->st_dev = rtems_filesystem_make_dev_t(0xcc494cd6U, 0x1d970b4dU);
</font>
st->st_mode = S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO;
</pre>
<p> </p>
<a name='cs6'></a>
<table border='0' cellspacing='0' cellpadding='5' width='100%' bgcolor='#eeeeee'>
<tr><td colspan='3' bgcolor='#dddddd'>
<font color='#bb2222'><strong>sh</strong></font>
</td></tr>
<tr><td colspan='3' bgcolor='#dddddd'><pre>2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libcsupport/include/rtems/libio_.h, libcsupport/src/envlock.c,
libcsupport/src/libio.c: Added and use rtems_libio_lock() and
rtems_libio_unlock(). Cleaned up includes and declarations. Do not
use RTEMS_NO_PRIORITY for unused ceiling priority in
rtems_semaphore_create().
</pre></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/ChangeLog.diff?r1=text&tr1=1.2286&r2=text&tr2=1.2287&diff_format=h">M</a></td><td width='1%'>1.2287</td><td width='100%'>cpukit/ChangeLog</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libcsupport/include/rtems/libio_.h.diff?r1=text&tr1=1.31&r2=text&tr2=1.32&diff_format=h">M</a></td><td width='1%'>1.32</td><td width='100%'>cpukit/libcsupport/include/rtems/libio_.h</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libcsupport/src/envlock.c.diff?r1=text&tr1=1.4&r2=text&tr2=1.5&diff_format=h">M</a></td><td width='1%'>1.5</td><td width='100%'>cpukit/libcsupport/src/envlock.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libcsupport/src/libio.c.diff?r1=text&tr1=1.48&r2=text&tr2=1.49&diff_format=h">M</a></td><td width='1%'>1.49</td><td width='100%'>cpukit/libcsupport/src/libio.c</td></tr>
</table>
<pre>
<font color='#006600'>diff -u rtems/cpukit/ChangeLog:1.2286 rtems/cpukit/ChangeLog:1.2287
--- rtems/cpukit/ChangeLog:1.2286 Fri Apr 30 03:52:28 2010
+++ rtems/cpukit/ChangeLog Fri Apr 30 03:55:38 2010
</font><font color='#997700'>@@ -1,5 +1,13 @@
</font> 2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
<font color='#000088'>+ * libcsupport/include/rtems/libio_.h, libcsupport/src/envlock.c,
+ libcsupport/src/libio.c: Added and use rtems_libio_lock() and
+ rtems_libio_unlock(). Cleaned up includes and declarations. Do not
+ use RTEMS_NO_PRIORITY for unused ceiling priority in
+ rtems_semaphore_create().
+
+2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
+
</font> * libnetworking/lib/ftpfs.c: Format changes. Fixed pathname
allocation in rtems_ftpfs_eval_path(). Send QUIT command during
file close.
<font color='#006600'>diff -u rtems/cpukit/libcsupport/include/rtems/libio_.h:1.31 rtems/cpukit/libcsupport/include/rtems/libio_.h:1.32
--- rtems/cpukit/libcsupport/include/rtems/libio_.h:1.31 Wed Aug 5 13:17:11 2009
+++ rtems/cpukit/libcsupport/include/rtems/libio_.h Fri Apr 30 03:55:40 2010
</font><font color='#997700'>@@ -204,6 +204,16 @@
</font> rtems_status_code rtems_libio_set_private_env(void);
rtems_status_code rtems_libio_share_private_env(rtems_id task_id) ;
<font color='#000088'>+static inline void rtems_libio_lock( void )
+{
+ rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
+}
+
+static inline void rtems_libio_unlock( void )
+{
+ rtems_semaphore_release( rtems_libio_semaphore );
+}
+
</font> /*
* File Descriptor Routine Prototypes
*/
<font color='#006600'>diff -u rtems/cpukit/libcsupport/src/envlock.c:1.4 rtems/cpukit/libcsupport/src/envlock.c:1.5
--- rtems/cpukit/libcsupport/src/envlock.c:1.4 Tue Sep 15 04:29:55 2009
+++ rtems/cpukit/libcsupport/src/envlock.c Fri Apr 30 03:55:40 2010
</font><font color='#997700'>@@ -97,12 +97,12 @@
</font> void
__env_lock(struct _reent *r __attribute__((unused)))
{
<font color='#880000'>- rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
</font><font color='#000088'>+ rtems_libio_lock();
</font> }
void
__env_unlock(struct _reent *r __attribute__((unused)))
{
<font color='#880000'>- rtems_semaphore_release( rtems_libio_semaphore );
</font><font color='#000088'>+ rtems_libio_unlock();
</font> }
#endif
<font color='#006600'>diff -u rtems/cpukit/libcsupport/src/libio.c:1.48 rtems/cpukit/libcsupport/src/libio.c:1.49
--- rtems/cpukit/libcsupport/src/libio.c:1.48 Sun Nov 29 07:35:32 2009
+++ rtems/cpukit/libcsupport/src/libio.c Fri Apr 30 03:55:41 2010
</font><font color='#997700'>@@ -17,14 +17,15 @@
</font> #include "config.h"
#endif
<font color='#880000'>-#include <rtems/libio_.h> /* libio_.h pulls in rtems */
-#include <rtems.h>
-#include <rtems/assoc.h> /* assoc.h not included by rtems.h */
</font><font color='#000088'>+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
</font>
<font color='#880000'>-#include <stdio.h> /* O_RDONLY, et.al. */
-#include <fcntl.h> /* O_RDONLY, et.al. */
-#include <assert.h>
-#include <errno.h>
</font><font color='#000088'>+#include <rtems.h>
+#include <rtems/libio_.h>
+#include <rtems/assoc.h>
</font>
/* define this to alias O_NDELAY to O_NONBLOCK, i.e.,
* O_NDELAY is accepted on input but fcntl(F_GETFL) returns
<font color='#997700'>@@ -40,22 +41,6 @@
</font> */
#undef ACCEPT_O_NDELAY_ALIAS
<font color='#880000'>-#include <errno.h>
-#include <string.h> /* strcmp */
-#include <unistd.h>
-#include <stdlib.h> /* calloc() */
-
-#include <rtems/libio.h> /* libio.h not pulled in by rtems */
-
-/*
- * File descriptor Table Information
- */
-
-extern uint32_t rtems_libio_number_iops;
-extern rtems_id rtems_libio_semaphore;
-extern rtems_libio_t *rtems_libio_iops;
-extern rtems_libio_t *rtems_libio_iop_freelist;
-
</font> /*
* rtems_libio_fcntl_flags
*
<font color='#997700'>@@ -151,14 +136,14 @@
</font> rtems_status_code rc;
rtems_id sema;
<font color='#880000'>- rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
</font><font color='#000088'>+ rtems_libio_lock();
</font>
if (rtems_libio_iop_freelist) {
rc = rtems_semaphore_create(
RTEMS_LIBIO_IOP_SEM(rtems_libio_iop_freelist - rtems_libio_iops),
1,
RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY,
<font color='#880000'>- RTEMS_NO_PRIORITY,
</font><font color='#000088'>+ 0,
</font> &sema
);
if (rc != RTEMS_SUCCESSFUL)
<font color='#997700'>@@ -176,7 +161,7 @@
</font> iop = 0;
done:
<font color='#880000'>- rtems_semaphore_release( rtems_libio_semaphore );
</font><font color='#000088'>+ rtems_libio_unlock();
</font> return iop;
}
<font color='#997700'>@@ -191,7 +176,7 @@
</font> rtems_libio_t *iop
)
{
<font color='#880000'>- rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
</font><font color='#000088'>+ rtems_libio_lock();
</font>
if (iop->sem)
rtems_semaphore_delete(iop->sem);
<font color='#997700'>@@ -200,7 +185,7 @@
</font> iop->data1 = rtems_libio_iop_freelist;
rtems_libio_iop_freelist = iop;
<font color='#880000'>- rtems_semaphore_release(rtems_libio_semaphore);
</font><font color='#000088'>+ rtems_libio_unlock();
</font> }
/*
<font color='#997700'>@@ -222,7 +207,7 @@
</font> int result = 0;
uint32_t i;
<font color='#880000'>- rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
</font><font color='#000088'>+ rtems_libio_lock();
</font>
/*
* Look for any active file descriptor entry.
<font color='#997700'>@@ -244,7 +229,7 @@
</font> }
}
<font color='#880000'>- rtems_semaphore_release( rtems_libio_semaphore );
</font><font color='#000088'>+ rtems_libio_unlock();
</font>
return result;
}
<font color='#997700'>@@ -266,7 +251,7 @@
</font> int result=0;
uint32_t i;
<font color='#880000'>- rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
</font><font color='#000088'>+ rtems_libio_lock();
</font>
/*
* Look for any active file descriptor entry.
<font color='#997700'>@@ -287,7 +272,7 @@
</font> }
}
<font color='#880000'>- rtems_semaphore_release( rtems_libio_semaphore );
</font><font color='#000088'>+ rtems_libio_unlock();
</font>
return result;
}
</pre>
<p> </p>
<p>--<br />
<small>Generated by <a href="http://www.codewiz.org/projects/index.html#loginfo">Deluxe Loginfo</a> 2.122 by Bernardo Innocenti <bernie@develer.com></small></p>
</body>
</html>