Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlInterface.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlInterface.cpp	(revision 71137)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlInterface.cpp	(revision 71138)
@@ -70,4 +70,48 @@
         commandData.m_strPassword = ValueUnion.psz;   \
         break;
+
+QString getFsObjTypeString(KFsObjType type)
+{
+    QString strType;
+    switch(type)
+    {
+        case (KFsObjType_Unknown):
+            strType = "Unknown";
+            break;
+    case (KFsObjType_Fifo):
+        strType = "Fifo";
+        break;
+
+    case (KFsObjType_DevChar):
+        strType = "DevChar";
+        break;
+
+    case (KFsObjType_Directory):
+        strType = "Directory";
+        break;
+
+    case (KFsObjType_DevBlock):
+        strType = "DevBlock";
+        break;
+
+    case (KFsObjType_File):
+        strType = "File";
+        break;
+    case (KFsObjType_Symlink):
+        strType = "Symlink";
+        break;
+    case (KFsObjType_Socket):
+        strType = "Socket";
+        break;
+
+    case (KFsObjType_WhiteOut):
+        strType = "WhiteOut";
+        break;
+    default:
+        strType = "Unknown";
+        break;
+    }
+    return strType;
+};
 
 QString generateErrorString(int getOptErrorCode, const RTGETOPTUNION &/*valueUnion*/)
@@ -143,5 +187,5 @@
                 "                                   [-P|--parents] [<guest directory>\n"
                 "                                   [--sessionid <id> |  [sessionname <name>]]\n"
-                "stat                            [common-options]\n"
+                "[stat|ls                          [common-options]\n"
                 "                                   [--sessionid <id> |  [sessionname <name>]]\n"
                 )
@@ -274,4 +318,6 @@
     if (!findOrCreateSession(commandData, guestSession) || !guestSession.isOk())
         return false;
+    if (guestSession.GetStatus() != KGuestSessionStatus_Started)
+        RETURN_ERROR("The guest session is not valid");
 
     bool isADirectory =
@@ -385,4 +431,7 @@
         }
     }
+    /* search within the existing CGuestSessions and return a valid one if found: */
+    if (findAValidGuestSession(outGuestSession))
+        return true;
     /* if neither sessionname and session id is given then create a new session */
     else
@@ -392,4 +441,21 @@
     }
     return true;
+}
+
+bool UIGuestControlInterface::findAValidGuestSession(CGuestSession &outGuestSession)
+{
+    if (!m_comGuest.isOk())
+        return false;
+
+    QVector<CGuestSession> sessions = m_comGuest.GetSessions();
+    for(int i = 0; i < sessions.size(); ++i)
+    {
+        if (sessions[i].isOk() && sessions[i].GetStatus() == KGuestSessionStatus_Started)
+        {
+            outGuestSession = sessions[i];
+            return true;
+        }
+    }
+    return false;
 }
 
@@ -462,4 +528,5 @@
     m_subCommandHandlers.insert("mkdir" , &UIGuestControlInterface::handleMkdir);
     m_subCommandHandlers.insert("stat" , &UIGuestControlInterface::handleStat);
+    m_subCommandHandlers.insert("ls" , &UIGuestControlInterface::handleStat);
 }
 
@@ -552,4 +619,8 @@
 bool UIGuestControlInterface::createSession(const CommandData &commandData, CGuestSession& outSession)
 {
+    if (!m_comGuest.isOk())
+        return false;
+    if(commandData.m_strUserName.isEmpty())
+        RETURN_ERROR("No user name has been given");
     CGuestSession guestSession = m_comGuest.CreateSession(commandData.m_strUserName,
                                                           commandData.m_strPassword,
@@ -575,9 +646,9 @@
     if (!fsObjectInfo.isOk())
         return strInfo;
-    strInfo.append(QString("Name %1 \n").arg(fsObjectInfo.GetName()));
-    strInfo.append(QString("Size %1 \n").arg(fsObjectInfo.GetObjectSize()));
-    strInfo.append(QString("User %1 \n").arg(fsObjectInfo.GetUserName()));
-    strInfo.append(QString("BirthTime %1 \n").arg(fsObjectInfo.GetBirthTime()));
-    strInfo.append(QString("ChangeTime %1 ").arg(fsObjectInfo.GetChangeTime()));
+    strInfo.append(QString("%1 \t").arg(fsObjectInfo.GetName()));
+    strInfo.append(QString("%1 \t").arg(getFsObjTypeString(fsObjectInfo.GetType())));
+    strInfo.append(QString("%1 \t").arg(fsObjectInfo.GetObjectSize()));
+    strInfo.append(QString("%1 \t").arg(fsObjectInfo.GetBirthTime()));
+    strInfo.append(QString("%1 ").arg(fsObjectInfo.GetChangeTime()));
 
     return strInfo;
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlInterface.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlInterface.h	(revision 71137)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlInterface.h	(revision 71138)
@@ -58,5 +58,7 @@
     /** findOrCreateSession parses command options and determines if an existing session
         to be returned or a new one to be created */
-    bool findOrCreateSession(const CommandData &commandData, CGuestSession &guestSession);
+    bool findOrCreateSession(const CommandData &commandData, CGuestSession &outGuestSession);
+    /* Search a valid gurst session among existing ones, assign @p outGuestSession if found and return true */
+    bool findAValidGuestSession(CGuestSession &outGuestSession);
     bool findSession(const QString& strSessionName, CGuestSession& outSession);
     bool findSession(ULONG strSessionId, CGuestSession& outSession);
