[syslinux:master] com32 pwd module

syslinux-bot for Gene Cumm gene.cumm at gmail.com
Sat Jun 26 12:36:32 PDT 2010


Commit-ID:  e9654e598bab36d0c5218163263baf4105db5ae0
Gitweb:     http://syslinux.zytor.com/commit/e9654e598bab36d0c5218163263baf4105db5ae0
Author:     Gene Cumm <gene.cumm at gmail.com>
AuthorDate: Sat, 26 Jun 2010 10:59:46 -0400
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Sat, 26 Jun 2010 12:34:07 -0700

com32 pwd module

[MODULE] pwd to list present (current) working directory.  If the
returned string is empty, display ".".  If the return value is NULL,
display an error message.

Unfortunately, it appears that COM32 getcwd is not working properly at
this moment, it calling the COMBOOT call and getting an empty string.

Signed-off-by: Gene Cumm <gene.cumm at gmail.com>
Signed-off-by: H. Peter Anvin <hpa at zytor.com>


---
 com32/modules/pwd.c |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/com32/modules/pwd.c b/com32/modules/pwd.c
new file mode 100644
index 0000000..880327d
--- /dev/null
+++ b/com32/modules/pwd.c
@@ -0,0 +1,51 @@
+/* ----------------------------------------------------------------------- *
+ *
+ *   Copyright 2010 Gene Cumm - All Rights Reserved
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+ *   Boston MA 02111-1307, USA; either version 2 of the License, or
+ *   (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * Display present (current) working directory
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <console.h>
+#include <unistd.h>
+#include <dirent.h>
+
+/* Size of path buffer string */
+#ifndef PATH_MAX
+#  ifdef NAME_MAX
+#    define PATH_MAX   NAME_MAX
+#  elif FILENAME_MAX
+#    define PATH_MAX   FILENAME_MAX
+#  else
+#    define PATH_MAX   256
+#  endif       /* NAME_MAX */
+#endif /* PATH_MAX */
+
+int main(void)
+{
+    int rv = 0;
+    char pwd[PATH_MAX], *pwdptr;
+
+    openconsole(&dev_rawcon_r, &dev_stdcon_w);
+    pwdptr = getcwd(pwd, PATH_MAX);
+    if (pwdptr) {
+       if (pwd[0] != 0)
+           puts(pwd);
+       else
+           puts(".");
+    } else {
+       rv = errno;
+       puts("ERROR: getcwd() returned NULL");
+    }
+    return rv;
+}



More information about the Syslinux-commits mailing list