diff -ur ../mozilla-orig/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp ./netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp
--- ../mozilla-orig/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp	Wed Mar 30 06:25:41 2005
+++ ./netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp	Mon Oct 23 16:57:40 2006
@@ -1042,7 +1042,63 @@
                 mInternalError = NS_ERROR_FAILURE;
 
             break;
+
+// SITE NAMEFMT 1 (Make OS/400 use Unix-style pathnames)
+
+          case FTP_S_OS400_NAMEFMT:
+            rv = S_os400_namefmt();
+
+            if (NS_FAILED(rv))
+                mInternalError = rv;
             
+            MoveToNextState(FTP_R_OS400_NAMEFMT);
+            break;
+
+          case FTP_R_OS400_NAMEFMT:
+            mState = R_os400_namefmt();
+
+            if (FTP_ERROR == mState) 
+                mInternalError = NS_ERROR_FAILURE;
+
+            break;
+
+// SITE LISTFMT 1 (Make OS/400 use Unix-style directory lists)
+
+          case FTP_S_OS400_LISTFMT:
+            rv = S_os400_listfmt();
+
+            if (NS_FAILED(rv))
+                mInternalError = rv;
+            
+            MoveToNextState(FTP_R_OS400_LISTFMT);
+            break;
+            
+          case FTP_R_OS400_LISTFMT:
+            mState = R_os400_listfmt();
+
+            if (FTP_ERROR == mState) 
+                mInternalError = NS_ERROR_FAILURE;
+
+            break;
+
+// CWD / (Make OS/400 start at IFS Root)
+
+          case FTP_S_OS400_STARTROOT:
+            rv = S_os400_startroot();
+
+            if (NS_FAILED(rv))
+                mInternalError = rv;
+            
+            MoveToNextState(FTP_R_OS400_STARTROOT);
+            break;
+            
+          case FTP_R_OS400_STARTROOT:
+            mState = R_os400_startroot();
+
+            if (FTP_ERROR == mState) 
+                mInternalError = NS_ERROR_FAILURE;
+
+            break;
 
           default:
             ;
@@ -1305,6 +1361,13 @@
         {
             mServerType = FTP_VMS_TYPE;
         }
+        else if (  ( mResponseMsg.Find("OS/400") > -1) 
+                || ( mResponseMsg.Find("i5/OS")  > -1) )
+        {
+            mServerType = FTP_UNIX_TYPE;
+            mResponseMsg = "";
+            return FTP_S_OS400_NAMEFMT;
+        }
         else
         {
             NS_ASSERTION(0, "Server type list format unrecognized.");
@@ -2887,4 +2950,54 @@
     }
 
    return FTP_ERROR;
+}
+
+/* For OS/400 (i5/OS) Send SITE NAMEFMT 1 to tell the
+   system to use Unix-like path names */
+
+nsresult
+nsFtpState::S_os400_namefmt() {
+    nsCString typeString("SITE NAMEFMT 1" CRLF);
+    return SendFTPCommand(typeString);
+}
+
+FTP_STATE
+nsFtpState::R_os400_namefmt() {
+    if (mResponseCode/100 == 2) {
+        return FTP_S_OS400_LISTFMT;
+    }
+    return FTP_ERROR;
+}
+
+/* For OS/400 (i5/OS) Send SITE LISTFMT 1 to tell the
+   system to use Unix-like directory listings */
+
+nsresult
+nsFtpState::S_os400_listfmt() {
+    nsCString typeString("SITE LISTFMT 1" CRLF);
+    return SendFTPCommand(typeString);
+}
+
+FTP_STATE
+nsFtpState::R_os400_listfmt() {
+    if (mResponseCode/100 == 2) {
+        return FTP_S_OS400_STARTROOT;
+    }
+    return FTP_ERROR;
+}
+
+/* For OS/400 (i5/OS) Start in the root directory of the system */
+
+nsresult
+nsFtpState::S_os400_startroot() {
+    nsCString typeString("CWD /" CRLF);
+    return SendFTPCommand(typeString);
+}
+
+FTP_STATE
+nsFtpState::R_os400_startroot() {
+    if (mResponseCode/100 == 2) {
+        return FTP_S_PWD;
+    }
+    return FTP_ERROR;
 }
diff -ur ../mozilla-orig/netwerk/protocol/ftp/src/nsFtpConnectionThread.h ./netwerk/protocol/ftp/src/nsFtpConnectionThread.h
--- ../mozilla-orig/netwerk/protocol/ftp/src/nsFtpConnectionThread.h	Mon Jan 31 06:51:12 2005
+++ ./netwerk/protocol/ftp/src/nsFtpConnectionThread.h	Mon Oct 23 16:59:55 2006
@@ -102,7 +102,10 @@
     FTP_S_MKD,  FTP_R_MKD,
     FTP_S_RMD,  FTP_R_RMD,
     FTP_S_RNFR, FTP_R_RNFR,
-    FTP_S_RNTO, FTP_R_RNTO
+    FTP_S_RNTO, FTP_R_RNTO,
+    FTP_S_OS400_NAMEFMT, FTP_R_OS400_NAMEFMT,
+    FTP_S_OS400_LISTFMT, FTP_R_OS400_LISTFMT,
+    FTP_S_OS400_STARTROOT, FTP_R_OS400_STARTROOT
 } FTP_STATE;
 
 // higher level ftp actions
@@ -194,6 +197,10 @@
 
     nsresult        S_rnfr(); FTP_STATE       R_rnfr();
     nsresult        S_rnto(); FTP_STATE       R_rnto();
+
+    nsresult S_os400_namefmt(); FTP_STATE R_os400_namefmt();
+    nsresult S_os400_listfmt(); FTP_STATE R_os400_listfmt();
+    nsresult S_os400_startroot(); FTP_STATE R_os400_startroot();
     // END: STATE METHODS
     ///////////////////////////////////
 
