mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
generic: drop SMB and NFS support
I cannot think of a use case for them with kdirshare service in place, never needed to access one either Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
f28ca2226a
commit
56b3460011
55 changed files with 11 additions and 16254 deletions
|
@ -161,17 +161,6 @@ set_package_properties(RAW1394 PROPERTIES
|
|||
PURPOSE "View FireWire devices in kinfocenter"
|
||||
)
|
||||
|
||||
# we need a version of samba which has already smbc_set_context(), Alex
|
||||
set(SAMBA_REQUIRE_SMBC_SET_CONTEXT TRUE)
|
||||
set(SAMBA_REQUIRE_SMBC_OPTION_SET TRUE)
|
||||
macro_optional_find_package(Samba)
|
||||
set_package_properties(Samba PROPERTIES
|
||||
DESCRIPTION "the SMB client library, a version with smbc_set_context() and smbc_option_set()"
|
||||
URL "http://www.samba.org"
|
||||
TYPE OPTIONAL
|
||||
PURPOSE "Needed to build the SMB kioslave"
|
||||
)
|
||||
|
||||
macro_optional_find_package(LibSSH 0.6.0)
|
||||
set_package_properties(LibSSH PROPERTIES
|
||||
DESCRIPTION "the SSH library with SFTP support"
|
||||
|
|
|
@ -23,8 +23,8 @@ build_script:
|
|||
libxcb-damage0-dev libxcb-xfixes0-dev libxcb-render0-dev libxcb-randr0-dev \
|
||||
libxcb-shape0-dev libxcb-sync-dev libxcb-render-util0-dev libxcb-keysyms1-dev \
|
||||
libglu1-mesa-dev mesa-common-dev libmtp-dev libusb-1.0-0-dev libssh-dev \
|
||||
libsmbclient-dev libdrm-dev libraw1394-dev libsensors4-dev libgphoto2-dev \
|
||||
libegl-dev libpci-dev libopenexr-dev liblightdm-gobject-1-dev libkmod-dev \
|
||||
libdrm-dev libraw1394-dev libsensors4-dev libgphoto2-dev libegl-dev \
|
||||
libpci-dev libopenexr-dev liblightdm-gobject-1-dev libkmod-dev \
|
||||
libdbusmenu-katie \
|
||||
sudo ctags cppcheck lrzsz locate \
|
||||
ariya-icons dbus-x11 ccache
|
||||
|
|
|
@ -4,7 +4,6 @@ add_subdirectory( infosummary )
|
|||
add_subdirectory( memory )
|
||||
add_subdirectory( devinfo )
|
||||
add_subdirectory( info )
|
||||
add_subdirectory( samba )
|
||||
add_subdirectory( nics )
|
||||
add_subdirectory( pci )
|
||||
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
Samba Status Module:
|
||||
|
||||
Michael Glauche <glauche@isa.rwth-aachen.de>
|
||||
|
||||
Conversion to kcontrol applet:
|
||||
|
||||
Matthias Hoelzer <hoelzer@physik.uni-wuerzburg.de>
|
||||
|
||||
Use of K3Process instead of popen, and more error checking
|
||||
|
||||
David Faure <David.Faure@insa-lyon.fr>
|
||||
|
||||
Added Window and Column resizing:
|
||||
|
||||
Harald Koschinski <Harald.Koschinski@arcormail.de>
|
||||
|
||||
KTabListBox to QListView conversion and use of QLayout:
|
||||
|
||||
Wilco Greven <j.w.greven@student.utwente.nl>
|
||||
|
||||
Conversion to KDE2 kcontrol module
|
||||
Corrected parsing of the smbstatus output
|
||||
(now works also with shares containing spaces "a share name")
|
||||
Added three tab pages
|
||||
-one for viewing mounted network resources (Samba and NFS, works on Linux, maybe Solaris)
|
||||
-one for viewing samba logfile
|
||||
-one for some filtering of samba logfile
|
||||
Added support for viewing NFS-exports mounted by remote hosts on the first
|
||||
tab
|
||||
|
||||
Alexander Neundorf <alexander.neundorf@rz.tu-ilmenau.de>
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
set(kcm_samba_PART_SRCS
|
||||
main.cpp
|
||||
ksmbstatus.cpp
|
||||
kcmsambaimports.cpp
|
||||
kcmsambalog.cpp
|
||||
kcmsambastatistics.cpp )
|
||||
|
||||
|
||||
kde4_add_plugin(kcm_samba ${kcm_samba_PART_SRCS})
|
||||
|
||||
|
||||
target_link_libraries(kcm_samba ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS})
|
||||
|
||||
install(TARGETS kcm_samba DESTINATION ${KDE4_PLUGIN_INSTALL_DIR} )
|
||||
|
||||
|
||||
########### install files ###############
|
||||
|
||||
install( FILES smbstatus.desktop DESTINATION ${KDE4_SERVICES_INSTALL_DIR} )
|
|
@ -1,2 +0,0 @@
|
|||
#!/bin/bash
|
||||
$XGETTEXT *.cpp -o $podir/kcmsamba.pot
|
|
@ -1,90 +0,0 @@
|
|||
/*
|
||||
* kcmsambaimports.cpp
|
||||
*
|
||||
* Copyright (c) 2000 Alexander Neundorf <alexander.neundorf@rz.tu-ilmenau.de>
|
||||
*
|
||||
* Requires the Qt widget libraries, available at no cost at
|
||||
* http://www.troll.no/
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#include "kcmsambaimports.h"
|
||||
#include "moc_kcmsambaimports.cpp"
|
||||
|
||||
#include <QLayout>
|
||||
#include <QWhatsThis>
|
||||
|
||||
#include <klocale.h>
|
||||
#include <kdialog.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
ImportsView::ImportsView(QWidget * parent) :
|
||||
QWidget(parent), list(this) {
|
||||
QBoxLayout *topLayout = new QVBoxLayout(this);
|
||||
topLayout->setMargin(KDialog::marginHint());
|
||||
topLayout->setSpacing(KDialog::spacingHint());
|
||||
topLayout->addWidget(&list);
|
||||
|
||||
list.setAllColumnsShowFocus(true);
|
||||
list.setMinimumSize(425, 200);
|
||||
list.setHeaderLabels(QStringList() << i18n("Type") << i18n("Resource") << i18n("Mounted Under"));
|
||||
|
||||
this->setWhatsThis(i18n("This list shows the Samba and NFS shared"
|
||||
" resources mounted on your system from other hosts. The \"Type\""
|
||||
" column tells you whether the mounted resource is a Samba or an NFS"
|
||||
" type of resource. The \"Resource\" column shows the descriptive name"
|
||||
" of the shared resource. Finally, the third column, which is labeled"
|
||||
" \"Mounted under\" shows the location on your system where the shared"
|
||||
" resource is mounted.") );
|
||||
|
||||
timer.start(10000);
|
||||
QObject::connect(&timer, SIGNAL(timeout()), this, SLOT(updateList()));
|
||||
updateList();
|
||||
}
|
||||
|
||||
void ImportsView::updateList() {
|
||||
list.clear();
|
||||
char *e;
|
||||
char buf[250];
|
||||
QByteArray s(""), strSource, strMount, strType;
|
||||
FILE *f=popen("mount", "r");
|
||||
if (f==0)
|
||||
return;
|
||||
do {
|
||||
e=fgets(buf, 250, f);
|
||||
if (e!=0) {
|
||||
s=buf;
|
||||
if ((s.contains(" nfs ")) || (s.contains(" smbfs "))) {
|
||||
strSource=s.left(s.indexOf(" on /"));
|
||||
strMount=s.mid(s.indexOf(" on /")+4, s.length());
|
||||
if ((s.contains(" nfs ")) || (s.contains("/remote on ")))
|
||||
strType="NFS";
|
||||
else if (s.contains(" smbfs "))
|
||||
strType="SMB";
|
||||
int pos(strMount.indexOf(" type "));
|
||||
if (pos==-1)
|
||||
pos=strMount.indexOf(" read/");
|
||||
strMount=strMount.left(pos);
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(&list);
|
||||
item->setText(0, strType);
|
||||
item->setText(1, strSource);
|
||||
item->setText(2, strMount);
|
||||
};
|
||||
};
|
||||
} while (!feof(f));
|
||||
pclose(f);
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* kcmsambaimports.h
|
||||
*
|
||||
* Copyright (c) 2000 Alexander Neundorf <alexander.neundorf@rz.tu-ilmenau.de>
|
||||
*
|
||||
* Requires the Qt widget libraries, available at no cost at
|
||||
* http://www.troll.no/
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef kcmsambaimports_h_included
|
||||
#define kcmsambaimports_h_included
|
||||
|
||||
#include <QTimer>
|
||||
#include <QTreeWidget>
|
||||
|
||||
#include <KConfig>
|
||||
|
||||
class ImportsView : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ImportsView(QWidget *parent);
|
||||
virtual ~ImportsView() {
|
||||
}
|
||||
void saveSettings() {
|
||||
}
|
||||
void loadSettings() {
|
||||
}
|
||||
private:
|
||||
QTreeWidget list;
|
||||
QTimer timer;
|
||||
private Q_SLOTS:
|
||||
void updateList();
|
||||
};
|
||||
|
||||
#endif // main_included
|
|
@ -1,232 +0,0 @@
|
|||
/*
|
||||
* kcmsambalog.cpp
|
||||
*
|
||||
* Copyright (c) 2000 Alexander Neundorf <neundorf@kde.org>
|
||||
*
|
||||
* Requires the Qt widget libraries, available at no cost at
|
||||
* http://www.troll.no/
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QFile>
|
||||
#include <QLayout>
|
||||
|
||||
#include <kmessagebox.h>
|
||||
#include <kdialog.h>
|
||||
#include <klocale.h>
|
||||
|
||||
#include "kcmsambalog.h"
|
||||
#include "moc_kcmsambalog.cpp"
|
||||
|
||||
#define LOG_SCREEN_XY_OFFSET 10
|
||||
|
||||
LogView::LogView(QWidget *parent, KConfig *config) :
|
||||
QWidget(parent), configFile(config), filesCount(0), connectionsCount(0), logFileName(KUrl::fromPath("/var/log/samba.log"), this), label(i18n("Samba log file: "), this), viewHistory(this), showConnOpen(i18n("Show opened connections"), this), showConnClose(i18n("Show closed connections"), this),
|
||||
showFileOpen(i18n("Show opened files"), this), showFileClose(i18n("Show closed files"), this), updateButton(i18n("&Update"), this) {
|
||||
label.setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
label.setBuddy( &logFileName);
|
||||
QVBoxLayout *mainLayout=new QVBoxLayout(this);
|
||||
mainLayout->setMargin(KDialog::marginHint());
|
||||
mainLayout->setSpacing(KDialog::spacingHint());
|
||||
QHBoxLayout *leLayout=new QHBoxLayout();
|
||||
mainLayout->addItem(leLayout);
|
||||
leLayout->addWidget(&label);
|
||||
leLayout->addWidget(&logFileName, 1);
|
||||
mainLayout->addWidget(&viewHistory, 1);
|
||||
QGridLayout *subLayout=new QGridLayout();
|
||||
mainLayout->addItem(subLayout);
|
||||
subLayout->addWidget(&showConnOpen, 0, 0);
|
||||
subLayout->addWidget(&showConnClose, 1, 0);
|
||||
subLayout->addWidget(&showFileOpen, 0, 1);
|
||||
subLayout->addWidget(&showFileClose, 1, 1);
|
||||
mainLayout->addWidget(&updateButton, 0, Qt::AlignLeft);
|
||||
|
||||
logFileName.setWhatsThis(i18n("This page presents the contents of"
|
||||
" your samba log file in a friendly layout. Check that the correct log"
|
||||
" file for your computer is listed here. If you need to, correct the name"
|
||||
" or location of the log file, and then click the \"Update\" button.") );
|
||||
|
||||
showConnOpen.setWhatsThis(i18n("Check this option if you want to"
|
||||
" view the details for connections opened to your computer.") );
|
||||
|
||||
showConnClose.setWhatsThis(i18n("Check this option if you want to"
|
||||
" view the events when connections to your computer were closed.") );
|
||||
|
||||
showFileOpen.setWhatsThis(i18n("Check this option if you want to"
|
||||
" see the files which were opened on your computer by remote users."
|
||||
" Note that file open/close events are not logged unless the samba"
|
||||
" log level is set to at least 2 (you cannot set the log level"
|
||||
" using this module).") );
|
||||
|
||||
showFileClose.setWhatsThis(i18n("Check this option if you want to"
|
||||
" see the events when files opened by remote users were closed."
|
||||
" Note that file open/close events are not logged unless the samba"
|
||||
" log level is set to at least 2 (you cannot set the log level"
|
||||
" using this module).") );
|
||||
|
||||
updateButton.setWhatsThis(i18n("Click here to refresh the information"
|
||||
" on this page. The log file (shown above) will be read to obtain the"
|
||||
" events logged by samba.") );
|
||||
|
||||
viewHistory.setAllColumnsShowFocus(true);
|
||||
viewHistory.setFocusPolicy(Qt::ClickFocus);
|
||||
|
||||
QStringList headers;
|
||||
headers << i18n("Date & Time") << i18n("Event") << i18n("Service/File")
|
||||
<< i18n("Host/User") << i18n("Date & Time") << i18n("Event")
|
||||
<< i18n("Service/File") << i18n("Host/User");
|
||||
viewHistory.setHeaderLabels(headers);
|
||||
|
||||
viewHistory.setWhatsThis(i18n("<p>This list shows details of the events"
|
||||
" logged by samba. Note that events at the file level are not logged"
|
||||
" unless you have configured the log level for samba to 2 or greater.</p><p>"
|
||||
" As with many other lists in KDE, you can click on a column heading"
|
||||
" to sort on that column. Click again to change the sorting direction"
|
||||
" from ascending to descending or vice versa.</p><p>"
|
||||
" If the list is empty, try clicking the \"Update\" button. The samba"
|
||||
" log file will be read and the list refreshed.</p>") );
|
||||
|
||||
showConnOpen.setChecked(true);
|
||||
showConnClose.setChecked(true);
|
||||
showFileOpen.setChecked(false);
|
||||
showFileClose.setChecked(false);
|
||||
|
||||
connect(&updateButton, SIGNAL(clicked()), this, SLOT(updateList()));
|
||||
emit contentsChanged(&viewHistory, 0, 0);
|
||||
|
||||
label.setMinimumSize(label.sizeHint());
|
||||
logFileName.setMinimumSize(250, logFileName.sizeHint().height());
|
||||
viewHistory.setMinimumSize(425, 200);
|
||||
showConnOpen.setMinimumSize(showConnOpen.sizeHint());
|
||||
showConnClose.setMinimumSize(showConnClose.sizeHint());
|
||||
showFileOpen.setMinimumSize(showFileOpen.sizeHint());
|
||||
showFileClose.setMinimumSize(showFileClose.sizeHint());
|
||||
updateButton.setFixedSize(updateButton.sizeHint());
|
||||
}
|
||||
|
||||
void LogView::loadSettings() {
|
||||
if (configFile==0)
|
||||
return;
|
||||
KConfigGroup group = configFile->group(LOGGROUPNAME);
|
||||
logFileName.setUrl(KUrl(group.readPathEntry("SambaLogFile", "/var/log/samba.log")));
|
||||
|
||||
showConnOpen.setChecked(group.readEntry("ShowConnectionOpen", true));
|
||||
showConnClose.setChecked(group.readEntry("ShowConnectionClose", false));
|
||||
showFileOpen.setChecked(group.readEntry("ShowFileOpen", true));
|
||||
showFileClose.setChecked(group.readEntry("ShowFileClose", false));
|
||||
}
|
||||
|
||||
void LogView::saveSettings() {
|
||||
if (configFile==0)
|
||||
return;
|
||||
KConfigGroup group = configFile->group(LOGGROUPNAME);
|
||||
group.writePathEntry("SambaLogFile", logFileName.url().path());
|
||||
|
||||
group.writeEntry("ShowConnectionOpen", showConnOpen.isChecked());
|
||||
group.writeEntry("ShowConnectionClose", showConnClose.isChecked());
|
||||
group.writeEntry("ShowFileOpen", showFileOpen.isChecked());
|
||||
group.writeEntry("ShowFileClose", showFileClose.isChecked());
|
||||
}
|
||||
|
||||
#define CONN_OPEN " connect to service "
|
||||
#define CONN_CLOSE " closed connection to service "
|
||||
#define FILE_OPEN " opened file "
|
||||
#define FILE_CLOSE " closed file "
|
||||
|
||||
//caution ! high optimized code :-)
|
||||
void LogView::updateList() {
|
||||
QFile logFile(logFileName.url().path());
|
||||
if (logFile.open(QIODevice::ReadOnly)) {
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
viewHistory.clear();
|
||||
filesCount=0;
|
||||
connectionsCount=0;
|
||||
|
||||
int connOpenLen(strlen(CONN_OPEN));
|
||||
int connCloseLen(strlen(CONN_CLOSE));
|
||||
int fileOpenLen(strlen(FILE_OPEN));
|
||||
int fileCloseLen(strlen(FILE_CLOSE));
|
||||
|
||||
char buf[400];
|
||||
char *c1, *c2, *c3, *c4, *c, time[25];
|
||||
int timeRead(0);
|
||||
|
||||
while (!logFile.atEnd()) {
|
||||
logFile.readLine(buf, sizeof(buf));
|
||||
timeRead=0;
|
||||
if (buf[0]=='[') {
|
||||
if (strlen(buf)>11)
|
||||
if (buf[5]=='/') {
|
||||
buf[20]='\0';
|
||||
strncpy(time, buf+1, sizeof(time));
|
||||
time[sizeof(time)-1] = '\0';
|
||||
timeRead=1;
|
||||
};
|
||||
};
|
||||
if (timeRead==0) {
|
||||
c1=0;
|
||||
c2=0;
|
||||
c3=0;
|
||||
c4=0;
|
||||
if (showConnOpen.isChecked())
|
||||
c1=strstr(buf, CONN_OPEN);
|
||||
if (c1==0) {
|
||||
if (showConnClose.isChecked())
|
||||
c2=strstr(buf, CONN_CLOSE);
|
||||
if (c2==0) {
|
||||
if (showFileOpen.isChecked())
|
||||
c3=strstr(buf, FILE_OPEN);
|
||||
if (c3==0) {
|
||||
if (showFileClose.isChecked())
|
||||
c4=strstr(buf, FILE_CLOSE);
|
||||
if (c4==0)
|
||||
continue;
|
||||
};
|
||||
};
|
||||
};
|
||||
if (c1!=0) {
|
||||
c=strstr(buf, " as user");
|
||||
*c='\0';
|
||||
*c1='\0';
|
||||
new QTreeWidgetItemX(&viewHistory,time,I18N_NOOP("CONNECTION OPENED"),c1+connOpenLen,buf+2);
|
||||
connectionsCount++;
|
||||
} else if (c2!=0) {
|
||||
*c2='\0';
|
||||
new QTreeWidgetItemX(&viewHistory,time,I18N_NOOP("CONNECTION CLOSED"),c2+connCloseLen,buf+2);
|
||||
} else if (c3!=0) {
|
||||
c=strstr(buf, " read=");
|
||||
*c='\0';
|
||||
*c3='\0';
|
||||
new QTreeWidgetItemX(&viewHistory,time,I18N_NOOP(" FILE OPENED"),c3+fileOpenLen,buf+2);
|
||||
filesCount++;
|
||||
} else if (c4!=0) {
|
||||
c=strstr(buf, " (numopen=");
|
||||
*c='\0';
|
||||
*c4='\0';
|
||||
new QTreeWidgetItemX(&viewHistory,time,I18N_NOOP(" FILE CLOSED"),c4+fileCloseLen,buf+2);
|
||||
};
|
||||
};
|
||||
};
|
||||
logFile.close();
|
||||
emit contentsChanged(&viewHistory, filesCount, connectionsCount);
|
||||
QApplication::restoreOverrideCursor();
|
||||
} else {
|
||||
QString tmp = i18n("Could not open file %1", logFileName.url().path());
|
||||
KMessageBox::error(this, tmp);
|
||||
};
|
||||
}
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* kcmsambalog.h
|
||||
*
|
||||
* Copyright (c) 2000 Alexander Neundorf <neundorf@kde.org>
|
||||
*
|
||||
* Requires the Qt widget libraries, available at no cost at
|
||||
* http://www.troll.no/
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#ifndef kcmsambalog_h_included
|
||||
#define kcmsambalog_h_included
|
||||
|
||||
#include <QLabel>
|
||||
#include <QCheckBox>
|
||||
#include <QPushButton>
|
||||
#include <QTreeWidget>
|
||||
#include <QEvent>
|
||||
|
||||
#include <KConfig>
|
||||
#include <KUrlRequester>
|
||||
|
||||
#define LOGGROUPNAME "SambaLogFileSettings"
|
||||
|
||||
class LogView : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LogView(QWidget *parent=0, KConfig *config=0);
|
||||
virtual ~LogView() {
|
||||
}
|
||||
void saveSettings();
|
||||
void loadSettings();
|
||||
private:
|
||||
KConfig *configFile;
|
||||
int filesCount, connectionsCount;
|
||||
KUrlRequester logFileName;
|
||||
QLabel label;
|
||||
QTreeWidget viewHistory;
|
||||
QCheckBox showConnOpen, showConnClose, showFileOpen, showFileClose;
|
||||
QPushButton updateButton;
|
||||
private Q_SLOTS:
|
||||
void updateList();
|
||||
Q_SIGNALS:
|
||||
void contentsChanged(QTreeWidget *list, int nrOfFiles, int nrOfConnections);
|
||||
};
|
||||
|
||||
class QTreeWidgetItemX : public QTreeWidgetItem {
|
||||
public:
|
||||
//a faster constructor saves a lot time
|
||||
QTreeWidgetItemX(QTreeWidget *parent, const char *c0, const char *c1 = 0, const char *c2 = 0, const char *c3 = 0, const char *c4 = 0, const char *c5 = 0, const char *c6 = 0, const char *c7 = 0) :
|
||||
QTreeWidgetItem(parent) {
|
||||
setText( 0, c0);
|
||||
setText( 1, c1);
|
||||
setText( 2, c2);
|
||||
setText( 3, c3);
|
||||
if (c4==0)
|
||||
return;
|
||||
setText( 4, c4);
|
||||
if (c5==0)
|
||||
return;
|
||||
setText( 5, c5);
|
||||
if (c6==0)
|
||||
return;
|
||||
setText( 6, c6);
|
||||
if (c7==0)
|
||||
return;
|
||||
setText( 7, c7);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // main_included
|
|
@ -1,309 +0,0 @@
|
|||
/*
|
||||
* kcmsambastatistics.cpp
|
||||
*
|
||||
* Copyright (c) 2000 Alexander Neundorf <alexander.neundorf@rz.tu-ilmenau.de>
|
||||
*
|
||||
* Requires the Qt widget libraries, available at no cost at
|
||||
* http://www.troll.no/
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#include "kcmsambastatistics.h"
|
||||
#include "moc_kcmsambastatistics.cpp"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QPushButton>
|
||||
#include <QRegExp>
|
||||
#include <QTreeWidget>
|
||||
|
||||
#include <KDebug>
|
||||
#include <KDialog>
|
||||
#include <KGlobal>
|
||||
#include <KLocale>
|
||||
|
||||
StatisticsView::StatisticsView(QWidget *parent) :
|
||||
QWidget(parent), dataList(0), connectionsCount(0), filesCount(0), calcCount(0) {
|
||||
viewStatistics = new QTreeWidget( this );
|
||||
connectionsL = new QLabel( i18n( "Connections: 0" ), this );
|
||||
connectionsL->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
filesL = new QLabel( i18n( "File accesses: 0" ), this );
|
||||
filesL->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
eventCb = new QComboBox( this );
|
||||
eventL = new QLabel( i18n( "Event: " ), this );
|
||||
eventL->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
eventL->setBuddy(eventCb);
|
||||
serviceLe = new QLineEdit( this );
|
||||
serviceL = new QLabel( i18n( "Service/File:" ), this );
|
||||
serviceL->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
serviceL->setBuddy(serviceLe);
|
||||
hostLe = new QLineEdit( this );
|
||||
hostL = new QLabel( i18n( "Host/User:" ), this );
|
||||
hostL->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
hostL->setBuddy(hostLe);
|
||||
calcButton = new QPushButton( i18n( "&Search" ), this );
|
||||
clearButton = new QPushButton( i18n( "Clear Results" ), this );
|
||||
expandedInfoCb = new QCheckBox( i18n( "Show expanded service info" ), this );
|
||||
expandedUserCb = new QCheckBox( i18n( "Show expanded host info" ), this );
|
||||
|
||||
viewStatistics->setAllColumnsShowFocus(true);
|
||||
viewStatistics->setFocusPolicy(Qt::ClickFocus);
|
||||
|
||||
QStringList headers;
|
||||
headers << i18n("Nr") << i18n("Event") << i18n("Service/File") << i18n("Host/User") << i18n("Hits"); //i18n("Percentage"),100);
|
||||
viewStatistics->setHeaderLabels(headers);
|
||||
|
||||
eventCb->setEditable(false);
|
||||
eventCb->addItem(i18n("Connection"));
|
||||
eventCb->addItem(i18n("File Access"));
|
||||
|
||||
expandedInfoCb->setChecked(false);
|
||||
expandedUserCb->setChecked(false);
|
||||
clearStatistics();
|
||||
serviceLe->setText("*");
|
||||
hostLe->setText("*");
|
||||
|
||||
viewStatistics->setMinimumSize(375, 200);
|
||||
connectionsL->setMinimumSize(connectionsL->sizeHint());
|
||||
filesL->setMinimumSize(filesL->sizeHint());
|
||||
eventL->setMinimumSize(eventL->sizeHint());
|
||||
eventCb->setMinimumSize(eventCb->sizeHint());
|
||||
hostL->setMinimumSize(hostL->sizeHint());
|
||||
hostLe->setMinimumSize(120, hostLe->sizeHint().height());
|
||||
serviceL->setMinimumSize(serviceL->sizeHint());
|
||||
serviceLe->setMinimumSize(120, serviceLe->sizeHint().height());
|
||||
calcButton->setMinimumSize(calcButton->sizeHint());
|
||||
clearButton->setMinimumSize(clearButton->sizeHint());
|
||||
expandedInfoCb->setMinimumSize(expandedInfoCb->sizeHint());
|
||||
expandedUserCb->setMinimumSize(expandedUserCb->sizeHint());
|
||||
|
||||
QVBoxLayout *topLayout=new QVBoxLayout(this);
|
||||
topLayout->setMargin(KDialog::marginHint());
|
||||
topLayout->setSpacing(KDialog::spacingHint());
|
||||
topLayout->addWidget(viewStatistics, 1);
|
||||
QGridLayout *subLayout=new QGridLayout();
|
||||
topLayout->addItem(subLayout);
|
||||
subLayout->setColumnStretch(1, 1);
|
||||
subLayout->setColumnStretch(2, 1);
|
||||
|
||||
QHBoxLayout *twoButtonsLayout=new QHBoxLayout;
|
||||
twoButtonsLayout->addWidget(calcButton, 1);
|
||||
twoButtonsLayout->addWidget(clearButton, 1);
|
||||
|
||||
subLayout->addWidget(connectionsL, 0, 0);
|
||||
subLayout->addWidget(filesL, 0, 1);
|
||||
subLayout->addWidget(eventL, 1, 0);
|
||||
subLayout->addWidget(serviceL, 1, 1);
|
||||
subLayout->addWidget(hostL, 1, 2);
|
||||
subLayout->addWidget(eventCb, 2, 0);
|
||||
subLayout->addWidget(serviceLe, 2, 1);
|
||||
subLayout->addWidget(hostLe, 2, 2);
|
||||
subLayout->addLayout(twoButtonsLayout, 3, 0);
|
||||
subLayout->addWidget(expandedInfoCb, 3, 1);
|
||||
subLayout->addWidget(expandedUserCb, 3, 2);
|
||||
|
||||
connect(clearButton, SIGNAL(clicked()), this, SLOT(clearStatistics()));
|
||||
connect(calcButton, SIGNAL(clicked()), this, SLOT(calculate()));
|
||||
setListInfo(0, 0, 0);
|
||||
}
|
||||
|
||||
void StatisticsView::setListInfo(QTreeWidget *list, int nrOfFiles, int nrOfConnections) {
|
||||
dataList=list;
|
||||
filesCount=nrOfFiles;
|
||||
connectionsCount=nrOfConnections;
|
||||
connectionsL->setText(i18n("Connections: %1", KGlobal::locale()->formatNumber(connectionsCount, 0)));
|
||||
filesL->setText(i18n("File accesses: %1", KGlobal::locale()->formatNumber(filesCount, 0)));
|
||||
clearStatistics();
|
||||
}
|
||||
|
||||
void StatisticsView::calculate() {
|
||||
if (dataList==0)
|
||||
return;
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
int connCount(0);
|
||||
if (eventCb->currentText()==i18n("Connection"))
|
||||
connCount=1;
|
||||
//something has to be counted exactly
|
||||
if ((expandedInfoCb->isChecked()) || (expandedUserCb->isChecked())) {
|
||||
SambaLog sLog;
|
||||
QRegExp rService(serviceLe->text(), Qt::CaseInsensitive, QRegExp::Wildcard);
|
||||
QRegExp rHost(hostLe->text(), Qt::CaseInsensitive, QRegExp::Wildcard);
|
||||
QString item2, item3;
|
||||
for (int i = 0; i < dataList->topLevelItemCount(); ++i)
|
||||
{
|
||||
QTreeWidgetItem *item = dataList->topLevelItem(i);
|
||||
if (connCount) {
|
||||
if ((QString(item->text(1)).contains(i18n("CONNECTION OPENED"))) && (QString(item->text(2)).contains(rService)) && (QString(item->text(3)).contains(rHost))) {
|
||||
if (expandedInfoCb->isChecked())
|
||||
item2=item->text(2);
|
||||
else
|
||||
item2=serviceLe->text();
|
||||
if (expandedUserCb->isChecked())
|
||||
item3=item->text(3);
|
||||
else
|
||||
item3=hostLe->text();
|
||||
sLog.addItem(item2, item3);
|
||||
//count++;
|
||||
}
|
||||
} else {
|
||||
if ((QString(item->text(1)).contains(i18n("FILE OPENED"))) && (QString(item->text(2)).contains(rService)) && (QString(item->text(3)).contains(rHost))) {
|
||||
if (expandedInfoCb->isChecked())
|
||||
item2=item->text(2);
|
||||
else
|
||||
item2=serviceLe->text();
|
||||
if (expandedUserCb->isChecked())
|
||||
item3=item->text(3);
|
||||
else
|
||||
item3=hostLe->text();
|
||||
sLog.addItem(item2, item3);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (const LogItem *tmpItem, sLog.items)
|
||||
{
|
||||
if (!tmpItem)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (const SmallLogItem *tmpStr, tmpItem->accessed) {
|
||||
if (!tmpStr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
calcCount++;
|
||||
QString number("");
|
||||
number.sprintf("%6d", calcCount);
|
||||
QString hits("");
|
||||
hits.sprintf("%7d", tmpStr->count);
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(viewStatistics);
|
||||
item->setText(0, number);
|
||||
item->setText(1, eventCb->currentText());
|
||||
item->setText(2, tmpItem->name);
|
||||
item->setText(3, tmpStr->name);
|
||||
item->setText(4, hits);
|
||||
}
|
||||
}
|
||||
}
|
||||
//no expanded info needed
|
||||
else {
|
||||
calcCount++;
|
||||
int count(0);
|
||||
QRegExp rService(serviceLe->text(), Qt::CaseInsensitive, QRegExp::Wildcard);
|
||||
QRegExp rHost(hostLe->text(), Qt::CaseInsensitive, QRegExp::Wildcard);
|
||||
for (int i = 0; i < dataList->topLevelItemCount(); ++i)
|
||||
{
|
||||
QTreeWidgetItem *item = dataList->topLevelItem(i);
|
||||
if (connCount) {
|
||||
if ((QString(item->text(1)).contains(i18n("CONNECTION OPENED"))) && (QString(item->text(2)).contains(rService)) && (QString(item->text(3)).contains(rHost)))
|
||||
count++;
|
||||
} else {
|
||||
if ((QString(item->text(1)).contains(i18n("FILE OPENED"))) && (QString(item->text(2)).contains(rService)) && (QString(item->text(3)).contains(rHost)))
|
||||
count++;
|
||||
}
|
||||
}
|
||||
QString number("");
|
||||
number.sprintf("%6d", calcCount);
|
||||
QString hits("");
|
||||
hits.sprintf("%7d", count);
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(viewStatistics);
|
||||
item->setText(0, number);
|
||||
item->setText(1, eventCb->currentText());
|
||||
item->setText(2, serviceLe->text());
|
||||
item->setText(3, hostLe->text());
|
||||
item->setText(4, hits);
|
||||
};
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void StatisticsView::clearStatistics() {
|
||||
viewStatistics->clear();
|
||||
calcCount=0;
|
||||
}
|
||||
|
||||
void SambaLog::printItems() {
|
||||
kDebug() << "****** printing items: ******";
|
||||
foreach (const LogItem *tmpItem, items)
|
||||
{
|
||||
if (!tmpItem)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
kDebug() << "SERVICE: " << tmpItem->name;
|
||||
foreach (const SmallLogItem *tmpLog, tmpItem->accessed) {
|
||||
if (!tmpLog)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
kDebug() << " accessed by: " << tmpLog->name << " " << tmpLog->count;
|
||||
}
|
||||
}
|
||||
|
||||
kDebug() << "------ end of printing ------";
|
||||
}
|
||||
|
||||
LogItem* SambaLog::itemInList(const QString &name) {
|
||||
foreach (LogItem *tmpItem, items)
|
||||
{
|
||||
if (!tmpItem)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tmpItem->name==name)
|
||||
{
|
||||
return tmpItem;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SambaLog::addItem(const QString &share, const QString &user) {
|
||||
//cout<<" adding connection: -"<<share<<"- -"<<user<<"-"<<endl;
|
||||
LogItem* tmp(itemInList(share));
|
||||
if (tmp!=0) {
|
||||
tmp->count++;
|
||||
tmp->addItem(user);
|
||||
} else {
|
||||
items.append(new LogItem(share,user));
|
||||
};
|
||||
}
|
||||
|
||||
SmallLogItem* LogItem::itemInList(const QString &name) {
|
||||
foreach (SmallLogItem *tmpLog, accessed) {
|
||||
if (tmpLog && tmpLog->name==name) {
|
||||
return tmpLog;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void LogItem::addItem(const QString &host) {
|
||||
SmallLogItem* tmp(itemInList(host));
|
||||
if (tmp!=0)
|
||||
tmp->count++;
|
||||
else
|
||||
accessed.append(new SmallLogItem(host));
|
||||
}
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
/*
|
||||
* kcmsambastatistics.h
|
||||
*
|
||||
* Copyright (c) 2000 Alexander Neundorf <alexander.neundorf@rz.tu-ilmenau.de>
|
||||
*
|
||||
* Requires the Qt widget libraries, available at no cost at
|
||||
* http://www.troll.no/
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#ifndef kcmsambastatistics_h_included
|
||||
#define kcmsambastatistics_h_included
|
||||
|
||||
#include <QList>
|
||||
#include <QWidget>
|
||||
|
||||
#include <QTreeWidget>
|
||||
#include <QLabel>
|
||||
#include <QComboBox>
|
||||
#include <QCheckBox>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
|
||||
class KConfig;
|
||||
|
||||
class SmallLogItem {
|
||||
public:
|
||||
SmallLogItem() :
|
||||
name(""), count(0) {
|
||||
}
|
||||
SmallLogItem(const QString &n) :
|
||||
name(n), count(1) {
|
||||
}
|
||||
QString name;
|
||||
int count;
|
||||
};
|
||||
|
||||
class LogItem {
|
||||
public:
|
||||
LogItem() :
|
||||
name(""), accessed(), count(0) {
|
||||
}
|
||||
LogItem(const QString &n, const QString &a) :
|
||||
name(n), accessed(), count(1) {
|
||||
accessed.append(new SmallLogItem(a));
|
||||
}
|
||||
~LogItem() {
|
||||
qDeleteAll(accessed);
|
||||
accessed.clear();
|
||||
}
|
||||
QString name;
|
||||
QList<SmallLogItem *> accessed;
|
||||
int count;
|
||||
SmallLogItem* itemInList(const QString &name);
|
||||
void addItem(const QString &host);
|
||||
};
|
||||
|
||||
class SambaLog {
|
||||
public:
|
||||
~SambaLog() {
|
||||
qDeleteAll(items);
|
||||
items.clear();
|
||||
}
|
||||
QList<LogItem *> items;
|
||||
void addItem(const QString &share, const QString &host);
|
||||
void printItems();
|
||||
private:
|
||||
LogItem* itemInList(const QString &name);
|
||||
};
|
||||
|
||||
class StatisticsView : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit StatisticsView(QWidget *parent=0);
|
||||
virtual ~StatisticsView() {
|
||||
}
|
||||
void saveSettings() {
|
||||
}
|
||||
void loadSettings() {
|
||||
}
|
||||
public Q_SLOTS:
|
||||
void setListInfo(QTreeWidget *list, int nrOfFiles, int nrOfConnections);
|
||||
private:
|
||||
QTreeWidget* dataList;
|
||||
QTreeWidget* viewStatistics;
|
||||
QLabel* connectionsL, *filesL;
|
||||
QComboBox* eventCb;
|
||||
QLabel* eventL;
|
||||
QLineEdit* serviceLe;
|
||||
QLabel* serviceL;
|
||||
QLineEdit* hostLe;
|
||||
QLabel* hostL;
|
||||
QPushButton* calcButton, *clearButton;
|
||||
QCheckBox* expandedInfoCb, *expandedUserCb;
|
||||
int connectionsCount, filesCount, calcCount;
|
||||
private Q_SLOTS:
|
||||
void clearStatistics();
|
||||
void calculate();
|
||||
};
|
||||
#endif // main_included
|
|
@ -1,216 +0,0 @@
|
|||
/*
|
||||
* ksmbstatus.cpp
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <QLayout>
|
||||
|
||||
#include <klocale.h>
|
||||
#include <kdialog.h>
|
||||
#include <kstandarddirs.h>
|
||||
|
||||
#include "ksmbstatus.h"
|
||||
#include "moc_ksmbstatus.cpp"
|
||||
|
||||
#define Before(ttf,in) in.left(in.indexOf(ttf))
|
||||
#define After(ttf,in) (in.contains(ttf)?QString(in.mid(in.indexOf(ttf)+QString(ttf).length())):QString(""))
|
||||
|
||||
NetMon::NetMon(QWidget * parent) :
|
||||
QWidget(parent), showmountProc(0), strShare(""), strUser(""), strGroup(""), strMachine(""), strSince(""), strPid(""), iUser(0), iGroup(0), iMachine(0), iPid(0) {
|
||||
QBoxLayout *topLayout = new QVBoxLayout(this);
|
||||
topLayout->setMargin(KDialog::marginHint());
|
||||
topLayout->setSpacing(KDialog::spacingHint());
|
||||
|
||||
list = new QTreeWidget(this);
|
||||
topLayout->addWidget(list);
|
||||
version=new QLabel(this);
|
||||
version->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
topLayout->addWidget(version);
|
||||
|
||||
list->setAllColumnsShowFocus(true);
|
||||
list->setMinimumSize(425, 200);
|
||||
|
||||
QStringList headers;
|
||||
headers << i18n("Type") << i18n("Service") << i18n("Accessed From")
|
||||
<< i18n("UID") << i18n("GID") << i18n("PID") << i18n("Open Files");
|
||||
list->setHeaderLabels(headers);
|
||||
|
||||
timer = new QTimer(this);
|
||||
timer->start(15000);
|
||||
QObject::connect(timer, SIGNAL(timeout()), this, SLOT(update()));
|
||||
update();
|
||||
}
|
||||
|
||||
void NetMon::processNFSLine(char *bufline, int) {
|
||||
QByteArray line(bufline);
|
||||
if (line.contains(":/")) {
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(list);
|
||||
item->setText(0, "NFS");
|
||||
item->setText(0, After(":",line));
|
||||
item->setText(0, Before(":/",line));
|
||||
}
|
||||
}
|
||||
|
||||
void NetMon::processSambaLine(char *bufline, int) {
|
||||
QByteArray line(bufline);
|
||||
rownumber++;
|
||||
if (rownumber == 2)
|
||||
version->setText(bufline); // second line = samba version
|
||||
if ((readingpart==header) && line.contains("Service")) {
|
||||
iUser=line.indexOf("uid");
|
||||
iGroup=line.indexOf("gid");
|
||||
iPid=line.indexOf("pid");
|
||||
iMachine=line.indexOf("machine");
|
||||
} else if ((readingpart==header) && (line.contains("---"))) {
|
||||
readingpart=connexions;
|
||||
} else if ((readingpart==connexions) && (int(line.length())>=iMachine)) {
|
||||
strShare=line.mid(0, iUser);
|
||||
strUser=line.mid(iUser, iGroup-iUser);
|
||||
strGroup=line.mid(iGroup, iPid-iGroup);
|
||||
strPid=line.mid(iPid, iMachine-iPid);
|
||||
|
||||
line=line.mid(iMachine, line.length());
|
||||
strMachine=line;
|
||||
QTreeWidgetItem * item = new QTreeWidgetItem(list);
|
||||
item->setText(0, "SMB");
|
||||
item->setText(1, strShare);
|
||||
item->setText(2, strMachine);
|
||||
item->setText(3, strUser);
|
||||
item->setText(4, strGroup);
|
||||
item->setText(5, strPid/*,strSince*/);
|
||||
} else if (readingpart==connexions)
|
||||
readingpart=locked_files;
|
||||
else if ((readingpart==locked_files) && (line.indexOf("No ")==0))
|
||||
readingpart=finished;
|
||||
else if (readingpart==locked_files) {
|
||||
if ((strncmp(bufline, "Pi", 2) !=0) // "Pid DenyMode ..."
|
||||
&& (strncmp(bufline, "--", 2) !=0)) // "------------"
|
||||
{
|
||||
char *tok=strtok(bufline, " ");
|
||||
if (tok) {
|
||||
int pid=atoi(tok);
|
||||
(lo)[pid]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// called when we get some data from smbstatus
|
||||
// can be called for any size of buffer (one line, several lines,
|
||||
// half of one ...)
|
||||
void NetMon::readFromProcess() {
|
||||
QProcess *process = qobject_cast<QProcess *>(sender());
|
||||
if (!process || !process->canReadLine())
|
||||
return;
|
||||
|
||||
qint64 buflen = 8046; // 8k enough?
|
||||
char buffer[buflen];
|
||||
buflen = process->readLine(buffer, buflen);
|
||||
//kDebug()<<"received stuff";
|
||||
char s[250], *start, *end;
|
||||
size_t len;
|
||||
start = buffer;
|
||||
while ((end = strchr(start, '\n'))) // look for '\n'
|
||||
{
|
||||
len = end-start;
|
||||
if (len>=sizeof(s))
|
||||
len=sizeof(s)-1;
|
||||
strncpy(s, start, len);
|
||||
s[len] = '\0';
|
||||
//kDebug() << "recived: "<<s;
|
||||
if (readingpart==nfs)
|
||||
processNFSLine(s, len);
|
||||
else
|
||||
processSambaLine(s, len); // process each line
|
||||
start=end+1;
|
||||
}
|
||||
/* FIXME: is this needed? was here with the Q3Support classes, but seems a little inane
|
||||
if (readingpart==nfs) {
|
||||
list->viewport()->update();
|
||||
list->update();
|
||||
}
|
||||
*/
|
||||
// here we could save the remaining part of line, if ever buffer
|
||||
// doesn't end with a '\n' ... but will this happen ?
|
||||
}
|
||||
|
||||
void NetMon::smbstatusError()
|
||||
{
|
||||
version->setText(i18n("Error: Unable to run smbstatus"));
|
||||
}
|
||||
|
||||
void NetMon::update() {
|
||||
QProcess *process = new QProcess();
|
||||
|
||||
memset(&lo, 0, sizeof(lo));
|
||||
list->clear();
|
||||
/* Re-read the Contents ... */
|
||||
|
||||
QString smbstatusExe = KStandardDirs::findRootExe("smbstatus");
|
||||
|
||||
rownumber=0;
|
||||
readingpart=header;
|
||||
nrpid=0;
|
||||
connect(process, SIGNAL(readyRead()), SLOT(readFromProcess()));
|
||||
connect(process, SIGNAL(error(QProcess::ProcessError)), SLOT(smbstatusError()));
|
||||
process->start(smbstatusExe);
|
||||
process->waitForFinished();
|
||||
if (rownumber==0) { // empty result
|
||||
version->setText(i18n("Error: Unable to open configuration file \"smb.conf\""));
|
||||
} else {
|
||||
// ok -> count the number of locked files for each pid
|
||||
for (int i = 0; i < list->topLevelItemCount(); ++i)
|
||||
{
|
||||
QTreeWidgetItem *row = list->topLevelItem(i);
|
||||
// cerr<<"NetMon::update: this should be the pid: "<<row->text(5)<<endl;
|
||||
int pid=row->text(5).toInt();
|
||||
row->setText(6,QString::number((lo)[pid]));
|
||||
}
|
||||
}
|
||||
|
||||
delete process;
|
||||
process=0;
|
||||
|
||||
QString showmountExe = KStandardDirs::findRootExe("showmount");
|
||||
|
||||
readingpart=nfs;
|
||||
delete showmountProc;
|
||||
showmountProc=new QProcess();
|
||||
connect(showmountProc, SIGNAL(readyRead()), SLOT(readFromProcess()));
|
||||
//without this timer showmount hangs up to 5 minutes
|
||||
//if the portmapper daemon isn't running
|
||||
QTimer::singleShot(5000,this,SLOT(killShowmount()));
|
||||
//kDebug()<<"starting kill timer with 5 seconds";
|
||||
connect(showmountProc,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(killShowmount()));
|
||||
connect(showmountProc,SIGNAL(error(QProcess::ProcessError)),this,SLOT(killShowmount()));
|
||||
showmountProc->start(showmountExe, QStringList() << "-a" << "localhost");
|
||||
|
||||
version->adjustSize();
|
||||
list->show();
|
||||
}
|
||||
|
||||
void NetMon::killShowmount() {
|
||||
//kDebug()<<"killShowmount()";
|
||||
showmountProc->deleteLater();
|
||||
showmountProc=0;
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* ksmbstatus.h
|
||||
*
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#ifndef ksmbstatus_h_included
|
||||
#define ksmbstatus_h_included
|
||||
|
||||
#include <QTimer>
|
||||
#include <QTreeWidget>
|
||||
#include <QLabel>
|
||||
#include <QProcess>
|
||||
|
||||
#include <KConfig>
|
||||
|
||||
#define SCREEN_XY_OFFSET 20
|
||||
|
||||
class NetMon : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit NetMon(QWidget *parent);
|
||||
void saveSettings() {
|
||||
}
|
||||
void loadSettings() {
|
||||
}
|
||||
private:
|
||||
QProcess *showmountProc;
|
||||
QTreeWidget *list;
|
||||
QLabel *version;
|
||||
QTimer *timer;
|
||||
int rownumber;
|
||||
enum {header, connexions, locked_files, finished, nfs} readingpart;
|
||||
int lo[65536];
|
||||
int nrpid;
|
||||
void processNFSLine(char *bufline, int linelen);
|
||||
void processSambaLine(char *bufline, int linelen);
|
||||
|
||||
QByteArray strShare, strUser, strGroup, strMachine, strSince, strPid;
|
||||
int iUser, iGroup, iMachine, iPid;
|
||||
|
||||
private Q_SLOTS:
|
||||
void killShowmount();
|
||||
void update();
|
||||
void readFromProcess();
|
||||
void smbstatusError();
|
||||
};
|
||||
|
||||
#endif // main_included
|
|
@ -1,107 +0,0 @@
|
|||
/*
|
||||
* main.cpp for the samba kcontrol module
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <QLayout>
|
||||
#include <QTabWidget>
|
||||
|
||||
#include <kaboutdata.h>
|
||||
#include <kcmodule.h>
|
||||
#include <kdialog.h>
|
||||
|
||||
#include "kcmsambaimports.h"
|
||||
#include "kcmsambalog.h"
|
||||
#include "kcmsambastatistics.h"
|
||||
#include "ksmbstatus.h"
|
||||
#include <KPluginFactory>
|
||||
|
||||
class SambaContainer : public KCModule {
|
||||
Q_OBJECT
|
||||
public:
|
||||
SambaContainer(QWidget *parent=0, const QVariantList &list = QVariantList());
|
||||
virtual ~SambaContainer();
|
||||
virtual void load();
|
||||
virtual void save();
|
||||
|
||||
private:
|
||||
KConfig config;
|
||||
QTabWidget tabs;
|
||||
NetMon status;
|
||||
ImportsView imports;
|
||||
LogView logView;
|
||||
StatisticsView statisticsView;
|
||||
};
|
||||
|
||||
K_PLUGIN_FACTORY(SambaFactory,
|
||||
registerPlugin<SambaContainer>();
|
||||
)
|
||||
K_EXPORT_PLUGIN(SambaFactory("kcmsamba"))
|
||||
|
||||
SambaContainer::SambaContainer(QWidget *parent, const QVariantList&) :
|
||||
KCModule(SambaFactory::componentData(), parent), config("kcmsambarc"), tabs(this), status(&tabs), imports(&tabs), logView(&tabs, &config), statisticsView(&tabs) {
|
||||
QVBoxLayout *layout = new QVBoxLayout( this );
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(&tabs);
|
||||
tabs.addTab(&status, i18n("&Exports"));
|
||||
tabs.addTab(&imports, i18n("&Imports"));
|
||||
tabs.addTab(&logView, i18n("&Log"));
|
||||
tabs.addTab(&statisticsView, i18n("&Statistics"));
|
||||
connect(&logView, SIGNAL(contentsChanged(QTreeWidget*,int,int)), &statisticsView, SLOT(setListInfo(QTreeWidget*,int,int)));
|
||||
setButtons(Help);
|
||||
|
||||
setQuickHelp(i18n("<p>The Samba and NFS Status Monitor is a front end to the programs"
|
||||
" <em>smbstatus</em> and <em>showmount</em>. Smbstatus reports on current"
|
||||
" Samba connections, and is part of the suite of Samba tools, which"
|
||||
" implements the SMB (Session Message Block) protocol, also called the"
|
||||
" NetBIOS or LanManager protocol. This protocol can be used to provide"
|
||||
" printer sharing or drive sharing services on a network including"
|
||||
" machines running the various flavors of Microsoft Windows.</p>"));
|
||||
|
||||
KAboutData *about = new KAboutData(I18N_NOOP("kcmsamba"), 0,
|
||||
ki18n("System Information Control Module"),
|
||||
0, KLocalizedString(), KAboutData::License_GPL,
|
||||
ki18n("(c) 2002 KDE Information Control Module Samba Team"));
|
||||
about->addAuthor(ki18n("Michael Glauche"), KLocalizedString(), "glauche@isa.rwth-aachen.de");
|
||||
about->addAuthor(ki18n("Matthias Hoelzer"), KLocalizedString(), "hoelzer@kde.org");
|
||||
about->addAuthor(ki18n("David Faure"), KLocalizedString(), "faure@kde.org");
|
||||
about->addAuthor(ki18n("Harald Koschinski"), KLocalizedString(), "Harald.Koschinski@arcormail.de");
|
||||
about->addAuthor(ki18n("Wilco Greven"), KLocalizedString(), "greven@kde.org");
|
||||
about->addAuthor(ki18n("Alexander Neundorf"), KLocalizedString(), "neundorf@kde.org");
|
||||
setAboutData(about);
|
||||
}
|
||||
|
||||
SambaContainer::~SambaContainer() {
|
||||
save();
|
||||
}
|
||||
|
||||
void SambaContainer::load() {
|
||||
status.loadSettings();
|
||||
imports.loadSettings();
|
||||
logView.loadSettings();
|
||||
statisticsView.loadSettings();
|
||||
}
|
||||
|
||||
void SambaContainer::save() {
|
||||
status.saveSettings();
|
||||
imports.saveSettings();
|
||||
logView.saveSettings();
|
||||
statisticsView.saveSettings();
|
||||
config.sync();
|
||||
}
|
||||
|
||||
#include "main.moc"
|
|
@ -1,241 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Exec=kcmshell4 smbstatus
|
||||
Icon=preferences-system-network-share-windows-status
|
||||
Type=Service
|
||||
X-KDE-ServiceTypes=KCModule
|
||||
|
||||
X-KDE-KInfoCenter-Category=network_information
|
||||
X-KDE-Library=kcm_samba
|
||||
X-KDE-ParentApp=kinfocenter
|
||||
X-DocPath=kinfocenter/index.html#smbstatus
|
||||
|
||||
Name=Samba Status
|
||||
Name[af]=Samba Status
|
||||
Name[ar]=حالة السامبا
|
||||
Name[as]=Samba ৰ অৱস্থা
|
||||
Name[ast]=Estáu de Samba
|
||||
Name[be]=Стан Samba
|
||||
Name[be@latin]=Stanovišča słužby „Samba”
|
||||
Name[bg]=Сървър Samba
|
||||
Name[bn]=সাম্বা স্ট্যাটাস
|
||||
Name[bn_IN]=Samba-র অবস্থা
|
||||
Name[br]=Saviad Samba
|
||||
Name[bs]=Stanje Sambe
|
||||
Name[ca]=Estat de Samba
|
||||
Name[ca@valencia]=Estat de Samba
|
||||
Name[cs]=Stav Samby
|
||||
Name[csb]=Sztaus Samba
|
||||
Name[cy]=Cyflwr Samba
|
||||
Name[da]=Samba-status
|
||||
Name[de]=Samba-Status
|
||||
Name[el]=Κατάσταση samba
|
||||
Name[en_GB]=Samba Status
|
||||
Name[eo]=Samba stato
|
||||
Name[es]=Estado de Samba
|
||||
Name[et]=Samba olek
|
||||
Name[eu]=Samba-ren egoera
|
||||
Name[fa]=وضعیت Samba
|
||||
Name[fi]=Samban tila
|
||||
Name[fr]=État de Samba
|
||||
Name[fy]=Samba-tastân
|
||||
Name[ga]=Stádas Samba
|
||||
Name[gl]=Estado de Samba
|
||||
Name[gu]=સામ્બા સ્થિતિ
|
||||
Name[he]=מצב Samba
|
||||
Name[hi]=साम्बा स्थिति
|
||||
Name[hne]=साम्बा स्थिति
|
||||
Name[hr]=Stanje Sambe
|
||||
Name[hsb]=Samba status
|
||||
Name[hu]=Samba
|
||||
Name[ia]=Stato de Samba
|
||||
Name[id]=Status Samba
|
||||
Name[is]=Staða Samba
|
||||
Name[it]=Stato di Samba
|
||||
Name[ja]=Samba の状態
|
||||
Name[ka]=Samba-ს სტატუსი
|
||||
Name[kk]=Samba сервері
|
||||
Name[km]=ស្ថានភាព Samba
|
||||
Name[kn]=ಸಾಂಬಾ ಸ್ಥಿತಿಗತಿ
|
||||
Name[ko]=삼바 상태
|
||||
Name[ku]=Rewşa Sambayê
|
||||
Name[lt]=Samba būsena
|
||||
Name[lv]=Samba statuss
|
||||
Name[mai]=साम्बा स्थिति
|
||||
Name[mk]=Статус на Samba
|
||||
Name[ml]=സാംബാ സ്ഥിതിവിവരം
|
||||
Name[mr]=साम्बा स्थिति
|
||||
Name[ms]=Status Samba
|
||||
Name[nb]=Samba-status
|
||||
Name[nds]=Samba-Status
|
||||
Name[ne]=साम्बा वस्तुस्थिति
|
||||
Name[nl]=Samba-status
|
||||
Name[nn]=Samba-status
|
||||
Name[or]=ସାମ୍ବା ସ୍ଥିତି
|
||||
Name[pa]=ਸਾਂਬਾ ਹਾਲਤ
|
||||
Name[pl]=Stan Samby
|
||||
Name[pt]=Estado do Samba
|
||||
Name[pt_BR]=Estado do Samba
|
||||
Name[ro]=Stare Samba
|
||||
Name[ru]=Сервер Samba
|
||||
Name[se]=Samba stáhtus
|
||||
Name[si]=සම්බා තත්ත්වය
|
||||
Name[sk]=Stav Samby
|
||||
Name[sl]=Stanje Sambe
|
||||
Name[sr]=Стање Самбе
|
||||
Name[sr@ijekavian]=Стање Самбе
|
||||
Name[sr@ijekavianlatin]=Stanje Sambe
|
||||
Name[sr@latin]=Stanje Sambe
|
||||
Name[sv]=Samba-status
|
||||
Name[ta]=சம்பா நிலை
|
||||
Name[te]=సాంబా స్థితి
|
||||
Name[tg]=Ҳолати Samba
|
||||
Name[th]=สถานะของ Samba
|
||||
Name[tr]=Samba Servisi
|
||||
Name[ug]=Samba ھالىتى
|
||||
Name[uk]=Стан Samba
|
||||
Name[uz]=Samba'ning holati
|
||||
Name[uz@cyrillic]=Samba'нинг ҳолати
|
||||
Name[vi]=Trạng thái Samba
|
||||
Name[wa]=Estat di Samba
|
||||
Name[xh]=Isimo se Samba
|
||||
Name[x-test]=xxSamba Statusxx
|
||||
Name[zh_CN]=Samba 状态
|
||||
Name[zh_TW]=Samba 狀態
|
||||
|
||||
Comment=Samba status monitor
|
||||
Comment[af]=Samba status monitor
|
||||
Comment[ar]=مراقب حالة السامبا
|
||||
Comment[as]=Samba ৰ অৱস্থাৰ নিৰীক্ষণ
|
||||
Comment[ast]=Monitor d'estáu de Samba
|
||||
Comment[be]=Назіральнік стану Samba
|
||||
Comment[be@latin]=Nazirańnik za stanoviščam słužby „Samba”
|
||||
Comment[bg]=Данни за състоянието на сървъра Samba
|
||||
Comment[bn]=সাম্বা স্ট্যাটাস নির্দেশক
|
||||
Comment[bn_IN]=Samba অবস্থা নিরীক্ষণ
|
||||
Comment[br]=Diskwel saviad Samba
|
||||
Comment[bs]=Nadgledanje stanja Sambe
|
||||
Comment[ca]=Monitor de l'estat de Samba
|
||||
Comment[ca@valencia]=Monitor de l'estat de Samba
|
||||
Comment[cs]=Monitor stavu Samby
|
||||
Comment[csb]=Mònitor stónu Sambë
|
||||
Comment[cy]=Monitr cyflwr samba
|
||||
Comment[da]=Overvågning af samba-status
|
||||
Comment[de]=Samba-Statusmonitor
|
||||
Comment[el]=Εποπτεία της Samba
|
||||
Comment[en_GB]=Samba status monitor
|
||||
Comment[eo]=Rigardilo por la stato de Samba
|
||||
Comment[es]=Monitor de estado de Samba
|
||||
Comment[et]=Samba oleku jälgimine
|
||||
Comment[eu]=Samba-ren egoeraren monitorea
|
||||
Comment[fa]=نمایشگر وضعیت Samba
|
||||
Comment[fi]=Samban tilan näyttö
|
||||
Comment[fr]=Indicateur d'état de Samba
|
||||
Comment[fy]=Sambatastânmonitor
|
||||
Comment[ga]=Monatóir stádais Samba
|
||||
Comment[gl]=Vixilante do estado de Samba
|
||||
Comment[gu]=સામ્બા સ્થિતિ દેખરેખ
|
||||
Comment[he]=מידע על המצב של Samba
|
||||
Comment[hi]=साम्बा स्थिति मॉनीटर
|
||||
Comment[hne]=साम्बा स्थिति मानीटर
|
||||
Comment[hr]=Nadzor stanje Sambe
|
||||
Comment[hsb]=Samba statusowy monitor
|
||||
Comment[hu]=Samba állapotmonitor
|
||||
Comment[ia]=Monitor de stato de Samba
|
||||
Comment[id]=Monitor status Samba
|
||||
Comment[is]=Eftirlit með stöðu Samba
|
||||
Comment[it]=Monitor dello stato di Samba
|
||||
Comment[ja]=Samba の状態を監視します
|
||||
Comment[ka]=Samba-ს სტატუსის მონიტორი
|
||||
Comment[kk]=Samba күйін бақылау
|
||||
Comment[km]=កម្មវិធីត្រួតពិនិត្យស្ថានភាព Samba
|
||||
Comment[kn]=ಸಾಂಬಾ ಸ್ಥಿತಿಗತಿ ಮೇಲ್ವಿಚಾರಕ
|
||||
Comment[ko]=삼바 상태 모니터
|
||||
Comment[ku]=Temaşekarê Rewşa Sambayê
|
||||
Comment[lt]=Samba būsenos monitorius
|
||||
Comment[lv]=Sambas statusa monitors
|
||||
Comment[mai]=साम्बा स्थिति मानीटर
|
||||
Comment[mk]=Монитор на статусот на Samba
|
||||
Comment[ml]=സാംബാ അവസ്ഥ നിരീക്ഷിണി
|
||||
Comment[mr]=साम्बा स्थिति मॉनीटर
|
||||
Comment[ms]=Monitor status Samba
|
||||
Comment[nb]=Overvåking av Samba-status
|
||||
Comment[nds]=Statuskieker för Samba
|
||||
Comment[ne]=साम्बा वस्तुस्थिति मोनिटर
|
||||
Comment[nl]=Sambastatusmonitor
|
||||
Comment[nn]=Overvaking av Samba-status
|
||||
Comment[or]=ସାମ୍ବା ସ୍ଥିତି ପ୍ରଦର୍ଶିକା
|
||||
Comment[pa]=ਸਾਂਬਾ ਹਾਲਤ ਨਿਗਰਾਨ
|
||||
Comment[pl]=Monitor stanu Samby
|
||||
Comment[pt]=Monitor do estado do Samba
|
||||
Comment[pt_BR]=Monitor de estado do Samba
|
||||
Comment[ro]=Monitorizează starea serverului Samba
|
||||
Comment[ru]=Состояние сервера Samba
|
||||
Comment[se]=Gozit Samba stáhtusa
|
||||
Comment[si]=සම්බා තත්ත්ව නිරික්ෂකය
|
||||
Comment[sk]=Monitor stavu Samby
|
||||
Comment[sl]=Nadzornik stanja Sambe
|
||||
Comment[sr]=Надгледање стања Самбе
|
||||
Comment[sr@ijekavian]=Надгледање стања Самбе
|
||||
Comment[sr@ijekavianlatin]=Nadgledanje stanja Sambe
|
||||
Comment[sr@latin]=Nadgledanje stanja Sambe
|
||||
Comment[sv]=Övervakar Samba-status
|
||||
Comment[ta]=சம்பா நிலை காட்டி
|
||||
Comment[te]=సాంబా స్థితి మానిటర్
|
||||
Comment[tg]=Барномаи ҳолатҳои Samba
|
||||
Comment[th]=เฝ้าดูสถานะ Samba
|
||||
Comment[tr]=Samba durum izleyici
|
||||
Comment[ug]=Samba ھالەت كۆزەتكۈچىسى
|
||||
Comment[uk]=Монітор стану Samba
|
||||
Comment[uz]=Samba'ning holatini nazorat qiluvchi vosita
|
||||
Comment[uz@cyrillic]=Samba'нинг ҳолатини назорат қилувчи восита
|
||||
Comment[vi]=Theo dõi trạng thái Samba
|
||||
Comment[wa]=Corwaitoe di l' estat di Samba
|
||||
Comment[xh]=Umphathi wemeko we Samba
|
||||
Comment[x-test]=xxSamba status monitorxx
|
||||
Comment[zh_CN]=Samba 状态监视器
|
||||
Comment[zh_TW]=Samba 狀態監視器
|
||||
|
||||
X-KDE-Keywords=SMB,SAMBA,Windows network,LAN,System Information
|
||||
X-KDE-Keywords[bs]=SMB,SAMBA,Windows umrežavanje,LAN,Sistemske informacije
|
||||
X-KDE-Keywords[ca]=SMB,SAMBA,Xarxa Windows,LAN,Informació del sistema
|
||||
X-KDE-Keywords[ca@valencia]=SMB,SAMBA,Xarxa Windows,LAN,Informació del sistema
|
||||
X-KDE-Keywords[da]=SMB,SAMBA,Windows netværk,LAN,Systeminformation
|
||||
X-KDE-Keywords[de]=SMB,Samba,Windows-Netzwerk,LAN,Systeminformationen
|
||||
X-KDE-Keywords[el]=SMB,SAMBA,δίκτυο Windows,LAN,πληροφορίες συστήματος
|
||||
X-KDE-Keywords[en_GB]=SMB,SAMBA,Windows network,LAN,System Information
|
||||
X-KDE-Keywords[es]=SMB,SAMBA,Red Windows,LAN,Información del sistema
|
||||
X-KDE-Keywords[et]=SMB,SAMBA,Windowsi võrk,LAN,süsteemi teave
|
||||
X-KDE-Keywords[eu]=SMB,SAMBA,Windows sarea,LAN,sistema-informazioa
|
||||
X-KDE-Keywords[fi]=SMB,SAMBA,Windows-verkko,LAN,järjestelmätiedot
|
||||
X-KDE-Keywords[fr]=SMB, SAMBA, réseau Windows, LAN, Informations système
|
||||
X-KDE-Keywords[ga]=SMB,SAMBA,Líonra Windows,LAN,líonra logánta,Eolas faoin Chóras
|
||||
X-KDE-Keywords[gl]=SMB,SAMBA,Rede de Windows,LAN,Información do sistema
|
||||
X-KDE-Keywords[hu]=SMB,SAMBA,Windows hálózat,LAN,Rendszerinformáció
|
||||
X-KDE-Keywords[ia]=SMB,SAMBA,rete de Windows,LAN,Information de systema
|
||||
X-KDE-Keywords[it]=SMB,SAMBA,rete di Windows,LAN,Informazioni di sistema
|
||||
X-KDE-Keywords[kk]=SMB,SAMBA,Windows network,LAN,System Information
|
||||
X-KDE-Keywords[km]=SMB,SAMBA,Windows network,LAN,System Information
|
||||
X-KDE-Keywords[ko]=SMB,SAMBA,Windows network,LAN,System Information,윈도우,윈도,윈도우 네트워크,윈도 네트워크,시스템 정보
|
||||
X-KDE-Keywords[mr]=SMB, SAMBA, विंडोज नेटवर्क, LAN, प्रणाली माहीती
|
||||
X-KDE-Keywords[nb]=SMB,SAMBA,Windows-nettverk,LAN,Systeminformasjon
|
||||
X-KDE-Keywords[nds]=SMB,SAMBA,Windows-Nettwark,LAN,Systeem-Informatschonen
|
||||
X-KDE-Keywords[nl]=SMB,SAMBA,Windows-netwerk,LAN,systeeminformatie
|
||||
X-KDE-Keywords[pa]=SMB,SAMBA,ਵਿੰਡੋਜ਼ ਨੈੱਟਵਰਕ,LAN,ਸਿਸਟਮ ਜਾਣਕਾਰੀ
|
||||
X-KDE-Keywords[pl]=SMB,SAMBA,Sieć Windows,LAN,Informacje o systemie
|
||||
X-KDE-Keywords[pt]=SMB,SAMBA,rede Windows,LAN,Informação do Sistema
|
||||
X-KDE-Keywords[pt_BR]=SMB,SAMBA,Rede Windows,LAN,Informação do sistema
|
||||
X-KDE-Keywords[ro]=SMB,SAMBA,rețea Windows,LAN,informații sistem,rețea locală
|
||||
X-KDE-Keywords[ru]=SMB,SAMBA,Windows network,LAN,System Information,сеть Windows,локальная сеть,локальная вычислительная сеть,ЛВС
|
||||
X-KDE-Keywords[sk]=SMB,SAMBA,Sieť Windows,LAN,Systémové informácie
|
||||
X-KDE-Keywords[sl]=smb,samba,omrežje Windows,lan,krajevno omrežje,sistemski podatki,podatki o sistemu
|
||||
X-KDE-Keywords[sr]=SMB,SAMBA,Windows network,LAN,System Information,СМБ,Самба,виндоуз мрежа,ЛАН,системске информације
|
||||
X-KDE-Keywords[sr@ijekavian]=SMB,SAMBA,Windows network,LAN,System Information,СМБ,Самба,виндоуз мрежа,ЛАН,системске информације
|
||||
X-KDE-Keywords[sr@ijekavianlatin]=SMB,SAMBA,Windows network,LAN,System Information,SMB,Samba,windows mreža,LAN,sistemske informacije
|
||||
X-KDE-Keywords[sr@latin]=SMB,SAMBA,Windows network,LAN,System Information,SMB,Samba,windows mreža,LAN,sistemske informacije
|
||||
X-KDE-Keywords[sv]=SMB,SAMBA,Windows-nätverk,LAN,Systeminformation
|
||||
X-KDE-Keywords[tr]=SMB,SAMBA,Windows ağı,LAN,Yerel Ağ,Sistem Bilgileri
|
||||
X-KDE-Keywords[uk]=SMB,SAMBA,Windows network,LAN,System Information,мережа,віндоус,віндоуз,віндовс,віндовз,система,інформація,відомості
|
||||
X-KDE-Keywords[x-test]=xxSMB,SAMBA,Windows network,LAN,System Informationxx
|
||||
X-KDE-Keywords[zh_CN]=SMB,SAMBA,Windows network,LAN,System Information,Windows 网络,网上邻居,局域网,系统信息
|
||||
X-KDE-Keywords[zh_TW]=SMB,SAMBA,Windows network,LAN,System Information
|
||||
Categories=Qt;KDE;X-KDE-information;
|
|
@ -18,12 +18,3 @@ if(GPHOTO2_FOUND)
|
|||
endif()
|
||||
|
||||
add_subdirectory( floppy )
|
||||
check_include_files(rpc/rpc.h HAVE_RPC_RPC_H)
|
||||
add_feature_info("NFS kioslave" HAVE_RPC_RPC_H "The RPC library is needed to build the NFS kioslave")
|
||||
if(HAVE_RPC_RPC_H)
|
||||
add_subdirectory(nfs)
|
||||
endif()
|
||||
|
||||
if(SAMBA_FOUND)
|
||||
add_subdirectory(smb)
|
||||
endif()
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
Written and maintained by:
|
||||
Alexander Neundorf, neundorf@kde.org
|
|
@ -1,42 +0,0 @@
|
|||
## Check for XDR types
|
||||
include(CheckTypeSize)
|
||||
|
||||
cmake_reset_check_state()
|
||||
set(CMAKE_EXTRA_INCLUDE_FILES "rpc/rpc.h")
|
||||
check_type_size(xdr_u_int64_t HAVE_XDR_U_INT64_T)
|
||||
check_type_size(xdr_uint64_t HAVE_XDR_UINT64_T)
|
||||
check_type_size(xdr_u_hyper HAVE_XDR_U_HYPER)
|
||||
check_type_size(xdr_u_longlong_t HAVE_XDR_U_LONGLONG_T)
|
||||
cmake_reset_check_state()
|
||||
|
||||
if (NOT HAVE_XDR_U_INT64_T AND NOT HAVE_XDR_UINT64_T AND NOT HAVE_XDR_U_HYPER AND NOT HAVE_XDR_U_LONGLONG_T)
|
||||
message(FATAL_ERROR "Could not find 64-bit XDR data types!")
|
||||
endif (NOT HAVE_XDR_U_INT64_T AND NOT HAVE_XDR_UINT64_T AND NOT HAVE_XDR_U_HYPER AND NOT HAVE_XDR_U_LONGLONG_T)
|
||||
|
||||
if (HAVE_XDR_U_INT64_T)
|
||||
add_definitions(-DHAVE_XDR_U_INT64_T)
|
||||
endif (HAVE_XDR_U_INT64_T)
|
||||
if (HAVE_XDR_UINT64_T)
|
||||
add_definitions(-DHAVE_XDR_UINT64_T)
|
||||
endif (HAVE_XDR_UINT64_T)
|
||||
if (HAVE_XDR_U_HYPER)
|
||||
add_definitions(-DHAVE_XDR_U_HYPER)
|
||||
endif (HAVE_XDR_U_HYPER)
|
||||
if (HAVE_XDR_U_LONGLONG_T)
|
||||
add_definitions(-DHAVE_XDR_U_LONGLONG_T)
|
||||
endif (HAVE_XDR_U_LONGLONG_T)
|
||||
|
||||
set(kio_nfs_PART_SRCS kio_nfs.cpp nfsv2.cpp nfsv3.cpp rpc_nfs3_prot_xdr.c rpc_nfs2_prot_xdr.c )
|
||||
|
||||
|
||||
kde4_add_plugin(kio_nfs ${kio_nfs_PART_SRCS})
|
||||
|
||||
|
||||
target_link_libraries(kio_nfs ${KDE4_KIO_LIBS})
|
||||
|
||||
install(TARGETS kio_nfs DESTINATION ${KDE4_PLUGIN_INSTALL_DIR} )
|
||||
|
||||
|
||||
########### install files ###############
|
||||
|
||||
install( FILES nfs.protocol DESTINATION ${KDE4_SERVICES_INSTALL_DIR} )
|
|
@ -1,2 +0,0 @@
|
|||
#!/bin/bash
|
||||
$XGETTEXT *.cpp -o $podir/kio_nfs.pot
|
|
@ -1,3 +0,0 @@
|
|||
This contains a kio slave for NFS version 2 and 3.
|
||||
|
||||
Mathias
|
|
@ -1,5 +0,0 @@
|
|||
-maybe use rpcgen ?
|
||||
-cache handling: how long should file handles be cached ?
|
||||
should the stat'ed structures be cached ? no, IMHO
|
||||
|
||||
Alex
|
|
@ -1,739 +0,0 @@
|
|||
/* This file is part of the KDE project
|
||||
|
||||
Copyright(C) 2000 Alexander Neundorf <neundorf@kde.org>,
|
||||
2014 Mathias Tillman <master.homer@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "kio_nfs.h"
|
||||
|
||||
#include <config-workspace.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
#include <QtNetwork/QHostInfo>
|
||||
|
||||
#include <KDebug>
|
||||
#include <KLocalizedString>
|
||||
#include <kio/global.h>
|
||||
|
||||
#include "nfsv2.h"
|
||||
#include "nfsv3.h"
|
||||
|
||||
using namespace KIO;
|
||||
using namespace std;
|
||||
|
||||
extern "C" int Q_DECL_EXPORT kdemain(int argc, char** argv);
|
||||
|
||||
int kdemain(int argc, char** argv)
|
||||
{
|
||||
if (argc != 4) {
|
||||
fprintf(stderr, "Usage: kio_nfs protocol domain-socket1 domain-socket2\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
kDebug(7121) << "NFS: kdemain: starting";
|
||||
|
||||
NFSSlave slave(argv[2], argv[3]);
|
||||
slave.dispatchLoop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
NFSSlave::NFSSlave(const QByteArray& pool, const QByteArray& app)
|
||||
: KIO::SlaveBase("nfs", pool, app),
|
||||
m_protocol(NULL)
|
||||
{
|
||||
|
||||
kDebug(7121) << pool << app;
|
||||
}
|
||||
NFSSlave::~NFSSlave()
|
||||
{
|
||||
if (m_protocol != NULL) {
|
||||
delete m_protocol;
|
||||
}
|
||||
}
|
||||
|
||||
void NFSSlave::openConnection()
|
||||
{
|
||||
kDebug(7121) << "openConnection";
|
||||
|
||||
if (m_protocol != NULL) {
|
||||
m_protocol->openConnection();
|
||||
} else {
|
||||
bool connectionError = false;
|
||||
|
||||
int version = 4;
|
||||
while (version > 1) {
|
||||
kDebug(7121) << "Trying NFS version" << version;
|
||||
|
||||
// We need to create a new NFS protocol handler
|
||||
switch (version) {
|
||||
case 4: {
|
||||
// TODO
|
||||
kDebug(7121) << "NFSv4 is not supported at this time";
|
||||
}
|
||||
break;
|
||||
case 3: {
|
||||
m_protocol = new NFSProtocolV3(this);
|
||||
}
|
||||
break;
|
||||
case 2: {
|
||||
m_protocol = new NFSProtocolV2(this);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Unimplemented protocol version
|
||||
if (m_protocol == NULL) {
|
||||
version--;
|
||||
continue;
|
||||
}
|
||||
|
||||
m_protocol->setHost(m_host);
|
||||
if (m_protocol->isCompatible(connectionError)) {
|
||||
break;
|
||||
}
|
||||
|
||||
version--;
|
||||
delete m_protocol;
|
||||
m_protocol = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (m_protocol == NULL) {
|
||||
// If we could not find a compatible protocol, send an error.
|
||||
if (!connectionError) {
|
||||
error(KIO::ERR_COULD_NOT_CONNECT, i18n("%1: Unsupported NFS version", m_host));
|
||||
} else {
|
||||
error(KIO::ERR_COULD_NOT_CONNECT, m_host);
|
||||
}
|
||||
} else {
|
||||
// Otherwise we open the connection
|
||||
m_protocol->openConnection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NFSSlave::closeConnection()
|
||||
{
|
||||
kDebug(7121);
|
||||
|
||||
if (m_protocol != NULL) {
|
||||
m_protocol->closeConnection();
|
||||
}
|
||||
}
|
||||
|
||||
void NFSSlave::setHost(const QString& host, quint16 /*port*/, const QString& /*user*/, const QString& /*pass*/)
|
||||
{
|
||||
kDebug(7121);
|
||||
|
||||
if (m_protocol != NULL) {
|
||||
// New host? New protocol!
|
||||
if (m_host != host) {
|
||||
kDebug(7121) << "Deleting old protocol";
|
||||
delete m_protocol;
|
||||
m_protocol = NULL;
|
||||
} else {
|
||||
m_protocol->setHost(host);
|
||||
}
|
||||
}
|
||||
|
||||
m_host = host;
|
||||
}
|
||||
|
||||
void NFSSlave::put(const KUrl& url, int _mode, KIO::JobFlags _flags)
|
||||
{
|
||||
kDebug(7121);
|
||||
|
||||
if (verifyProtocol()) {
|
||||
m_protocol->put(url, _mode, _flags);
|
||||
}
|
||||
}
|
||||
|
||||
void NFSSlave::get(const KUrl& url)
|
||||
{
|
||||
kDebug(7121);
|
||||
|
||||
if (verifyProtocol()) {
|
||||
m_protocol->get(url);
|
||||
}
|
||||
}
|
||||
|
||||
void NFSSlave::listDir(const KUrl& url)
|
||||
{
|
||||
kDebug(7121) << url;
|
||||
|
||||
if (verifyProtocol()) {
|
||||
m_protocol->listDir(url);
|
||||
}
|
||||
}
|
||||
|
||||
void NFSSlave::symlink(const QString& target, const KUrl& dest, KIO::JobFlags _flags)
|
||||
{
|
||||
kDebug(7121);
|
||||
|
||||
if (verifyProtocol()) {
|
||||
m_protocol->symlink(target, dest, _flags);
|
||||
}
|
||||
}
|
||||
|
||||
void NFSSlave::stat(const KUrl& url)
|
||||
{
|
||||
kDebug(7121);
|
||||
|
||||
if (verifyProtocol()) {
|
||||
m_protocol->stat(url);
|
||||
}
|
||||
}
|
||||
|
||||
void NFSSlave::mkdir(const KUrl& url, int permissions)
|
||||
{
|
||||
kDebug(7121);
|
||||
|
||||
if (verifyProtocol()) {
|
||||
m_protocol->mkdir(url, permissions);
|
||||
}
|
||||
}
|
||||
|
||||
void NFSSlave::del(const KUrl& url, bool isfile)
|
||||
{
|
||||
kDebug(7121);
|
||||
|
||||
if (verifyProtocol()) {
|
||||
m_protocol->del(url, isfile);
|
||||
}
|
||||
}
|
||||
|
||||
void NFSSlave::chmod(const KUrl& url, int permissions)
|
||||
{
|
||||
kDebug(7121);
|
||||
|
||||
if (verifyProtocol()) {
|
||||
m_protocol->chmod(url, permissions);
|
||||
}
|
||||
}
|
||||
|
||||
void NFSSlave::rename(const KUrl& src, const KUrl& dest, KIO::JobFlags flags)
|
||||
{
|
||||
kDebug(7121);
|
||||
|
||||
if (verifyProtocol()) {
|
||||
m_protocol->rename(src, dest, flags);
|
||||
}
|
||||
}
|
||||
|
||||
void NFSSlave::copy(const KUrl& src, const KUrl& dest, int mode, KIO::JobFlags flags)
|
||||
{
|
||||
kDebug(7121);
|
||||
|
||||
if (verifyProtocol()) {
|
||||
m_protocol->copy(src, dest, mode, flags);
|
||||
}
|
||||
}
|
||||
|
||||
bool NFSSlave::verifyProtocol()
|
||||
{
|
||||
const bool haveProtocol = (m_protocol != NULL);
|
||||
if (!haveProtocol) {
|
||||
openConnection();
|
||||
|
||||
if (m_protocol == NULL) {
|
||||
// We have failed.... :(
|
||||
kDebug(7121) << "Could not find a compatible protocol version!!";
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we are not connected @openConnection will have sent an
|
||||
// error message to the client, so it's safe to return here.
|
||||
if (!m_protocol->isConnected()) {
|
||||
return false;
|
||||
}
|
||||
} else if (!m_protocol->isConnected()) {
|
||||
m_protocol->openConnection();
|
||||
if (!m_protocol->isConnected()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_protocol->isConnected()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
finished();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
NFSFileHandle::NFSFileHandle()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
NFSFileHandle::NFSFileHandle(const NFSFileHandle& src)
|
||||
{
|
||||
init();
|
||||
(*this) = src;
|
||||
}
|
||||
|
||||
NFSFileHandle::NFSFileHandle(const fhandle3& src)
|
||||
{
|
||||
init();
|
||||
(*this) = src;
|
||||
}
|
||||
|
||||
NFSFileHandle::NFSFileHandle(const fhandle& src)
|
||||
{
|
||||
init();
|
||||
(*this) = src;
|
||||
}
|
||||
|
||||
NFSFileHandle::NFSFileHandle(const nfs_fh3& src)
|
||||
{
|
||||
init();
|
||||
(*this) = src;
|
||||
}
|
||||
|
||||
NFSFileHandle::NFSFileHandle(const nfs_fh& src)
|
||||
{
|
||||
init();
|
||||
(*this) = src;
|
||||
}
|
||||
|
||||
NFSFileHandle::~NFSFileHandle()
|
||||
{
|
||||
if (m_handle != NULL) {
|
||||
delete [] m_handle;
|
||||
}
|
||||
if (m_linkHandle != NULL) {
|
||||
delete [] m_linkHandle;
|
||||
}
|
||||
}
|
||||
|
||||
void NFSFileHandle::init()
|
||||
{
|
||||
m_handle = NULL;
|
||||
m_size = 0;
|
||||
m_linkHandle = NULL;
|
||||
m_linkSize = 0;
|
||||
m_isInvalid = true;
|
||||
m_isLink = false;
|
||||
}
|
||||
|
||||
void NFSFileHandle::toFH(nfs_fh3& fh) const
|
||||
{
|
||||
fh.data.data_len = m_size;
|
||||
fh.data.data_val = m_handle;
|
||||
}
|
||||
|
||||
void NFSFileHandle::toFH(nfs_fh& fh) const
|
||||
{
|
||||
memcpy(fh.data, m_handle, m_size);
|
||||
}
|
||||
|
||||
void NFSFileHandle::toFHLink(nfs_fh3& fh) const
|
||||
{
|
||||
fh.data.data_len = m_linkSize;
|
||||
fh.data.data_val = m_linkHandle;
|
||||
}
|
||||
|
||||
void NFSFileHandle::toFHLink(nfs_fh& fh) const
|
||||
{
|
||||
memcpy(fh.data, m_linkHandle, m_size);
|
||||
}
|
||||
|
||||
NFSFileHandle& NFSFileHandle::operator=(const NFSFileHandle& src)
|
||||
{
|
||||
if (src.m_size > 0) {
|
||||
if (m_handle != NULL) {
|
||||
delete [] m_handle;
|
||||
m_handle = NULL;
|
||||
}
|
||||
|
||||
m_size = src.m_size;
|
||||
m_handle = new char[m_size];
|
||||
memcpy(m_handle, src.m_handle, m_size);
|
||||
}
|
||||
if (src.m_linkSize > 0) {
|
||||
if (m_linkHandle != NULL) {
|
||||
delete [] m_linkHandle;
|
||||
m_linkHandle = NULL;
|
||||
}
|
||||
|
||||
m_linkSize = src.m_linkSize;
|
||||
m_linkHandle = new char[m_linkSize];
|
||||
memcpy(m_linkHandle, src.m_linkHandle, m_linkSize);
|
||||
}
|
||||
|
||||
m_isInvalid = src.m_isInvalid;
|
||||
m_isLink = src.m_isLink;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NFSFileHandle& NFSFileHandle::operator=(const fhandle3& src)
|
||||
{
|
||||
if (m_handle != NULL) {
|
||||
delete [] m_handle;
|
||||
m_handle = NULL;
|
||||
}
|
||||
|
||||
m_size = src.fhandle3_len;
|
||||
m_handle = new char[m_size];
|
||||
memcpy(m_handle, src.fhandle3_val, m_size);
|
||||
m_isInvalid = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NFSFileHandle& NFSFileHandle::operator=(const fhandle& src)
|
||||
{
|
||||
if (m_handle != NULL) {
|
||||
delete [] m_handle;
|
||||
m_handle = NULL;
|
||||
}
|
||||
|
||||
m_size = NFS_FHSIZE;
|
||||
m_handle = new char[m_size];
|
||||
memcpy(m_handle, src, m_size);
|
||||
m_isInvalid = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NFSFileHandle& NFSFileHandle::operator=(const nfs_fh3& src)
|
||||
{
|
||||
if (m_handle != NULL) {
|
||||
delete [] m_handle;
|
||||
m_handle = NULL;
|
||||
}
|
||||
|
||||
m_size = src.data.data_len;
|
||||
m_handle = new char[m_size];
|
||||
memcpy(m_handle, src.data.data_val, m_size);
|
||||
m_isInvalid = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
NFSFileHandle& NFSFileHandle::operator=(const nfs_fh& src)
|
||||
{
|
||||
if (m_handle != NULL) {
|
||||
delete [] m_handle;
|
||||
m_handle = NULL;
|
||||
}
|
||||
|
||||
m_size = NFS_FHSIZE;
|
||||
m_handle = new char[m_size];
|
||||
memcpy(m_handle, src.data, m_size);
|
||||
m_isInvalid = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void NFSFileHandle::setLinkSource(const nfs_fh3& src)
|
||||
{
|
||||
if (m_linkHandle != NULL) {
|
||||
delete [] m_linkHandle;
|
||||
m_linkHandle = NULL;
|
||||
}
|
||||
|
||||
m_linkSize = src.data.data_len;
|
||||
m_linkHandle = new char[m_linkSize];
|
||||
memcpy(m_linkHandle, src.data.data_val, m_linkSize);
|
||||
m_isLink = true;
|
||||
}
|
||||
|
||||
void NFSFileHandle::setLinkSource(const nfs_fh& src)
|
||||
{
|
||||
if (m_linkHandle != NULL) {
|
||||
delete [] m_linkHandle;
|
||||
m_linkHandle = NULL;
|
||||
}
|
||||
|
||||
m_linkSize = NFS_FHSIZE;
|
||||
m_linkHandle = new char[m_linkSize];
|
||||
memcpy(m_linkHandle, src.data, m_linkSize);
|
||||
m_isLink = true;
|
||||
}
|
||||
|
||||
|
||||
NFSProtocol::NFSProtocol(NFSSlave* slave)
|
||||
: m_slave(slave)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void NFSProtocol::copy(const KUrl& src, const KUrl& dest, int mode, KIO::JobFlags flags)
|
||||
{
|
||||
if (src.isLocalFile()) {
|
||||
copyTo(src, dest, mode, flags);
|
||||
} else if (dest.isLocalFile()) {
|
||||
copyFrom(src, dest, mode, flags);
|
||||
} else {
|
||||
copySame(src, dest, mode, flags);
|
||||
}
|
||||
}
|
||||
|
||||
void NFSProtocol::addExportedDir(const QString& path)
|
||||
{
|
||||
m_exportedDirs.append(path);
|
||||
}
|
||||
|
||||
const QStringList& NFSProtocol::getExportedDirs()
|
||||
{
|
||||
return m_exportedDirs;
|
||||
}
|
||||
|
||||
bool NFSProtocol::isExportedDir(const QString& path)
|
||||
{
|
||||
// If the path is the root filesystem we always return true.
|
||||
if (QFileInfo(path).isRoot()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (QStringList::const_iterator it = m_exportedDirs.constBegin(); it != m_exportedDirs.constEnd(); ++it) {
|
||||
if (path.length() < (*it).length() && (*it).startsWith(path)) {
|
||||
QString rest = (*it).mid(path.length());
|
||||
if (rest.isEmpty() || rest[0] == QDir::separator()) {
|
||||
kDebug(7121) << "isExportedDir" << path << "returning true";
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void NFSProtocol::removeExportedDir(const QString& path)
|
||||
{
|
||||
m_exportedDirs.removeOne(path);
|
||||
}
|
||||
|
||||
void NFSProtocol::addFileHandle(const QString& path, NFSFileHandle fh)
|
||||
{
|
||||
m_handleCache.insert(path, fh);
|
||||
}
|
||||
|
||||
NFSFileHandle NFSProtocol::getFileHandle(const QString& path)
|
||||
{
|
||||
if (!isConnected()) {
|
||||
return NFSFileHandle();
|
||||
}
|
||||
|
||||
if (!isValidPath(path)) {
|
||||
kDebug(7121) << path << "is not a valid path";
|
||||
return NFSFileHandle();
|
||||
}
|
||||
|
||||
// The handle may already be in the cache, check it now.
|
||||
// The exported dirs are always in the cache.
|
||||
if (m_handleCache.contains(path)) {
|
||||
return m_handleCache[path];
|
||||
}
|
||||
|
||||
// Loop detected, abort.
|
||||
if (QFileInfo(path).path() == path) {
|
||||
return NFSFileHandle();
|
||||
}
|
||||
|
||||
// Look up the file handle from the procotol
|
||||
NFSFileHandle childFH = lookupFileHandle(path);
|
||||
if (!childFH.isInvalid()) {
|
||||
m_handleCache.insert(path, childFH);
|
||||
}
|
||||
|
||||
return childFH;
|
||||
}
|
||||
|
||||
void NFSProtocol::removeFileHandle(const QString& path)
|
||||
{
|
||||
m_handleCache.remove(path);
|
||||
}
|
||||
|
||||
bool NFSProtocol::isValidPath(const QString& path)
|
||||
{
|
||||
if (path.isEmpty() || path == QDir::separator()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (QStringList::const_iterator it = m_exportedDirs.constBegin(); it != m_exportedDirs.constEnd(); ++it) {
|
||||
if ((path.length() == (*it).length() && path.startsWith((*it))) || (path.startsWith((*it) + QDir::separator()))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NFSProtocol::isValidLink(const QString& parentDir, const QString& linkDest)
|
||||
{
|
||||
if (linkDest.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (QFileInfo(linkDest).isAbsolute()) {
|
||||
return (!getFileHandle(linkDest).isInvalid());
|
||||
} else {
|
||||
QString absDest = QFileInfo(parentDir, linkDest).filePath();
|
||||
absDest = QDir::cleanPath(absDest);
|
||||
return (!getFileHandle(absDest).isInvalid());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int NFSProtocol::openConnection(const QString& host, int prog, int vers, CLIENT*& client, int& sock)
|
||||
{
|
||||
if (host.isEmpty()) {
|
||||
return KIO::ERR_UNKNOWN_HOST;
|
||||
}
|
||||
struct sockaddr_in server_addr;
|
||||
if (host[0] >= '0' && host[0] <= '9') {
|
||||
server_addr.sin_family = AF_INET;
|
||||
server_addr.sin_addr.s_addr = inet_addr(host.toLatin1());
|
||||
} else {
|
||||
struct hostent* hp = gethostbyname(host.toLatin1());
|
||||
if (hp == 0) {
|
||||
return KIO::ERR_UNKNOWN_HOST;
|
||||
}
|
||||
server_addr.sin_family = AF_INET;
|
||||
memcpy(&server_addr.sin_addr, hp->h_addr, hp->h_length);
|
||||
}
|
||||
|
||||
server_addr.sin_port = 0;
|
||||
|
||||
sock = RPC_ANYSOCK;
|
||||
client = clnttcp_create(&server_addr, prog, vers, &sock, 0, 0);
|
||||
if (client == 0) {
|
||||
server_addr.sin_port = 0;
|
||||
sock = RPC_ANYSOCK;
|
||||
|
||||
timeval pertry_timeout;
|
||||
pertry_timeout.tv_sec = 3;
|
||||
pertry_timeout.tv_usec = 0;
|
||||
client = clntudp_create(&server_addr, prog, vers, pertry_timeout, &sock);
|
||||
if (client == 0) {
|
||||
::close(sock);
|
||||
return KIO::ERR_COULD_NOT_CONNECT;
|
||||
}
|
||||
}
|
||||
|
||||
QString hostName = QHostInfo::localHostName();
|
||||
QString domainName = QHostInfo::localDomainName();
|
||||
if (!domainName.isEmpty()) {
|
||||
hostName = hostName + QLatin1Char('.') + domainName;
|
||||
}
|
||||
|
||||
client->cl_auth = authunix_create(hostName.toUtf8().data(), geteuid(), getegid(), 0, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool NFSProtocol::checkForError(int clientStat, int nfsStat, const QString& text)
|
||||
{
|
||||
if (clientStat != RPC_SUCCESS) {
|
||||
kDebug(7121) << "RPC error" << clientStat << text;
|
||||
|
||||
m_slave->error(KIO::ERR_INTERNAL_SERVER, i18n("RPC error %1", clientStat));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (nfsStat != NFS_OK) {
|
||||
kDebug(7121) << "NFS error:" << nfsStat << text;
|
||||
switch (nfsStat) {
|
||||
case NFSERR_PERM:
|
||||
m_slave->error(KIO::ERR_ACCESS_DENIED, text);
|
||||
break;
|
||||
case NFSERR_NOENT:
|
||||
m_slave->error(KIO::ERR_DOES_NOT_EXIST, text);
|
||||
break;
|
||||
//does this mapping make sense ?
|
||||
case NFSERR_IO:
|
||||
m_slave->error(KIO::ERR_INTERNAL_SERVER, text);
|
||||
break;
|
||||
//does this mapping make sense ?
|
||||
case NFSERR_NXIO:
|
||||
m_slave->error(KIO::ERR_DOES_NOT_EXIST, text);
|
||||
break;
|
||||
case NFSERR_ACCES:
|
||||
m_slave->error(KIO::ERR_ACCESS_DENIED, text);
|
||||
break;
|
||||
case NFSERR_EXIST:
|
||||
m_slave->error(KIO::ERR_FILE_ALREADY_EXIST, text);
|
||||
break;
|
||||
//does this mapping make sense ?
|
||||
case NFSERR_NODEV:
|
||||
m_slave->error(KIO::ERR_DOES_NOT_EXIST, text);
|
||||
break;
|
||||
case NFSERR_NOTDIR:
|
||||
m_slave->error(KIO::ERR_IS_FILE, text);
|
||||
break;
|
||||
case NFSERR_ISDIR:
|
||||
m_slave->error(KIO::ERR_IS_DIRECTORY, text);
|
||||
break;
|
||||
//does this mapping make sense ?
|
||||
case NFSERR_FBIG:
|
||||
m_slave->error(KIO::ERR_INTERNAL_SERVER, text);
|
||||
break;
|
||||
//does this mapping make sense ?
|
||||
case NFSERR_NOSPC:
|
||||
m_slave->error(KIO::ERR_INTERNAL_SERVER, i18n("No space left on device"));
|
||||
break;
|
||||
case NFSERR_ROFS:
|
||||
m_slave->error(KIO::ERR_COULD_NOT_WRITE, i18n("Read only file system"));
|
||||
break;
|
||||
case NFSERR_NAMETOOLONG:
|
||||
m_slave->error(KIO::ERR_INTERNAL_SERVER, i18n("Filename too long"));
|
||||
break;
|
||||
case NFSERR_NOTEMPTY:
|
||||
m_slave->error(KIO::ERR_COULD_NOT_RMDIR, text);
|
||||
break;
|
||||
//does this mapping make sense ?
|
||||
case NFSERR_DQUOT:
|
||||
m_slave->error(KIO::ERR_INTERNAL_SERVER, i18n("Disk quota exceeded"));
|
||||
break;
|
||||
case NFSERR_STALE:
|
||||
m_slave->error(KIO::ERR_DOES_NOT_EXIST, text);
|
||||
break;
|
||||
default:
|
||||
m_slave->error(KIO::ERR_UNKNOWN, i18n("NFS error %1 - %2", nfsStat, text));
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void NFSProtocol::createVirtualDirEntry(UDSEntry& entry)
|
||||
{
|
||||
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
|
||||
entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, "inode/directory");
|
||||
entry.insert(KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
|
||||
entry.insert(KIO::UDSEntry::UDS_USER, QString::fromLatin1("root"));
|
||||
entry.insert(KIO::UDSEntry::UDS_GROUP, QString::fromLatin1("root"));
|
||||
// Dummy size.
|
||||
entry.insert(KIO::UDSEntry::UDS_SIZE, 0);
|
||||
}
|
||||
|
||||
#include "moc_kio_nfs.cpp"
|
|
@ -1,208 +0,0 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2000 Alexander Neundorf <neundorf@kde.org>,
|
||||
2014 Mathias Tillman <master.homer@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef KIO_NFS_H
|
||||
#define KIO_NFS_H
|
||||
|
||||
#include <kio/slavebase.h>
|
||||
#include <kio/global.h>
|
||||
#include <kconfiggroup.h>
|
||||
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QTimer>
|
||||
|
||||
#include "rpc_nfs2_prot.h"
|
||||
#include "rpc_nfs3_prot.h"
|
||||
|
||||
class NFSProtocol;
|
||||
|
||||
class NFSSlave : public QObject, public KIO::SlaveBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
NFSSlave(const QByteArray& pool, const QByteArray& app);
|
||||
~NFSSlave();
|
||||
|
||||
void openConnection();
|
||||
void closeConnection();
|
||||
|
||||
void setHost(const QString& host, quint16 port, const QString& user, const QString& pass);
|
||||
|
||||
void put(const KUrl& url, int _mode, KIO::JobFlags _flags);
|
||||
void get(const KUrl& url);
|
||||
void listDir(const KUrl& url);
|
||||
void symlink(const QString& target, const KUrl& dest, KIO::JobFlags);
|
||||
void stat(const KUrl& url);
|
||||
void mkdir(const KUrl& url, int permissions);
|
||||
void del(const KUrl& url, bool isfile);
|
||||
void chmod(const KUrl& url, int permissions);
|
||||
void rename(const KUrl& src, const KUrl& dest, KIO::JobFlags flags);
|
||||
void copy(const KUrl& src, const KUrl& dest, int mode, KIO::JobFlags flags);
|
||||
|
||||
protected:
|
||||
// Verifies the current protocol and connection state, returns true if valid.
|
||||
bool verifyProtocol();
|
||||
|
||||
private:
|
||||
NFSProtocol* m_protocol;
|
||||
|
||||
// We need to cache this because the @openConnection call is responsible
|
||||
// for creating the protocol, and the @setHost call might happen before that.
|
||||
QString m_host;
|
||||
};
|
||||
|
||||
|
||||
class NFSFileHandle
|
||||
{
|
||||
public:
|
||||
NFSFileHandle();
|
||||
NFSFileHandle(const NFSFileHandle& handle);
|
||||
NFSFileHandle(const fhandle3& src);
|
||||
NFSFileHandle(const fhandle& src);
|
||||
NFSFileHandle(const nfs_fh3& src);
|
||||
NFSFileHandle(const nfs_fh& src);
|
||||
~NFSFileHandle();
|
||||
|
||||
// Copies the handle data to an nfs file handle
|
||||
void toFH(nfs_fh3& fh) const;
|
||||
void toFH(nfs_fh& fh) const;
|
||||
|
||||
// Copies the source link handle data to an nfs file handle
|
||||
void toFHLink(nfs_fh3& fh) const;
|
||||
void toFHLink(nfs_fh& fh) const;
|
||||
|
||||
NFSFileHandle& operator=(const NFSFileHandle& src);
|
||||
NFSFileHandle& operator=(const fhandle3& src);
|
||||
NFSFileHandle& operator=(const fhandle& src);
|
||||
NFSFileHandle& operator=(const nfs_fh3& src);
|
||||
NFSFileHandle& operator=(const nfs_fh& src);
|
||||
|
||||
bool isInvalid() const
|
||||
{
|
||||
return m_isInvalid;
|
||||
}
|
||||
void setInvalid()
|
||||
{
|
||||
m_isInvalid = true;
|
||||
}
|
||||
|
||||
bool isLink() const
|
||||
{
|
||||
return m_isLink;
|
||||
}
|
||||
bool isBadLink() const
|
||||
{
|
||||
return (m_isLink && m_linkSize == 0);
|
||||
}
|
||||
|
||||
void setLinkSource(const nfs_fh3& src);
|
||||
void setLinkSource(const nfs_fh& src);
|
||||
void setBadLink()
|
||||
{
|
||||
m_isLink = true;
|
||||
m_linkSize = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
char* m_handle;
|
||||
unsigned int m_size;
|
||||
|
||||
// Set to the link source's handle.
|
||||
char* m_linkHandle;
|
||||
unsigned int m_linkSize;
|
||||
|
||||
bool m_isInvalid;
|
||||
bool m_isLink;
|
||||
};
|
||||
|
||||
typedef QMap<QString, NFSFileHandle> NFSFileHandleMap;
|
||||
|
||||
class NFSProtocol
|
||||
{
|
||||
public:
|
||||
NFSProtocol(NFSSlave* slave);
|
||||
virtual ~NFSProtocol() {}
|
||||
|
||||
virtual bool isCompatible(bool &connectionError) = 0;
|
||||
virtual bool isConnected() const = 0;
|
||||
|
||||
virtual void openConnection() = 0;
|
||||
virtual void closeConnection() = 0;
|
||||
|
||||
virtual void setHost(const QString& host) = 0;
|
||||
|
||||
virtual void put(const KUrl& url, int _mode, KIO::JobFlags _flags) = 0;
|
||||
virtual void get(const KUrl& url) = 0;
|
||||
virtual void listDir(const KUrl& url) = 0;
|
||||
virtual void symlink(const QString& target, const KUrl& dest, KIO::JobFlags) = 0;
|
||||
virtual void stat(const KUrl& url) = 0;
|
||||
virtual void mkdir(const KUrl& url, int permissions) = 0;
|
||||
virtual void del(const KUrl& url, bool isfile) = 0;
|
||||
virtual void chmod(const KUrl& url, int permissions) = 0;
|
||||
virtual void rename(const KUrl& src, const KUrl& dest, KIO::JobFlags flags) = 0;
|
||||
|
||||
void copy(const KUrl& src, const KUrl& dest, int mode, KIO::JobFlags flags);
|
||||
|
||||
protected:
|
||||
// Copy from NFS to NFS
|
||||
virtual void copySame(const KUrl& src, const KUrl& dest, int mode, KIO::JobFlags flags) = 0;
|
||||
// Copy from NFS to local
|
||||
virtual void copyFrom(const KUrl& src, const KUrl& dest, int mode, KIO::JobFlags flags) = 0;
|
||||
// Copy from local to NFS
|
||||
virtual void copyTo(const KUrl& src, const KUrl& dest, int mode, KIO::JobFlags flags) = 0;
|
||||
|
||||
// Look up a file handle
|
||||
virtual NFSFileHandle lookupFileHandle(const QString& path) = 0;
|
||||
|
||||
// Modify the exported dirs.
|
||||
void addExportedDir(const QString& path);
|
||||
const QStringList& getExportedDirs();
|
||||
bool isExportedDir(const QString& path);
|
||||
void removeExportedDir(const QString& path);
|
||||
|
||||
// File handle cache functions.
|
||||
void addFileHandle(const QString& path, NFSFileHandle fh);
|
||||
NFSFileHandle getFileHandle(const QString& path);
|
||||
void removeFileHandle(const QString& path);
|
||||
|
||||
// Make sure that the path is actually a part of an nfs share.
|
||||
bool isValidPath(const QString& path);
|
||||
bool isValidLink(const QString& parentDir, const QString& linkDest);
|
||||
|
||||
int openConnection(const QString& host, int prog, int vers, CLIENT*& client, int& sock);
|
||||
|
||||
bool checkForError(int clientStat, int nfsStat, const QString& text);
|
||||
|
||||
void createVirtualDirEntry(KIO::UDSEntry& entry);
|
||||
|
||||
private:
|
||||
NFSSlave* m_slave;
|
||||
|
||||
NFSFileHandleMap m_handleCache;
|
||||
QStringList m_exportedDirs;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,20 +0,0 @@
|
|||
[Protocol]
|
||||
exec=kio_nfs
|
||||
protocol=nfs
|
||||
input=none
|
||||
output=filesystem
|
||||
listing=Name,Type,Size,Date,AccessDate,CreationDate,Access,Owner,Group,Link
|
||||
reading=true
|
||||
writing=true
|
||||
makedir=true
|
||||
deleting=true
|
||||
linking=true
|
||||
moving=true
|
||||
copyToFile=true
|
||||
copyFromFile=true
|
||||
maxInstances=20
|
||||
maxInstancesPerHost=5
|
||||
X-DocPath=kioslave/nfs/index.html
|
||||
Icon=folder-remote
|
||||
Class=:internet
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -1,107 +0,0 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2000 Alexander Neundorf <neundorf@kde.org>,
|
||||
2014 Mathias Tillman <master.homer@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef KIO_NFSV2_H
|
||||
#define KIO_NFSV2_H
|
||||
|
||||
#include "kio_nfs.h"
|
||||
|
||||
// This is needed on Solaris so that rpc.h defines clnttcp_create etc.
|
||||
#ifndef PORTMAP
|
||||
#define PORTMAP
|
||||
#endif
|
||||
|
||||
#include <rpc/rpc.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
class NFSProtocolV2 : public NFSProtocol
|
||||
{
|
||||
public:
|
||||
NFSProtocolV2(NFSSlave* slave);
|
||||
~NFSProtocolV2();
|
||||
|
||||
bool isCompatible(bool& connectionError);
|
||||
bool isConnected() const;
|
||||
|
||||
void openConnection();
|
||||
void closeConnection();
|
||||
|
||||
void setHost(const QString& host);
|
||||
|
||||
void put(const KUrl& url, int _mode, KIO::JobFlags _flags);
|
||||
void get(const KUrl& url);
|
||||
void listDir(const KUrl& url);
|
||||
void symlink(const QString& target, const KUrl& dest, KIO::JobFlags);
|
||||
void stat(const KUrl& url);
|
||||
void mkdir(const KUrl& url, int permissions);
|
||||
void del(const KUrl& url, bool isfile);
|
||||
void chmod(const KUrl& url, int permissions);
|
||||
void rename(const KUrl& src, const KUrl& dest, KIO::JobFlags flags);
|
||||
|
||||
protected:
|
||||
void copySame(const KUrl& src, const KUrl& dest, int mode, KIO::JobFlags flags);
|
||||
void copyFrom(const KUrl& src, const KUrl& dest, int mode, KIO::JobFlags flags);
|
||||
void copyTo(const KUrl& src, const KUrl& dest, int mode, KIO::JobFlags flags);
|
||||
|
||||
NFSFileHandle lookupFileHandle(const QString& path);
|
||||
|
||||
private:
|
||||
bool create(const QString& path, int mode, int& rpcStatus, diropres& result);
|
||||
|
||||
bool getAttr(const QString& path, int& rpcStatus, attrstat& result);
|
||||
|
||||
bool lookupHandle(const QString& path, int& rpcStatus, diropres& result);
|
||||
|
||||
bool readLink(const QString& path, int& rpcStatus, readlinkres& result, char* dataBuffer);
|
||||
|
||||
// Calls @remove, but with dummy rpcStatus and result arguments
|
||||
bool remove(const QString& path);
|
||||
bool remove(const QString& path, int& rpcStatus, nfsstat& result);
|
||||
|
||||
// Calls @rename, but with dummy rpcStatus and result arguments
|
||||
bool rename(const QString& src, const QString& dest);
|
||||
bool rename(const QString& src, const QString& dest, int& rpcStatus, nfsstat& result);
|
||||
|
||||
bool setAttr(const QString& path, const sattr& attributes, int& rpcStatus, nfsstat& result);
|
||||
|
||||
bool symLink(const QString& target, const QString& dest, int& rpcStatus, nfsstat& result);
|
||||
|
||||
// UDS helper functions
|
||||
void completeUDSEntry(KIO::UDSEntry& entry, const fattr& attributes);
|
||||
void completeBadLinkUDSEntry(KIO::UDSEntry& entry, const fattr& attributes);
|
||||
|
||||
NFSSlave* m_slave;
|
||||
|
||||
QString m_currentHost;
|
||||
|
||||
CLIENT* m_mountClient;
|
||||
int m_mountSock;
|
||||
CLIENT* m_nfsClient;
|
||||
int m_nfsSock;
|
||||
|
||||
timeval clnt_timeout;
|
||||
|
||||
QHash<long, QString> m_usercache;
|
||||
QHash<long, QString> m_groupcache;
|
||||
};
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load diff
|
@ -1,118 +0,0 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2000 Alexander Neundorf <neundorf@kde.org>,
|
||||
2014 Mathias Tillman <master.homer@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef KIO_NFSV3_H
|
||||
#define KIO_NFSV3_H
|
||||
|
||||
#include "kio_nfs.h"
|
||||
|
||||
// This is needed on Solaris so that rpc.h defines clnttcp_create etc.
|
||||
#ifndef PORTMAP
|
||||
#define PORTMAP
|
||||
#endif
|
||||
|
||||
#include <rpc/rpc.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
class NFSProtocolV3 : public NFSProtocol
|
||||
{
|
||||
public:
|
||||
NFSProtocolV3(NFSSlave* slave);
|
||||
~NFSProtocolV3();
|
||||
|
||||
bool isCompatible(bool& connectionError);
|
||||
bool isConnected() const;
|
||||
|
||||
void openConnection();
|
||||
void closeConnection();
|
||||
|
||||
void setHost(const QString& host);
|
||||
|
||||
void put(const KUrl& url, int _mode, KIO::JobFlags _flags);
|
||||
void get(const KUrl& url);
|
||||
void listDir(const KUrl& url);
|
||||
void symlink(const QString& target, const KUrl& dest, KIO::JobFlags);
|
||||
void stat(const KUrl& url);
|
||||
void mkdir(const KUrl& url, int permissions);
|
||||
void del(const KUrl& url, bool isfile);
|
||||
void chmod(const KUrl& url, int permissions);
|
||||
void rename(const KUrl& src, const KUrl& dest, KIO::JobFlags flags);
|
||||
|
||||
protected:
|
||||
void copySame(const KUrl& src, const KUrl& dest, int mode, KIO::JobFlags flags);
|
||||
void copyFrom(const KUrl& src, const KUrl& dest, int mode, KIO::JobFlags flags);
|
||||
void copyTo(const KUrl& src, const KUrl& dest, int mode, KIO::JobFlags flags);
|
||||
|
||||
// For servers that don't support the READDIRPLUS command.
|
||||
void listDirCompat(const KUrl& url);
|
||||
|
||||
// Look up a file handle.
|
||||
NFSFileHandle lookupFileHandle(const QString& path);
|
||||
|
||||
private:
|
||||
bool create(const QString& path, int mode, int& rpcStatus, CREATE3res& result);
|
||||
|
||||
bool getAttr(const QString& path, int& rpcStatus, GETATTR3res& result);
|
||||
|
||||
bool lookupHandle(const QString& path, int& rpcStatus, LOOKUP3res& result);
|
||||
|
||||
bool readLink(const QString& path, int& rpcStatus, READLINK3res& result, char* dataBuffer);
|
||||
|
||||
// Calls @remove, but with dummy rpcStatus and result arguments
|
||||
bool remove(const QString& path);
|
||||
bool remove(const QString& path, int& rpcStatus, REMOVE3res& result);
|
||||
|
||||
// Calls @rename, but with dummy rpcStatus and result arguments
|
||||
bool rename(const QString& src, const QString& dest);
|
||||
bool rename(const QString& src, const QString& dest, int& rpcStatus, RENAME3res& result);
|
||||
|
||||
bool setAttr(const QString& path, const sattr3& attributes, int& rpcStatus, SETATTR3res& result);
|
||||
|
||||
bool symLink(const QString& target, const QString& dest, int& rpcStatus, SYMLINK3res& result);
|
||||
|
||||
// Initialises the optimal read, write and read dir buffer sizes
|
||||
void initPreferredSizes(const NFSFileHandle& fh);
|
||||
|
||||
// UDS helper functions
|
||||
void completeUDSEntry(KIO::UDSEntry& entry, const fattr3& attributes);
|
||||
void completeBadLinkUDSEntry(KIO::UDSEntry& entry, const fattr3& attributes);
|
||||
|
||||
NFSSlave* m_slave;
|
||||
|
||||
QString m_currentHost;
|
||||
CLIENT* m_mountClient;
|
||||
int m_mountSock;
|
||||
CLIENT* m_nfsClient;
|
||||
int m_nfsSock;
|
||||
|
||||
timeval clnt_timeout;
|
||||
|
||||
QHash<long, QString> m_usercache;
|
||||
QHash<long, QString> m_groupcache;
|
||||
|
||||
// The optimal read and write buffer sizes and read dir size, cached values
|
||||
uint32 m_readBufferSize;
|
||||
uint32 m_writeBufferSize;
|
||||
uint32 m_readDirSize;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,665 +0,0 @@
|
|||
/*
|
||||
* Please do not edit this file.
|
||||
* It was generated using rpcgen.
|
||||
*/
|
||||
|
||||
#ifndef _RPC_NFS2_PROT_H_RPCGEN
|
||||
#define _RPC_NFS2_PROT_H_RPCGEN
|
||||
|
||||
// This is needed on Solaris so that rpc.h defines clnttcp_create etc.
|
||||
#ifndef PORTMAP
|
||||
#define PORTMAP
|
||||
#endif
|
||||
|
||||
#include <rpc/rpc.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
* unrestricted use provided that this legend is included on all tape
|
||||
* media and as a part of the software program in whole or part. Users
|
||||
* may copy or modify Sun RPC without charge, but are not authorized
|
||||
* to license or distribute it to anyone else except as part of a product or
|
||||
* program developed by the user or with the express written consent of
|
||||
* Sun Microsystems, Inc.
|
||||
*
|
||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
||||
*
|
||||
* Sun RPC is provided with no support and without any obligation on the
|
||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
||||
* modification or enhancement.
|
||||
*
|
||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
||||
* OR ANY PART THEREOF.
|
||||
*
|
||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
||||
* or profits or other special, indirect and consequential damages, even if
|
||||
* Sun has been advised of the possibility of such damages.
|
||||
*
|
||||
* Sun Microsystems, Inc.
|
||||
* 2550 Garcia Avenue
|
||||
* Mountain View, California 94043
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1987, 1990 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
/* from @(#)nfs_prot.x 1.3 91/03/11 TIRPC 1.0 */
|
||||
#ifndef RPCSVC_NFS_PROT_H
|
||||
#define RPCSVC_NFS_PROT_H
|
||||
#define NFS_PORT 2049
|
||||
#define NFS_MAXDATA 8192
|
||||
#define NFS_MAXPATHLEN 1024
|
||||
#define NFS_MAXNAMLEN 255
|
||||
#define NFS_FHSIZE 32
|
||||
#define NFS_COOKIESIZE 4
|
||||
#define NFS_FIFO_DEV -1
|
||||
#define NFSMODE_FMT 0170000
|
||||
#define NFSMODE_DIR 0040000
|
||||
#define NFSMODE_CHR 0020000
|
||||
#define NFSMODE_BLK 0060000
|
||||
#define NFSMODE_REG 0100000
|
||||
#define NFSMODE_LNK 0120000
|
||||
#define NFSMODE_SOCK 0140000
|
||||
#define NFSMODE_FIFO 0010000
|
||||
|
||||
enum nfsstat {
|
||||
NFS_OK = 0,
|
||||
NFSERR_PERM = 1,
|
||||
NFSERR_NOENT = 2,
|
||||
NFSERR_IO = 5,
|
||||
NFSERR_NXIO = 6,
|
||||
NFSERR_ACCES = 13,
|
||||
NFSERR_EXIST = 17,
|
||||
NFSERR_NODEV = 19,
|
||||
NFSERR_NOTDIR = 20,
|
||||
NFSERR_ISDIR = 21,
|
||||
NFSERR_INVAL = 22,
|
||||
NFSERR_FBIG = 27,
|
||||
NFSERR_NOSPC = 28,
|
||||
NFSERR_ROFS = 30,
|
||||
NFSERR_NAMETOOLONG = 63,
|
||||
NFSERR_NOTEMPTY = 66,
|
||||
NFSERR_DQUOT = 69,
|
||||
NFSERR_STALE = 70,
|
||||
NFSERR_WFLUSH = 99,
|
||||
};
|
||||
typedef enum nfsstat nfsstat;
|
||||
|
||||
enum ftype {
|
||||
NFNON = 0,
|
||||
NFREG = 1,
|
||||
NFDIR = 2,
|
||||
NFBLK = 3,
|
||||
NFCHR = 4,
|
||||
NFLNK = 5,
|
||||
NFSOCK = 6,
|
||||
NFBAD = 7,
|
||||
NFFIFO = 8,
|
||||
};
|
||||
typedef enum ftype ftype;
|
||||
|
||||
struct nfs_fh {
|
||||
char data[NFS_FHSIZE];
|
||||
};
|
||||
typedef struct nfs_fh nfs_fh;
|
||||
|
||||
struct nfstime {
|
||||
u_int seconds;
|
||||
u_int useconds;
|
||||
};
|
||||
typedef struct nfstime nfstime;
|
||||
|
||||
struct fattr {
|
||||
ftype type;
|
||||
u_int mode;
|
||||
u_int nlink;
|
||||
u_int uid;
|
||||
u_int gid;
|
||||
u_int size;
|
||||
u_int blocksize;
|
||||
u_int rdev;
|
||||
u_int blocks;
|
||||
u_int fsid;
|
||||
u_int fileid;
|
||||
nfstime atime;
|
||||
nfstime mtime;
|
||||
nfstime ctime;
|
||||
};
|
||||
typedef struct fattr fattr;
|
||||
|
||||
struct sattr {
|
||||
u_int mode;
|
||||
u_int uid;
|
||||
u_int gid;
|
||||
u_int size;
|
||||
nfstime atime;
|
||||
nfstime mtime;
|
||||
};
|
||||
typedef struct sattr sattr;
|
||||
|
||||
typedef char *filename;
|
||||
|
||||
typedef char *nfspath;
|
||||
|
||||
struct attrstat {
|
||||
nfsstat status;
|
||||
union {
|
||||
fattr attributes;
|
||||
} attrstat_u;
|
||||
};
|
||||
typedef struct attrstat attrstat;
|
||||
|
||||
struct sattrargs {
|
||||
nfs_fh file;
|
||||
sattr attributes;
|
||||
};
|
||||
typedef struct sattrargs sattrargs;
|
||||
|
||||
struct diropargs {
|
||||
nfs_fh dir;
|
||||
filename name;
|
||||
};
|
||||
typedef struct diropargs diropargs;
|
||||
|
||||
struct diropokres {
|
||||
nfs_fh file;
|
||||
fattr attributes;
|
||||
};
|
||||
typedef struct diropokres diropokres;
|
||||
|
||||
struct diropres {
|
||||
nfsstat status;
|
||||
union {
|
||||
diropokres diropres;
|
||||
} diropres_u;
|
||||
};
|
||||
typedef struct diropres diropres;
|
||||
|
||||
struct readlinkres {
|
||||
nfsstat status;
|
||||
union {
|
||||
nfspath data;
|
||||
} readlinkres_u;
|
||||
};
|
||||
typedef struct readlinkres readlinkres;
|
||||
|
||||
struct readargs {
|
||||
nfs_fh file;
|
||||
u_int offset;
|
||||
u_int count;
|
||||
u_int totalcount;
|
||||
};
|
||||
typedef struct readargs readargs;
|
||||
|
||||
struct readokres {
|
||||
fattr attributes;
|
||||
struct {
|
||||
u_int data_len;
|
||||
char *data_val;
|
||||
} data;
|
||||
};
|
||||
typedef struct readokres readokres;
|
||||
|
||||
struct readres {
|
||||
nfsstat status;
|
||||
union {
|
||||
readokres reply;
|
||||
} readres_u;
|
||||
};
|
||||
typedef struct readres readres;
|
||||
|
||||
struct writeargs {
|
||||
nfs_fh file;
|
||||
u_int beginoffset;
|
||||
u_int offset;
|
||||
u_int totalcount;
|
||||
struct {
|
||||
u_int data_len;
|
||||
char *data_val;
|
||||
} data;
|
||||
};
|
||||
typedef struct writeargs writeargs;
|
||||
|
||||
struct createargs {
|
||||
diropargs where;
|
||||
sattr attributes;
|
||||
};
|
||||
typedef struct createargs createargs;
|
||||
|
||||
struct renameargs {
|
||||
diropargs from;
|
||||
diropargs to;
|
||||
};
|
||||
typedef struct renameargs renameargs;
|
||||
|
||||
struct linkargs {
|
||||
nfs_fh from;
|
||||
diropargs to;
|
||||
};
|
||||
typedef struct linkargs linkargs;
|
||||
|
||||
struct symlinkargs {
|
||||
diropargs from;
|
||||
nfspath to;
|
||||
sattr attributes;
|
||||
};
|
||||
typedef struct symlinkargs symlinkargs;
|
||||
|
||||
typedef char nfscookie[NFS_COOKIESIZE];
|
||||
|
||||
struct readdirargs {
|
||||
nfs_fh dir;
|
||||
nfscookie cookie;
|
||||
u_int count;
|
||||
};
|
||||
typedef struct readdirargs readdirargs;
|
||||
|
||||
struct entry {
|
||||
u_int fileid;
|
||||
filename name;
|
||||
nfscookie cookie;
|
||||
struct entry *nextentry;
|
||||
};
|
||||
typedef struct entry entry;
|
||||
|
||||
struct dirlist {
|
||||
entry *entries;
|
||||
bool_t eof;
|
||||
};
|
||||
typedef struct dirlist dirlist;
|
||||
|
||||
struct readdirres {
|
||||
nfsstat status;
|
||||
union {
|
||||
dirlist reply;
|
||||
} readdirres_u;
|
||||
};
|
||||
typedef struct readdirres readdirres;
|
||||
|
||||
struct statfsokres {
|
||||
u_int tsize;
|
||||
u_int bsize;
|
||||
u_int blocks;
|
||||
u_int bfree;
|
||||
u_int bavail;
|
||||
};
|
||||
typedef struct statfsokres statfsokres;
|
||||
|
||||
struct statfsres {
|
||||
nfsstat status;
|
||||
union {
|
||||
statfsokres reply;
|
||||
} statfsres_u;
|
||||
};
|
||||
typedef struct statfsres statfsres;
|
||||
#define MNTPATHLEN 1024
|
||||
#define MNTNAMLEN 255
|
||||
#define FHSIZE 32
|
||||
|
||||
typedef char fhandle[FHSIZE];
|
||||
|
||||
struct fhstatus {
|
||||
u_int fhs_status;
|
||||
union {
|
||||
fhandle fhs_fhandle;
|
||||
} fhstatus_u;
|
||||
};
|
||||
typedef struct fhstatus fhstatus;
|
||||
|
||||
typedef char *dirpath;
|
||||
|
||||
typedef char *name;
|
||||
|
||||
typedef struct mountbody *mountlist;
|
||||
|
||||
struct mountbody {
|
||||
name ml_hostname;
|
||||
dirpath ml_directory;
|
||||
mountlist ml_next;
|
||||
};
|
||||
typedef struct mountbody mountbody;
|
||||
|
||||
typedef struct groupnode *groups;
|
||||
|
||||
struct groupnode {
|
||||
name gr_name;
|
||||
groups gr_next;
|
||||
};
|
||||
typedef struct groupnode groupnode;
|
||||
|
||||
typedef struct exportnode *exports;
|
||||
|
||||
struct exportnode {
|
||||
dirpath ex_dir;
|
||||
groups ex_groups;
|
||||
exports ex_next;
|
||||
};
|
||||
typedef struct exportnode exportnode;
|
||||
|
||||
struct ppathcnf {
|
||||
int pc_link_max;
|
||||
short pc_max_canon;
|
||||
short pc_max_input;
|
||||
short pc_name_max;
|
||||
short pc_path_max;
|
||||
short pc_pipe_buf;
|
||||
u_char pc_vdisable;
|
||||
char pc_xxx;
|
||||
short pc_mask[2];
|
||||
};
|
||||
typedef struct ppathcnf ppathcnf;
|
||||
#endif /*!RPCSVC_NFS_PROT_H*/
|
||||
|
||||
#define NFS_PROGRAM 100003
|
||||
#define NFS_VERSION 2
|
||||
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
#define NFSPROC_NULL 0
|
||||
extern void * nfsproc_null_2(CLIENT *);
|
||||
extern void * nfsproc_null_2_svc(struct svc_req *);
|
||||
#define NFSPROC_GETATTR 1
|
||||
extern attrstat * nfsproc_getattr_2(nfs_fh , CLIENT *);
|
||||
extern attrstat * nfsproc_getattr_2_svc(nfs_fh , struct svc_req *);
|
||||
#define NFSPROC_SETATTR 2
|
||||
extern attrstat * nfsproc_setattr_2(sattrargs , CLIENT *);
|
||||
extern attrstat * nfsproc_setattr_2_svc(sattrargs , struct svc_req *);
|
||||
#define NFSPROC_ROOT 3
|
||||
extern void * nfsproc_root_2(CLIENT *);
|
||||
extern void * nfsproc_root_2_svc(struct svc_req *);
|
||||
#define NFSPROC_LOOKUP 4
|
||||
extern diropres * nfsproc_lookup_2(diropargs , CLIENT *);
|
||||
extern diropres * nfsproc_lookup_2_svc(diropargs , struct svc_req *);
|
||||
#define NFSPROC_READLINK 5
|
||||
extern readlinkres * nfsproc_readlink_2(nfs_fh , CLIENT *);
|
||||
extern readlinkres * nfsproc_readlink_2_svc(nfs_fh , struct svc_req *);
|
||||
#define NFSPROC_READ 6
|
||||
extern readres * nfsproc_read_2(readargs , CLIENT *);
|
||||
extern readres * nfsproc_read_2_svc(readargs , struct svc_req *);
|
||||
#define NFSPROC_WRITECACHE 7
|
||||
extern void * nfsproc_writecache_2(CLIENT *);
|
||||
extern void * nfsproc_writecache_2_svc(struct svc_req *);
|
||||
#define NFSPROC_WRITE 8
|
||||
extern attrstat * nfsproc_write_2(writeargs , CLIENT *);
|
||||
extern attrstat * nfsproc_write_2_svc(writeargs , struct svc_req *);
|
||||
#define NFSPROC_CREATE 9
|
||||
extern diropres * nfsproc_create_2(createargs , CLIENT *);
|
||||
extern diropres * nfsproc_create_2_svc(createargs , struct svc_req *);
|
||||
#define NFSPROC_REMOVE 10
|
||||
extern nfsstat * nfsproc_remove_2(diropargs , CLIENT *);
|
||||
extern nfsstat * nfsproc_remove_2_svc(diropargs , struct svc_req *);
|
||||
#define NFSPROC_RENAME 11
|
||||
extern nfsstat * nfsproc_rename_2(renameargs , CLIENT *);
|
||||
extern nfsstat * nfsproc_rename_2_svc(renameargs , struct svc_req *);
|
||||
#define NFSPROC_LINK 12
|
||||
extern nfsstat * nfsproc_link_2(linkargs , CLIENT *);
|
||||
extern nfsstat * nfsproc_link_2_svc(linkargs , struct svc_req *);
|
||||
#define NFSPROC_SYMLINK 13
|
||||
extern nfsstat * nfsproc_symlink_2(symlinkargs , CLIENT *);
|
||||
extern nfsstat * nfsproc_symlink_2_svc(symlinkargs , struct svc_req *);
|
||||
#define NFSPROC_MKDIR 14
|
||||
extern diropres * nfsproc_mkdir_2(createargs , CLIENT *);
|
||||
extern diropres * nfsproc_mkdir_2_svc(createargs , struct svc_req *);
|
||||
#define NFSPROC_RMDIR 15
|
||||
extern nfsstat * nfsproc_rmdir_2(diropargs , CLIENT *);
|
||||
extern nfsstat * nfsproc_rmdir_2_svc(diropargs , struct svc_req *);
|
||||
#define NFSPROC_READDIR 16
|
||||
extern readdirres * nfsproc_readdir_2(readdirargs , CLIENT *);
|
||||
extern readdirres * nfsproc_readdir_2_svc(readdirargs , struct svc_req *);
|
||||
#define NFSPROC_STATFS 17
|
||||
extern statfsres * nfsproc_statfs_2(nfs_fh , CLIENT *);
|
||||
extern statfsres * nfsproc_statfs_2_svc(nfs_fh , struct svc_req *);
|
||||
extern int nfs_program_2_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
|
||||
|
||||
#else /* K&R C */
|
||||
#define NFSPROC_NULL 0
|
||||
extern void * nfsproc_null_2();
|
||||
extern void * nfsproc_null_2_svc();
|
||||
#define NFSPROC_GETATTR 1
|
||||
extern attrstat * nfsproc_getattr_2();
|
||||
extern attrstat * nfsproc_getattr_2_svc();
|
||||
#define NFSPROC_SETATTR 2
|
||||
extern attrstat * nfsproc_setattr_2();
|
||||
extern attrstat * nfsproc_setattr_2_svc();
|
||||
#define NFSPROC_ROOT 3
|
||||
extern void * nfsproc_root_2();
|
||||
extern void * nfsproc_root_2_svc();
|
||||
#define NFSPROC_LOOKUP 4
|
||||
extern diropres * nfsproc_lookup_2();
|
||||
extern diropres * nfsproc_lookup_2_svc();
|
||||
#define NFSPROC_READLINK 5
|
||||
extern readlinkres * nfsproc_readlink_2();
|
||||
extern readlinkres * nfsproc_readlink_2_svc();
|
||||
#define NFSPROC_READ 6
|
||||
extern readres * nfsproc_read_2();
|
||||
extern readres * nfsproc_read_2_svc();
|
||||
#define NFSPROC_WRITECACHE 7
|
||||
extern void * nfsproc_writecache_2();
|
||||
extern void * nfsproc_writecache_2_svc();
|
||||
#define NFSPROC_WRITE 8
|
||||
extern attrstat * nfsproc_write_2();
|
||||
extern attrstat * nfsproc_write_2_svc();
|
||||
#define NFSPROC_CREATE 9
|
||||
extern diropres * nfsproc_create_2();
|
||||
extern diropres * nfsproc_create_2_svc();
|
||||
#define NFSPROC_REMOVE 10
|
||||
extern nfsstat * nfsproc_remove_2();
|
||||
extern nfsstat * nfsproc_remove_2_svc();
|
||||
#define NFSPROC_RENAME 11
|
||||
extern nfsstat * nfsproc_rename_2();
|
||||
extern nfsstat * nfsproc_rename_2_svc();
|
||||
#define NFSPROC_LINK 12
|
||||
extern nfsstat * nfsproc_link_2();
|
||||
extern nfsstat * nfsproc_link_2_svc();
|
||||
#define NFSPROC_SYMLINK 13
|
||||
extern nfsstat * nfsproc_symlink_2();
|
||||
extern nfsstat * nfsproc_symlink_2_svc();
|
||||
#define NFSPROC_MKDIR 14
|
||||
extern diropres * nfsproc_mkdir_2();
|
||||
extern diropres * nfsproc_mkdir_2_svc();
|
||||
#define NFSPROC_RMDIR 15
|
||||
extern nfsstat * nfsproc_rmdir_2();
|
||||
extern nfsstat * nfsproc_rmdir_2_svc();
|
||||
#define NFSPROC_READDIR 16
|
||||
extern readdirres * nfsproc_readdir_2();
|
||||
extern readdirres * nfsproc_readdir_2_svc();
|
||||
#define NFSPROC_STATFS 17
|
||||
extern statfsres * nfsproc_statfs_2();
|
||||
extern statfsres * nfsproc_statfs_2_svc();
|
||||
extern int nfs_program_2_freeresult ();
|
||||
#endif /* K&R C */
|
||||
|
||||
#define MOUNTPROG 100005
|
||||
#define MOUNTVERS 1
|
||||
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
#define MOUNTPROC_NULL 0
|
||||
extern void * mountproc_null_1(CLIENT *);
|
||||
extern void * mountproc_null_1_svc(struct svc_req *);
|
||||
#define MOUNTPROC_MNT 1
|
||||
extern fhstatus * mountproc_mnt_1(dirpath , CLIENT *);
|
||||
extern fhstatus * mountproc_mnt_1_svc(dirpath , struct svc_req *);
|
||||
#define MOUNTPROC_DUMP 2
|
||||
extern mountlist * mountproc_dump_1(CLIENT *);
|
||||
extern mountlist * mountproc_dump_1_svc(struct svc_req *);
|
||||
#define MOUNTPROC_UMNT 3
|
||||
extern void * mountproc_umnt_1(dirpath , CLIENT *);
|
||||
extern void * mountproc_umnt_1_svc(dirpath , struct svc_req *);
|
||||
#define MOUNTPROC_UMNTALL 4
|
||||
extern void * mountproc_umntall_1(CLIENT *);
|
||||
extern void * mountproc_umntall_1_svc(struct svc_req *);
|
||||
#define MOUNTPROC_EXPORT 5
|
||||
extern exports * mountproc_export_1(CLIENT *);
|
||||
extern exports * mountproc_export_1_svc(struct svc_req *);
|
||||
#define MOUNTPROC_EXPORTALL 6
|
||||
extern exports * mountproc_exportall_1(CLIENT *);
|
||||
extern exports * mountproc_exportall_1_svc(struct svc_req *);
|
||||
extern int mountprog_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
|
||||
|
||||
#else /* K&R C */
|
||||
#define MOUNTPROC_NULL 0
|
||||
extern void * mountproc_null_1();
|
||||
extern void * mountproc_null_1_svc();
|
||||
#define MOUNTPROC_MNT 1
|
||||
extern fhstatus * mountproc_mnt_1();
|
||||
extern fhstatus * mountproc_mnt_1_svc();
|
||||
#define MOUNTPROC_DUMP 2
|
||||
extern mountlist * mountproc_dump_1();
|
||||
extern mountlist * mountproc_dump_1_svc();
|
||||
#define MOUNTPROC_UMNT 3
|
||||
extern void * mountproc_umnt_1();
|
||||
extern void * mountproc_umnt_1_svc();
|
||||
#define MOUNTPROC_UMNTALL 4
|
||||
extern void * mountproc_umntall_1();
|
||||
extern void * mountproc_umntall_1_svc();
|
||||
#define MOUNTPROC_EXPORT 5
|
||||
extern exports * mountproc_export_1();
|
||||
extern exports * mountproc_export_1_svc();
|
||||
#define MOUNTPROC_EXPORTALL 6
|
||||
extern exports * mountproc_exportall_1();
|
||||
extern exports * mountproc_exportall_1_svc();
|
||||
extern int mountprog_1_freeresult ();
|
||||
#endif /* K&R C */
|
||||
#define MOUNTVERS_POSIX 2
|
||||
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
extern void * mountproc_null_2(CLIENT *);
|
||||
extern void * mountproc_null_2_svc(struct svc_req *);
|
||||
extern fhstatus * mountproc_mnt_2(dirpath , CLIENT *);
|
||||
extern fhstatus * mountproc_mnt_2_svc(dirpath , struct svc_req *);
|
||||
extern mountlist * mountproc_dump_2(CLIENT *);
|
||||
extern mountlist * mountproc_dump_2_svc(struct svc_req *);
|
||||
extern void * mountproc_umnt_2(dirpath , CLIENT *);
|
||||
extern void * mountproc_umnt_2_svc(dirpath , struct svc_req *);
|
||||
extern void * mountproc_umntall_2(CLIENT *);
|
||||
extern void * mountproc_umntall_2_svc(struct svc_req *);
|
||||
extern exports * mountproc_export_2(CLIENT *);
|
||||
extern exports * mountproc_export_2_svc(struct svc_req *);
|
||||
extern exports * mountproc_exportall_2(CLIENT *);
|
||||
extern exports * mountproc_exportall_2_svc(struct svc_req *);
|
||||
#define MOUNTPROC_PATHCONF 7
|
||||
extern ppathcnf * mountproc_pathconf_2(dirpath , CLIENT *);
|
||||
extern ppathcnf * mountproc_pathconf_2_svc(dirpath , struct svc_req *);
|
||||
extern int mountprog_2_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
|
||||
|
||||
#else /* K&R C */
|
||||
extern void * mountproc_null_2();
|
||||
extern void * mountproc_null_2_svc();
|
||||
extern fhstatus * mountproc_mnt_2();
|
||||
extern fhstatus * mountproc_mnt_2_svc();
|
||||
extern mountlist * mountproc_dump_2();
|
||||
extern mountlist * mountproc_dump_2_svc();
|
||||
extern void * mountproc_umnt_2();
|
||||
extern void * mountproc_umnt_2_svc();
|
||||
extern void * mountproc_umntall_2();
|
||||
extern void * mountproc_umntall_2_svc();
|
||||
extern exports * mountproc_export_2();
|
||||
extern exports * mountproc_export_2_svc();
|
||||
extern exports * mountproc_exportall_2();
|
||||
extern exports * mountproc_exportall_2_svc();
|
||||
#define MOUNTPROC_PATHCONF 7
|
||||
extern ppathcnf * mountproc_pathconf_2();
|
||||
extern ppathcnf * mountproc_pathconf_2_svc();
|
||||
extern int mountprog_2_freeresult ();
|
||||
#endif /* K&R C */
|
||||
|
||||
/* the xdr functions */
|
||||
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
extern bool_t xdr_nfsstat (XDR *, nfsstat*);
|
||||
extern bool_t xdr_ftype (XDR *, ftype*);
|
||||
extern bool_t xdr_nfs_fh (XDR *, nfs_fh*);
|
||||
extern bool_t xdr_nfstime (XDR *, nfstime*);
|
||||
extern bool_t xdr_fattr (XDR *, fattr*);
|
||||
extern bool_t xdr_sattr (XDR *, sattr*);
|
||||
extern bool_t xdr_filename (XDR *, filename*);
|
||||
extern bool_t xdr_nfspath (XDR *, nfspath*);
|
||||
extern bool_t xdr_attrstat (XDR *, attrstat*);
|
||||
extern bool_t xdr_sattrargs (XDR *, sattrargs*);
|
||||
extern bool_t xdr_diropargs (XDR *, diropargs*);
|
||||
extern bool_t xdr_diropokres (XDR *, diropokres*);
|
||||
extern bool_t xdr_diropres (XDR *, diropres*);
|
||||
extern bool_t xdr_readlinkres (XDR *, readlinkres*);
|
||||
extern bool_t xdr_readargs (XDR *, readargs*);
|
||||
extern bool_t xdr_readokres (XDR *, readokres*);
|
||||
extern bool_t xdr_readres (XDR *, readres*);
|
||||
extern bool_t xdr_writeargs (XDR *, writeargs*);
|
||||
extern bool_t xdr_createargs (XDR *, createargs*);
|
||||
extern bool_t xdr_renameargs (XDR *, renameargs*);
|
||||
extern bool_t xdr_linkargs (XDR *, linkargs*);
|
||||
extern bool_t xdr_symlinkargs (XDR *, symlinkargs*);
|
||||
extern bool_t xdr_nfscookie (XDR *, nfscookie);
|
||||
extern bool_t xdr_readdirargs (XDR *, readdirargs*);
|
||||
extern bool_t xdr_entry (XDR *, entry*);
|
||||
extern bool_t xdr_dirlist (XDR *, dirlist*);
|
||||
extern bool_t xdr_readdirres (XDR *, readdirres*);
|
||||
extern bool_t xdr_statfsokres (XDR *, statfsokres*);
|
||||
extern bool_t xdr_statfsres (XDR *, statfsres*);
|
||||
extern bool_t xdr_fhandle (XDR *, fhandle);
|
||||
extern bool_t xdr_fhstatus (XDR *, fhstatus*);
|
||||
extern bool_t xdr_dirpath (XDR *, dirpath*);
|
||||
extern bool_t xdr_name (XDR *, name*);
|
||||
extern bool_t xdr_mountlist (XDR *, mountlist*);
|
||||
extern bool_t xdr_mountbody (XDR *, mountbody*);
|
||||
extern bool_t xdr_groups (XDR *, groups*);
|
||||
extern bool_t xdr_groupnode (XDR *, groupnode*);
|
||||
extern bool_t xdr_exports (XDR *, exports*);
|
||||
extern bool_t xdr_exportnode (XDR *, exportnode*);
|
||||
extern bool_t xdr_ppathcnf (XDR *, ppathcnf*);
|
||||
|
||||
#else /* K&R C */
|
||||
extern bool_t xdr_nfsstat ();
|
||||
extern bool_t xdr_ftype ();
|
||||
extern bool_t xdr_nfs_fh ();
|
||||
extern bool_t xdr_nfstime ();
|
||||
extern bool_t xdr_fattr ();
|
||||
extern bool_t xdr_sattr ();
|
||||
extern bool_t xdr_filename ();
|
||||
extern bool_t xdr_nfspath ();
|
||||
extern bool_t xdr_attrstat ();
|
||||
extern bool_t xdr_sattrargs ();
|
||||
extern bool_t xdr_diropargs ();
|
||||
extern bool_t xdr_diropokres ();
|
||||
extern bool_t xdr_diropres ();
|
||||
extern bool_t xdr_readlinkres ();
|
||||
extern bool_t xdr_readargs ();
|
||||
extern bool_t xdr_readokres ();
|
||||
extern bool_t xdr_readres ();
|
||||
extern bool_t xdr_writeargs ();
|
||||
extern bool_t xdr_createargs ();
|
||||
extern bool_t xdr_renameargs ();
|
||||
extern bool_t xdr_linkargs ();
|
||||
extern bool_t xdr_symlinkargs ();
|
||||
extern bool_t xdr_nfscookie ();
|
||||
extern bool_t xdr_readdirargs ();
|
||||
extern bool_t xdr_entry ();
|
||||
extern bool_t xdr_dirlist ();
|
||||
extern bool_t xdr_readdirres ();
|
||||
extern bool_t xdr_statfsokres ();
|
||||
extern bool_t xdr_statfsres ();
|
||||
extern bool_t xdr_fhandle ();
|
||||
extern bool_t xdr_fhstatus ();
|
||||
extern bool_t xdr_dirpath ();
|
||||
extern bool_t xdr_name ();
|
||||
extern bool_t xdr_mountlist ();
|
||||
extern bool_t xdr_mountbody ();
|
||||
extern bool_t xdr_groups ();
|
||||
extern bool_t xdr_groupnode ();
|
||||
extern bool_t xdr_exports ();
|
||||
extern bool_t xdr_exportnode ();
|
||||
extern bool_t xdr_ppathcnf ();
|
||||
|
||||
#endif /* K&R C */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_RPC_NFS2_PROT_H_RPCGEN */
|
|
@ -1,574 +0,0 @@
|
|||
%/*
|
||||
% * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
% * unrestricted use provided that this legend is included on all tape
|
||||
% * media and as a part of the software program in whole or part. Users
|
||||
% * may copy or modify Sun RPC without charge, but are not authorized
|
||||
% * to license or distribute it to anyone else except as part of a product or
|
||||
% * program developed by the user or with the express written consent of
|
||||
% * Sun Microsystems, Inc.
|
||||
% *
|
||||
% * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
||||
% * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
||||
% * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
||||
% *
|
||||
% * Sun RPC is provided with no support and without any obligation on the
|
||||
% * part of Sun Microsystems, Inc. to assist in its use, correction,
|
||||
% * modification or enhancement.
|
||||
% *
|
||||
% * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
||||
% * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
||||
% * OR ANY PART THEREOF.
|
||||
% *
|
||||
% * In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
||||
% * or profits or other special, indirect and consequential damages, even if
|
||||
% * Sun has been advised of the possibility of such damages.
|
||||
% *
|
||||
% * Sun Microsystems, Inc.
|
||||
% * 2550 Garcia Avenue
|
||||
% * Mountain View, California 94043
|
||||
% */
|
||||
|
||||
%/*
|
||||
% * Copyright (c) 1987, 1990 by Sun Microsystems, Inc.
|
||||
% */
|
||||
%
|
||||
%/* from @(#)nfs_prot.x 1.3 91/03/11 TIRPC 1.0 */
|
||||
|
||||
#ifdef RPC_HDR
|
||||
%#ifndef _rpcsvc_nfs_prot_h
|
||||
%#define _rpcsvc_nfs_prot_h
|
||||
#endif
|
||||
|
||||
const NFS_PORT = 2049;
|
||||
const NFS_MAXDATA = 8192;
|
||||
const NFS_MAXPATHLEN = 1024;
|
||||
const NFS_MAXNAMLEN = 255;
|
||||
const NFS_FHSIZE = 32;
|
||||
const NFS_COOKIESIZE = 4;
|
||||
const NFS_FIFO_DEV = -1; /* size kludge for named pipes */
|
||||
|
||||
/*
|
||||
* File types
|
||||
*/
|
||||
const NFSMODE_FMT = 0170000; /* type of file */
|
||||
const NFSMODE_DIR = 0040000; /* directory */
|
||||
const NFSMODE_CHR = 0020000; /* character special */
|
||||
const NFSMODE_BLK = 0060000; /* block special */
|
||||
const NFSMODE_REG = 0100000; /* regular */
|
||||
const NFSMODE_LNK = 0120000; /* symbolic link */
|
||||
const NFSMODE_SOCK = 0140000; /* socket */
|
||||
const NFSMODE_FIFO = 0010000; /* fifo */
|
||||
|
||||
/*
|
||||
* Error status
|
||||
*/
|
||||
enum nfsstat {
|
||||
NFS_OK= 0, /* no error */
|
||||
NFSERR_PERM=1, /* Not owner */
|
||||
NFSERR_NOENT=2, /* No such file or directory */
|
||||
NFSERR_IO=5, /* I/O error */
|
||||
NFSERR_NXIO=6, /* No such device or address */
|
||||
NFSERR_ACCES=13, /* Permission denied */
|
||||
NFSERR_EXIST=17, /* File exists */
|
||||
NFSERR_NODEV=19, /* No such device */
|
||||
NFSERR_NOTDIR=20, /* Not a directory*/
|
||||
NFSERR_ISDIR=21, /* Is a directory */
|
||||
NFSERR_INVAL=22, /* invalid argument */
|
||||
NFSERR_FBIG=27, /* File too large */
|
||||
NFSERR_NOSPC=28, /* No space left on device */
|
||||
NFSERR_ROFS=30, /* Read-only file system */
|
||||
NFSERR_NAMETOOLONG=63, /* File name too long */
|
||||
NFSERR_NOTEMPTY=66, /* Directory not empty */
|
||||
NFSERR_DQUOT=69, /* Disc quota exceeded */
|
||||
NFSERR_STALE=70, /* Stale NFS file handle */
|
||||
NFSERR_WFLUSH=99 /* write cache flushed */
|
||||
};
|
||||
|
||||
/*
|
||||
* File types
|
||||
*/
|
||||
enum ftype {
|
||||
NFNON = 0, /* non-file */
|
||||
NFREG = 1, /* regular file */
|
||||
NFDIR = 2, /* directory */
|
||||
NFBLK = 3, /* block special */
|
||||
NFCHR = 4, /* character special */
|
||||
NFLNK = 5, /* symbolic link */
|
||||
NFSOCK = 6, /* unix domain sockets */
|
||||
NFBAD = 7, /* unused */
|
||||
NFFIFO = 8 /* named pipe */
|
||||
};
|
||||
|
||||
/*
|
||||
* File access handle
|
||||
*/
|
||||
struct nfs_fh {
|
||||
opaque data[NFS_FHSIZE];
|
||||
};
|
||||
|
||||
/*
|
||||
* Timeval
|
||||
*/
|
||||
struct nfstime {
|
||||
unsigned seconds;
|
||||
unsigned useconds;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* File attributes
|
||||
*/
|
||||
struct fattr {
|
||||
ftype type; /* file type */
|
||||
unsigned mode; /* protection mode bits */
|
||||
unsigned nlink; /* # hard links */
|
||||
unsigned uid; /* owner user id */
|
||||
unsigned gid; /* owner group id */
|
||||
unsigned size; /* file size in bytes */
|
||||
unsigned blocksize; /* prefered block size */
|
||||
unsigned rdev; /* special device # */
|
||||
unsigned blocks; /* Kb of disk used by file */
|
||||
unsigned fsid; /* device # */
|
||||
unsigned fileid; /* inode # */
|
||||
nfstime atime; /* time of last access */
|
||||
nfstime mtime; /* time of last modification */
|
||||
nfstime ctime; /* time of last change */
|
||||
};
|
||||
|
||||
/*
|
||||
* File attributes which can be set
|
||||
*/
|
||||
struct sattr {
|
||||
unsigned mode; /* protection mode bits */
|
||||
unsigned uid; /* owner user id */
|
||||
unsigned gid; /* owner group id */
|
||||
unsigned size; /* file size in bytes */
|
||||
nfstime atime; /* time of last access */
|
||||
nfstime mtime; /* time of last modification */
|
||||
};
|
||||
|
||||
|
||||
typedef string filename<NFS_MAXNAMLEN>;
|
||||
typedef string nfspath<NFS_MAXPATHLEN>;
|
||||
|
||||
/*
|
||||
* Reply status with file attributes
|
||||
*/
|
||||
union attrstat switch (nfsstat status) {
|
||||
case NFS_OK:
|
||||
fattr attributes;
|
||||
default:
|
||||
void;
|
||||
};
|
||||
|
||||
struct sattrargs {
|
||||
nfs_fh file;
|
||||
sattr attributes;
|
||||
};
|
||||
|
||||
/*
|
||||
* Arguments for directory operations
|
||||
*/
|
||||
struct diropargs {
|
||||
nfs_fh dir; /* directory file handle */
|
||||
filename name; /* name (up to NFS_MAXNAMLEN bytes) */
|
||||
};
|
||||
|
||||
struct diropokres {
|
||||
nfs_fh file;
|
||||
fattr attributes;
|
||||
};
|
||||
|
||||
/*
|
||||
* Results from directory operation
|
||||
*/
|
||||
union diropres switch (nfsstat status) {
|
||||
case NFS_OK:
|
||||
diropokres diropres;
|
||||
default:
|
||||
void;
|
||||
};
|
||||
|
||||
union readlinkres switch (nfsstat status) {
|
||||
case NFS_OK:
|
||||
nfspath data;
|
||||
default:
|
||||
void;
|
||||
};
|
||||
|
||||
/*
|
||||
* Arguments to remote read
|
||||
*/
|
||||
struct readargs {
|
||||
nfs_fh file; /* handle for file */
|
||||
unsigned offset; /* byte offset in file */
|
||||
unsigned count; /* immediate read count */
|
||||
unsigned totalcount; /* total read count (from this offset)*/
|
||||
};
|
||||
|
||||
/*
|
||||
* Status OK portion of remote read reply
|
||||
*/
|
||||
struct readokres {
|
||||
fattr attributes; /* attributes, need for pagin*/
|
||||
opaque data<NFS_MAXDATA>;
|
||||
};
|
||||
|
||||
union readres switch (nfsstat status) {
|
||||
case NFS_OK:
|
||||
readokres reply;
|
||||
default:
|
||||
void;
|
||||
};
|
||||
|
||||
/*
|
||||
* Arguments to remote write
|
||||
*/
|
||||
struct writeargs {
|
||||
nfs_fh file; /* handle for file */
|
||||
unsigned beginoffset; /* beginning byte offset in file */
|
||||
unsigned offset; /* current byte offset in file */
|
||||
unsigned totalcount; /* total write count (to this offset)*/
|
||||
opaque data<NFS_MAXDATA>;
|
||||
};
|
||||
|
||||
struct createargs {
|
||||
diropargs where;
|
||||
sattr attributes;
|
||||
};
|
||||
|
||||
struct renameargs {
|
||||
diropargs from;
|
||||
diropargs to;
|
||||
};
|
||||
|
||||
struct linkargs {
|
||||
nfs_fh from;
|
||||
diropargs to;
|
||||
};
|
||||
|
||||
struct symlinkargs {
|
||||
diropargs from;
|
||||
nfspath to;
|
||||
sattr attributes;
|
||||
};
|
||||
|
||||
|
||||
typedef opaque nfscookie[NFS_COOKIESIZE];
|
||||
|
||||
/*
|
||||
* Arguments to readdir
|
||||
*/
|
||||
struct readdirargs {
|
||||
nfs_fh dir; /* directory handle */
|
||||
nfscookie cookie;
|
||||
unsigned count; /* number of directory bytes to read */
|
||||
};
|
||||
|
||||
struct entry {
|
||||
unsigned fileid;
|
||||
filename name;
|
||||
nfscookie cookie;
|
||||
entry *nextentry;
|
||||
};
|
||||
|
||||
struct dirlist {
|
||||
entry *entries;
|
||||
bool eof;
|
||||
};
|
||||
|
||||
union readdirres switch (nfsstat status) {
|
||||
case NFS_OK:
|
||||
dirlist reply;
|
||||
default:
|
||||
void;
|
||||
};
|
||||
|
||||
struct statfsokres {
|
||||
unsigned tsize; /* preferred transfer size in bytes */
|
||||
unsigned bsize; /* fundamental file system block size */
|
||||
unsigned blocks; /* total blocks in file system */
|
||||
unsigned bfree; /* free blocks in fs */
|
||||
unsigned bavail; /* free blocks avail to non-superuser */
|
||||
};
|
||||
|
||||
union statfsres switch (nfsstat status) {
|
||||
case NFS_OK:
|
||||
statfsokres reply;
|
||||
default:
|
||||
void;
|
||||
};
|
||||
|
||||
/*
|
||||
* Remote file service routines
|
||||
*/
|
||||
program NFS_PROGRAM {
|
||||
version NFS_VERSION {
|
||||
void
|
||||
NFSPROC_NULL(void) = 0;
|
||||
|
||||
attrstat
|
||||
NFSPROC_GETATTR(nfs_fh) = 1;
|
||||
|
||||
attrstat
|
||||
NFSPROC_SETATTR(sattrargs) = 2;
|
||||
|
||||
void
|
||||
NFSPROC_ROOT(void) = 3;
|
||||
|
||||
diropres
|
||||
NFSPROC_LOOKUP(diropargs) = 4;
|
||||
|
||||
readlinkres
|
||||
NFSPROC_READLINK(nfs_fh) = 5;
|
||||
|
||||
readres
|
||||
NFSPROC_READ(readargs) = 6;
|
||||
|
||||
void
|
||||
NFSPROC_WRITECACHE(void) = 7;
|
||||
|
||||
attrstat
|
||||
NFSPROC_WRITE(writeargs) = 8;
|
||||
|
||||
diropres
|
||||
NFSPROC_CREATE(createargs) = 9;
|
||||
|
||||
nfsstat
|
||||
NFSPROC_REMOVE(diropargs) = 10;
|
||||
|
||||
nfsstat
|
||||
NFSPROC_RENAME(renameargs) = 11;
|
||||
|
||||
nfsstat
|
||||
NFSPROC_LINK(linkargs) = 12;
|
||||
|
||||
nfsstat
|
||||
NFSPROC_SYMLINK(symlinkargs) = 13;
|
||||
|
||||
diropres
|
||||
NFSPROC_MKDIR(createargs) = 14;
|
||||
|
||||
nfsstat
|
||||
NFSPROC_RMDIR(diropargs) = 15;
|
||||
|
||||
readdirres
|
||||
NFSPROC_READDIR(readdirargs) = 16;
|
||||
|
||||
statfsres
|
||||
NFSPROC_STATFS(nfs_fh) = 17;
|
||||
} = 2;
|
||||
} = 100003;
|
||||
|
||||
/* Mount v2 */
|
||||
|
||||
const MNTPATHLEN = 1024; /* maximum bytes in a pathname argument */
|
||||
const MNTNAMLEN = 255; /* maximum bytes in a name argument */
|
||||
const FHSIZE = 32; /* size in bytes of a file handle */
|
||||
|
||||
/*
|
||||
* The fhandle is the file handle that the server passes to the client.
|
||||
* All file operations are done using the file handles to refer to a file
|
||||
* or a directory. The file handle can contain whatever information the
|
||||
* server needs to distinguish an individual file.
|
||||
*/
|
||||
typedef opaque fhandle[FHSIZE];
|
||||
|
||||
/*
|
||||
* If a status of zero is returned, the call completed successfully, and
|
||||
* a file handle for the directory follows. A non-zero status indicates
|
||||
* some sort of error. The status corresponds with UNIX error numbers.
|
||||
*/
|
||||
union fhstatus switch (unsigned fhs_status) {
|
||||
case 0:
|
||||
fhandle fhs_fhandle;
|
||||
default:
|
||||
void;
|
||||
};
|
||||
|
||||
/*
|
||||
* The type dirpath is the pathname of a directory
|
||||
*/
|
||||
typedef string dirpath<MNTPATHLEN>;
|
||||
|
||||
/*
|
||||
* The type name is used for arbitrary names (hostnames, groupnames)
|
||||
*/
|
||||
typedef string name<MNTNAMLEN>;
|
||||
|
||||
/*
|
||||
* A list of who has what mounted
|
||||
*/
|
||||
typedef struct mountbody *mountlist;
|
||||
struct mountbody {
|
||||
name ml_hostname;
|
||||
dirpath ml_directory;
|
||||
mountlist ml_next;
|
||||
};
|
||||
|
||||
/*
|
||||
* A list of netgroups
|
||||
*/
|
||||
typedef struct groupnode *groups;
|
||||
struct groupnode {
|
||||
name gr_name;
|
||||
groups gr_next;
|
||||
};
|
||||
|
||||
/*
|
||||
* A list of what is exported and to whom
|
||||
*/
|
||||
typedef struct exportnode *exports;
|
||||
struct exportnode {
|
||||
dirpath ex_dir;
|
||||
groups ex_groups;
|
||||
exports ex_next;
|
||||
};
|
||||
|
||||
/*
|
||||
* POSIX pathconf information
|
||||
*/
|
||||
struct ppathcnf {
|
||||
int pc_link_max; /* max links allowed */
|
||||
short pc_max_canon; /* max line len for a tty */
|
||||
short pc_max_input; /* input a tty can eat all at once */
|
||||
short pc_name_max; /* max file name length (dir entry) */
|
||||
short pc_path_max; /* max path name length (/x/y/x/.. ) */
|
||||
short pc_pipe_buf; /* size of a pipe (bytes) */
|
||||
u_char pc_vdisable; /* safe char to turn off c_cc[i] */
|
||||
char pc_xxx; /* alignment padding; cc_t == char */
|
||||
short pc_mask[2]; /* validity and boolean bits */
|
||||
};
|
||||
|
||||
program MOUNTPROG {
|
||||
/*
|
||||
* Version one of the mount protocol communicates with version two
|
||||
* of the NFS protocol. The only connecting point is the fhandle
|
||||
* structure, which is the same for both protocols.
|
||||
*/
|
||||
version MOUNTVERS {
|
||||
/*
|
||||
* Does no work. It is made available in all RPC services
|
||||
* to allow server reponse testing and timing
|
||||
*/
|
||||
void
|
||||
MOUNTPROC_NULL(void) = 0;
|
||||
|
||||
/*
|
||||
* If fhs_status is 0, then fhs_fhandle contains the
|
||||
* file handle for the directory. This file handle may
|
||||
* be used in the NFS protocol. This procedure also adds
|
||||
* a new entry to the mount list for this client mounting
|
||||
* the directory.
|
||||
* Unix authentication required.
|
||||
*/
|
||||
fhstatus
|
||||
MOUNTPROC_MNT(dirpath) = 1;
|
||||
|
||||
/*
|
||||
* Returns the list of remotely mounted filesystems. The
|
||||
* mountlist contains one entry for each hostname and
|
||||
* directory pair.
|
||||
*/
|
||||
mountlist
|
||||
MOUNTPROC_DUMP(void) = 2;
|
||||
|
||||
/*
|
||||
* Removes the mount list entry for the directory
|
||||
* Unix authentication required.
|
||||
*/
|
||||
void
|
||||
MOUNTPROC_UMNT(dirpath) = 3;
|
||||
|
||||
/*
|
||||
* Removes all of the mount list entries for this client
|
||||
* Unix authentication required.
|
||||
*/
|
||||
void
|
||||
MOUNTPROC_UMNTALL(void) = 4;
|
||||
|
||||
/*
|
||||
* Returns a list of all the exported filesystems, and which
|
||||
* machines are allowed to import it.
|
||||
*/
|
||||
exports
|
||||
MOUNTPROC_EXPORT(void) = 5;
|
||||
|
||||
/*
|
||||
* Identical to MOUNTPROC_EXPORT above
|
||||
*/
|
||||
exports
|
||||
MOUNTPROC_EXPORTALL(void) = 6;
|
||||
} = 1;
|
||||
|
||||
/*
|
||||
* Version two of the mount protocol communicates with version two
|
||||
* of the NFS protocol.
|
||||
* The only difference from version one is the addition of a POSIX
|
||||
* pathconf call.
|
||||
*/
|
||||
version MOUNTVERS_POSIX {
|
||||
/*
|
||||
* Does no work. It is made available in all RPC services
|
||||
* to allow server reponse testing and timing
|
||||
*/
|
||||
void
|
||||
MOUNTPROC_NULL(void) = 0;
|
||||
|
||||
/*
|
||||
* If fhs_status is 0, then fhs_fhandle contains the
|
||||
* file handle for the directory. This file handle may
|
||||
* be used in the NFS protocol. This procedure also adds
|
||||
* a new entry to the mount list for this client mounting
|
||||
* the directory.
|
||||
* Unix authentication required.
|
||||
*/
|
||||
fhstatus
|
||||
MOUNTPROC_MNT(dirpath) = 1;
|
||||
|
||||
/*
|
||||
* Returns the list of remotely mounted filesystems. The
|
||||
* mountlist contains one entry for each hostname and
|
||||
* directory pair.
|
||||
*/
|
||||
mountlist
|
||||
MOUNTPROC_DUMP(void) = 2;
|
||||
|
||||
/*
|
||||
* Removes the mount list entry for the directory
|
||||
* Unix authentication required.
|
||||
*/
|
||||
void
|
||||
MOUNTPROC_UMNT(dirpath) = 3;
|
||||
|
||||
/*
|
||||
* Removes all of the mount list entries for this client
|
||||
* Unix authentication required.
|
||||
*/
|
||||
void
|
||||
MOUNTPROC_UMNTALL(void) = 4;
|
||||
|
||||
/*
|
||||
* Returns a list of all the exported filesystems, and which
|
||||
* machines are allowed to import it.
|
||||
*/
|
||||
exports
|
||||
MOUNTPROC_EXPORT(void) = 5;
|
||||
|
||||
/*
|
||||
* Identical to MOUNTPROC_EXPORT above
|
||||
*/
|
||||
exports
|
||||
MOUNTPROC_EXPORTALL(void) = 6;
|
||||
|
||||
/*
|
||||
* POSIX pathconf info (Sun hack)
|
||||
*/
|
||||
ppathcnf
|
||||
MOUNTPROC_PATHCONF(dirpath) = 7;
|
||||
} = 2;
|
||||
} = 100005;
|
||||
|
||||
#ifdef RPC_HDR
|
||||
%#endif /*!_rpcsvc_nfs_prot_h*/
|
||||
#endif
|
|
@ -1,865 +0,0 @@
|
|||
/*
|
||||
* Please do not edit this file.
|
||||
* It was generated using rpcgen.
|
||||
*/
|
||||
|
||||
#include "rpc_nfs2_prot.h"
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
* unrestricted use provided that this legend is included on all tape
|
||||
* media and as a part of the software program in whole or part. Users
|
||||
* may copy or modify Sun RPC without charge, but are not authorized
|
||||
* to license or distribute it to anyone else except as part of a product or
|
||||
* program developed by the user or with the express written consent of
|
||||
* Sun Microsystems, Inc.
|
||||
*
|
||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
||||
*
|
||||
* Sun RPC is provided with no support and without any obligation on the
|
||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
||||
* modification or enhancement.
|
||||
*
|
||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
||||
* OR ANY PART THEREOF.
|
||||
*
|
||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
||||
* or profits or other special, indirect and consequential damages, even if
|
||||
* Sun has been advised of the possibility of such damages.
|
||||
*
|
||||
* Sun Microsystems, Inc.
|
||||
* 2550 Garcia Avenue
|
||||
* Mountain View, California 94043
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1987, 1990 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
/* from @(#)nfs_prot.x 1.3 91/03/11 TIRPC 1.0 */
|
||||
|
||||
bool_t
|
||||
xdr_nfsstat (XDR *xdrs, nfsstat *objp)
|
||||
{
|
||||
if (!xdr_enum (xdrs, (enum_t *) objp))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_ftype (XDR *xdrs, ftype *objp)
|
||||
{
|
||||
if (!xdr_enum (xdrs, (enum_t *) objp))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_nfs_fh (XDR *xdrs, nfs_fh *objp)
|
||||
{
|
||||
if (!xdr_opaque (xdrs, objp->data, NFS_FHSIZE))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_nfstime (XDR *xdrs, nfstime *objp)
|
||||
{
|
||||
if (!xdr_u_int (xdrs, &objp->seconds))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->useconds))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_fattr (XDR *xdrs, fattr *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
|
||||
if (xdrs->x_op == XDR_ENCODE) {
|
||||
if (!xdr_ftype (xdrs, &objp->type))
|
||||
return FALSE;
|
||||
buf = XDR_INLINE (xdrs, 10 * BYTES_PER_XDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!xdr_u_int (xdrs, &objp->mode))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->nlink))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->uid))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->gid))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->size))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->blocksize))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->rdev))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->blocks))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->fsid))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->fileid))
|
||||
return FALSE;
|
||||
|
||||
} else {
|
||||
IXDR_PUT_U_LONG(buf, objp->mode);
|
||||
IXDR_PUT_U_LONG(buf, objp->nlink);
|
||||
IXDR_PUT_U_LONG(buf, objp->uid);
|
||||
IXDR_PUT_U_LONG(buf, objp->gid);
|
||||
IXDR_PUT_U_LONG(buf, objp->size);
|
||||
IXDR_PUT_U_LONG(buf, objp->blocksize);
|
||||
IXDR_PUT_U_LONG(buf, objp->rdev);
|
||||
IXDR_PUT_U_LONG(buf, objp->blocks);
|
||||
IXDR_PUT_U_LONG(buf, objp->fsid);
|
||||
IXDR_PUT_U_LONG(buf, objp->fileid);
|
||||
}
|
||||
if (!xdr_nfstime (xdrs, &objp->atime))
|
||||
return FALSE;
|
||||
if (!xdr_nfstime (xdrs, &objp->mtime))
|
||||
return FALSE;
|
||||
if (!xdr_nfstime (xdrs, &objp->ctime))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
} else if (xdrs->x_op == XDR_DECODE) {
|
||||
if (!xdr_ftype (xdrs, &objp->type))
|
||||
return FALSE;
|
||||
buf = XDR_INLINE (xdrs, 10 * BYTES_PER_XDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!xdr_u_int (xdrs, &objp->mode))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->nlink))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->uid))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->gid))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->size))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->blocksize))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->rdev))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->blocks))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->fsid))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->fileid))
|
||||
return FALSE;
|
||||
|
||||
} else {
|
||||
objp->mode = IXDR_GET_U_LONG(buf);
|
||||
objp->nlink = IXDR_GET_U_LONG(buf);
|
||||
objp->uid = IXDR_GET_U_LONG(buf);
|
||||
objp->gid = IXDR_GET_U_LONG(buf);
|
||||
objp->size = IXDR_GET_U_LONG(buf);
|
||||
objp->blocksize = IXDR_GET_U_LONG(buf);
|
||||
objp->rdev = IXDR_GET_U_LONG(buf);
|
||||
objp->blocks = IXDR_GET_U_LONG(buf);
|
||||
objp->fsid = IXDR_GET_U_LONG(buf);
|
||||
objp->fileid = IXDR_GET_U_LONG(buf);
|
||||
}
|
||||
if (!xdr_nfstime (xdrs, &objp->atime))
|
||||
return FALSE;
|
||||
if (!xdr_nfstime (xdrs, &objp->mtime))
|
||||
return FALSE;
|
||||
if (!xdr_nfstime (xdrs, &objp->ctime))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!xdr_ftype (xdrs, &objp->type))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->mode))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->nlink))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->uid))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->gid))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->size))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->blocksize))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->rdev))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->blocks))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->fsid))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->fileid))
|
||||
return FALSE;
|
||||
if (!xdr_nfstime (xdrs, &objp->atime))
|
||||
return FALSE;
|
||||
if (!xdr_nfstime (xdrs, &objp->mtime))
|
||||
return FALSE;
|
||||
if (!xdr_nfstime (xdrs, &objp->ctime))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_sattr (XDR *xdrs, sattr *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
|
||||
if (xdrs->x_op == XDR_ENCODE) {
|
||||
buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!xdr_u_int (xdrs, &objp->mode))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->uid))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->gid))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->size))
|
||||
return FALSE;
|
||||
|
||||
} else {
|
||||
IXDR_PUT_U_LONG(buf, objp->mode);
|
||||
IXDR_PUT_U_LONG(buf, objp->uid);
|
||||
IXDR_PUT_U_LONG(buf, objp->gid);
|
||||
IXDR_PUT_U_LONG(buf, objp->size);
|
||||
}
|
||||
if (!xdr_nfstime (xdrs, &objp->atime))
|
||||
return FALSE;
|
||||
if (!xdr_nfstime (xdrs, &objp->mtime))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
} else if (xdrs->x_op == XDR_DECODE) {
|
||||
buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!xdr_u_int (xdrs, &objp->mode))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->uid))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->gid))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->size))
|
||||
return FALSE;
|
||||
|
||||
} else {
|
||||
objp->mode = IXDR_GET_U_LONG(buf);
|
||||
objp->uid = IXDR_GET_U_LONG(buf);
|
||||
objp->gid = IXDR_GET_U_LONG(buf);
|
||||
objp->size = IXDR_GET_U_LONG(buf);
|
||||
}
|
||||
if (!xdr_nfstime (xdrs, &objp->atime))
|
||||
return FALSE;
|
||||
if (!xdr_nfstime (xdrs, &objp->mtime))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!xdr_u_int (xdrs, &objp->mode))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->uid))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->gid))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->size))
|
||||
return FALSE;
|
||||
if (!xdr_nfstime (xdrs, &objp->atime))
|
||||
return FALSE;
|
||||
if (!xdr_nfstime (xdrs, &objp->mtime))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_filename (XDR *xdrs, filename *objp)
|
||||
{
|
||||
if (!xdr_string (xdrs, objp, NFS_MAXNAMLEN))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_nfspath (XDR *xdrs, nfspath *objp)
|
||||
{
|
||||
if (!xdr_string (xdrs, objp, NFS_MAXPATHLEN))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_attrstat (XDR *xdrs, attrstat *objp)
|
||||
{
|
||||
if (!xdr_nfsstat (xdrs, &objp->status))
|
||||
return FALSE;
|
||||
switch (objp->status) {
|
||||
case NFS_OK:
|
||||
if (!xdr_fattr (xdrs, &objp->attrstat_u.attributes))
|
||||
return FALSE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_sattrargs (XDR *xdrs, sattrargs *objp)
|
||||
{
|
||||
if (!xdr_nfs_fh (xdrs, &objp->file))
|
||||
return FALSE;
|
||||
if (!xdr_sattr (xdrs, &objp->attributes))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_diropargs (XDR *xdrs, diropargs *objp)
|
||||
{
|
||||
if (!xdr_nfs_fh (xdrs, &objp->dir))
|
||||
return FALSE;
|
||||
if (!xdr_filename (xdrs, &objp->name))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_diropokres (XDR *xdrs, diropokres *objp)
|
||||
{
|
||||
if (!xdr_nfs_fh (xdrs, &objp->file))
|
||||
return FALSE;
|
||||
if (!xdr_fattr (xdrs, &objp->attributes))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_diropres (XDR *xdrs, diropres *objp)
|
||||
{
|
||||
if (!xdr_nfsstat (xdrs, &objp->status))
|
||||
return FALSE;
|
||||
switch (objp->status) {
|
||||
case NFS_OK:
|
||||
if (!xdr_diropokres (xdrs, &objp->diropres_u.diropres))
|
||||
return FALSE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_readlinkres (XDR *xdrs, readlinkres *objp)
|
||||
{
|
||||
if (!xdr_nfsstat (xdrs, &objp->status))
|
||||
return FALSE;
|
||||
switch (objp->status) {
|
||||
case NFS_OK:
|
||||
if (!xdr_nfspath (xdrs, &objp->readlinkres_u.data))
|
||||
return FALSE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_readargs (XDR *xdrs, readargs *objp)
|
||||
{
|
||||
if (!xdr_nfs_fh (xdrs, &objp->file))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->offset))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->count))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->totalcount))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_readokres (XDR *xdrs, readokres *objp)
|
||||
{
|
||||
if (!xdr_fattr (xdrs, &objp->attributes))
|
||||
return FALSE;
|
||||
if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, NFS_MAXDATA))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_readres (XDR *xdrs, readres *objp)
|
||||
{
|
||||
if (!xdr_nfsstat (xdrs, &objp->status))
|
||||
return FALSE;
|
||||
switch (objp->status) {
|
||||
case NFS_OK:
|
||||
if (!xdr_readokres (xdrs, &objp->readres_u.reply))
|
||||
return FALSE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_writeargs (XDR *xdrs, writeargs *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
|
||||
if (xdrs->x_op == XDR_ENCODE) {
|
||||
if (!xdr_nfs_fh (xdrs, &objp->file))
|
||||
return FALSE;
|
||||
buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!xdr_u_int (xdrs, &objp->beginoffset))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->offset))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->totalcount))
|
||||
return FALSE;
|
||||
|
||||
} else {
|
||||
IXDR_PUT_U_LONG(buf, objp->beginoffset);
|
||||
IXDR_PUT_U_LONG(buf, objp->offset);
|
||||
IXDR_PUT_U_LONG(buf, objp->totalcount);
|
||||
}
|
||||
if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, NFS_MAXDATA))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
} else if (xdrs->x_op == XDR_DECODE) {
|
||||
if (!xdr_nfs_fh (xdrs, &objp->file))
|
||||
return FALSE;
|
||||
buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!xdr_u_int (xdrs, &objp->beginoffset))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->offset))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->totalcount))
|
||||
return FALSE;
|
||||
|
||||
} else {
|
||||
objp->beginoffset = IXDR_GET_U_LONG(buf);
|
||||
objp->offset = IXDR_GET_U_LONG(buf);
|
||||
objp->totalcount = IXDR_GET_U_LONG(buf);
|
||||
}
|
||||
if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, NFS_MAXDATA))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!xdr_nfs_fh (xdrs, &objp->file))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->beginoffset))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->offset))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->totalcount))
|
||||
return FALSE;
|
||||
if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, NFS_MAXDATA))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_createargs (XDR *xdrs, createargs *objp)
|
||||
{
|
||||
if (!xdr_diropargs (xdrs, &objp->where))
|
||||
return FALSE;
|
||||
if (!xdr_sattr (xdrs, &objp->attributes))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_renameargs (XDR *xdrs, renameargs *objp)
|
||||
{
|
||||
if (!xdr_diropargs (xdrs, &objp->from))
|
||||
return FALSE;
|
||||
if (!xdr_diropargs (xdrs, &objp->to))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_linkargs (XDR *xdrs, linkargs *objp)
|
||||
{
|
||||
if (!xdr_nfs_fh (xdrs, &objp->from))
|
||||
return FALSE;
|
||||
if (!xdr_diropargs (xdrs, &objp->to))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_symlinkargs (XDR *xdrs, symlinkargs *objp)
|
||||
{
|
||||
if (!xdr_diropargs (xdrs, &objp->from))
|
||||
return FALSE;
|
||||
if (!xdr_nfspath (xdrs, &objp->to))
|
||||
return FALSE;
|
||||
if (!xdr_sattr (xdrs, &objp->attributes))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_nfscookie (XDR *xdrs, nfscookie objp)
|
||||
{
|
||||
if (!xdr_opaque (xdrs, objp, NFS_COOKIESIZE))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_readdirargs (XDR *xdrs, readdirargs *objp)
|
||||
{
|
||||
if (!xdr_nfs_fh (xdrs, &objp->dir))
|
||||
return FALSE;
|
||||
if (!xdr_nfscookie (xdrs, objp->cookie))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->count))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_entry (XDR *xdrs, entry *objp)
|
||||
{
|
||||
if (!xdr_u_int (xdrs, &objp->fileid))
|
||||
return FALSE;
|
||||
if (!xdr_filename (xdrs, &objp->name))
|
||||
return FALSE;
|
||||
if (!xdr_nfscookie (xdrs, objp->cookie))
|
||||
return FALSE;
|
||||
if (!xdr_pointer (xdrs, (char **)&objp->nextentry, sizeof (entry), (xdrproc_t) xdr_entry))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_dirlist (XDR *xdrs, dirlist *objp)
|
||||
{
|
||||
if (!xdr_pointer (xdrs, (char **)&objp->entries, sizeof (entry), (xdrproc_t) xdr_entry))
|
||||
return FALSE;
|
||||
if (!xdr_bool (xdrs, &objp->eof))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_readdirres (XDR *xdrs, readdirres *objp)
|
||||
{
|
||||
if (!xdr_nfsstat (xdrs, &objp->status))
|
||||
return FALSE;
|
||||
switch (objp->status) {
|
||||
case NFS_OK:
|
||||
if (!xdr_dirlist (xdrs, &objp->readdirres_u.reply))
|
||||
return FALSE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_statfsokres (XDR *xdrs, statfsokres *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
|
||||
if (xdrs->x_op == XDR_ENCODE) {
|
||||
buf = XDR_INLINE (xdrs, 5 * BYTES_PER_XDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!xdr_u_int (xdrs, &objp->tsize))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->bsize))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->blocks))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->bfree))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->bavail))
|
||||
return FALSE;
|
||||
} else {
|
||||
IXDR_PUT_U_LONG(buf, objp->tsize);
|
||||
IXDR_PUT_U_LONG(buf, objp->bsize);
|
||||
IXDR_PUT_U_LONG(buf, objp->blocks);
|
||||
IXDR_PUT_U_LONG(buf, objp->bfree);
|
||||
IXDR_PUT_U_LONG(buf, objp->bavail);
|
||||
}
|
||||
return TRUE;
|
||||
} else if (xdrs->x_op == XDR_DECODE) {
|
||||
buf = XDR_INLINE (xdrs, 5 * BYTES_PER_XDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!xdr_u_int (xdrs, &objp->tsize))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->bsize))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->blocks))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->bfree))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->bavail))
|
||||
return FALSE;
|
||||
} else {
|
||||
objp->tsize = IXDR_GET_U_LONG(buf);
|
||||
objp->bsize = IXDR_GET_U_LONG(buf);
|
||||
objp->blocks = IXDR_GET_U_LONG(buf);
|
||||
objp->bfree = IXDR_GET_U_LONG(buf);
|
||||
objp->bavail = IXDR_GET_U_LONG(buf);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!xdr_u_int (xdrs, &objp->tsize))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->bsize))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->blocks))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->bfree))
|
||||
return FALSE;
|
||||
if (!xdr_u_int (xdrs, &objp->bavail))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_statfsres (XDR *xdrs, statfsres *objp)
|
||||
{
|
||||
if (!xdr_nfsstat (xdrs, &objp->status))
|
||||
return FALSE;
|
||||
switch (objp->status) {
|
||||
case NFS_OK:
|
||||
if (!xdr_statfsokres (xdrs, &objp->statfsres_u.reply))
|
||||
return FALSE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_fhandle (XDR *xdrs, fhandle objp)
|
||||
{
|
||||
if (!xdr_opaque (xdrs, objp, FHSIZE))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_fhstatus (XDR *xdrs, fhstatus *objp)
|
||||
{
|
||||
if (!xdr_u_int (xdrs, &objp->fhs_status))
|
||||
return FALSE;
|
||||
switch (objp->fhs_status) {
|
||||
case 0:
|
||||
if (!xdr_fhandle (xdrs, objp->fhstatus_u.fhs_fhandle))
|
||||
return FALSE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_dirpath (XDR *xdrs, dirpath *objp)
|
||||
{
|
||||
if (!xdr_string (xdrs, objp, MNTPATHLEN))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_name (XDR *xdrs, name *objp)
|
||||
{
|
||||
if (!xdr_string (xdrs, objp, MNTNAMLEN))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_mountlist (XDR *xdrs, mountlist *objp)
|
||||
{
|
||||
if (!xdr_pointer (xdrs, (char **)objp, sizeof (struct mountbody), (xdrproc_t) xdr_mountbody))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_mountbody (XDR *xdrs, mountbody *objp)
|
||||
{
|
||||
if (!xdr_name (xdrs, &objp->ml_hostname))
|
||||
return FALSE;
|
||||
if (!xdr_dirpath (xdrs, &objp->ml_directory))
|
||||
return FALSE;
|
||||
if (!xdr_mountlist (xdrs, &objp->ml_next))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_groups (XDR *xdrs, groups *objp)
|
||||
{
|
||||
if (!xdr_pointer (xdrs, (char **)objp, sizeof (struct groupnode), (xdrproc_t) xdr_groupnode))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_groupnode (XDR *xdrs, groupnode *objp)
|
||||
{
|
||||
if (!xdr_name (xdrs, &objp->gr_name))
|
||||
return FALSE;
|
||||
if (!xdr_groups (xdrs, &objp->gr_next))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_exports (XDR *xdrs, exports *objp)
|
||||
{
|
||||
if (!xdr_pointer (xdrs, (char **)objp, sizeof (struct exportnode), (xdrproc_t) xdr_exportnode))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_exportnode (XDR *xdrs, exportnode *objp)
|
||||
{
|
||||
if (!xdr_dirpath (xdrs, &objp->ex_dir))
|
||||
return FALSE;
|
||||
if (!xdr_groups (xdrs, &objp->ex_groups))
|
||||
return FALSE;
|
||||
if (!xdr_exports (xdrs, &objp->ex_next))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_ppathcnf (XDR *xdrs, ppathcnf *objp)
|
||||
{
|
||||
register int32_t *buf;
|
||||
|
||||
int i;
|
||||
|
||||
if (xdrs->x_op == XDR_ENCODE) {
|
||||
buf = XDR_INLINE (xdrs, 6 * BYTES_PER_XDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!xdr_int (xdrs, &objp->pc_link_max))
|
||||
return FALSE;
|
||||
if (!xdr_short (xdrs, &objp->pc_max_canon))
|
||||
return FALSE;
|
||||
if (!xdr_short (xdrs, &objp->pc_max_input))
|
||||
return FALSE;
|
||||
if (!xdr_short (xdrs, &objp->pc_name_max))
|
||||
return FALSE;
|
||||
if (!xdr_short (xdrs, &objp->pc_path_max))
|
||||
return FALSE;
|
||||
if (!xdr_short (xdrs, &objp->pc_pipe_buf))
|
||||
return FALSE;
|
||||
|
||||
} else {
|
||||
IXDR_PUT_LONG(buf, objp->pc_link_max);
|
||||
IXDR_PUT_SHORT(buf, objp->pc_max_canon);
|
||||
IXDR_PUT_SHORT(buf, objp->pc_max_input);
|
||||
IXDR_PUT_SHORT(buf, objp->pc_name_max);
|
||||
IXDR_PUT_SHORT(buf, objp->pc_path_max);
|
||||
IXDR_PUT_SHORT(buf, objp->pc_pipe_buf);
|
||||
}
|
||||
if (!xdr_u_char (xdrs, &objp->pc_vdisable))
|
||||
return FALSE;
|
||||
if (!xdr_char (xdrs, &objp->pc_xxx))
|
||||
return FALSE;
|
||||
buf = XDR_INLINE (xdrs, ( 2 ) * BYTES_PER_XDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!xdr_vector (xdrs, (char *)objp->pc_mask, 2,
|
||||
sizeof (short), (xdrproc_t) xdr_short))
|
||||
return FALSE;
|
||||
} else {
|
||||
{
|
||||
register short *genp;
|
||||
|
||||
for (i = 0, genp = objp->pc_mask;
|
||||
i < 2; ++i) {
|
||||
IXDR_PUT_SHORT(buf, *genp++);
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
} else if (xdrs->x_op == XDR_DECODE) {
|
||||
buf = XDR_INLINE (xdrs, 6 * BYTES_PER_XDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!xdr_int (xdrs, &objp->pc_link_max))
|
||||
return FALSE;
|
||||
if (!xdr_short (xdrs, &objp->pc_max_canon))
|
||||
return FALSE;
|
||||
if (!xdr_short (xdrs, &objp->pc_max_input))
|
||||
return FALSE;
|
||||
if (!xdr_short (xdrs, &objp->pc_name_max))
|
||||
return FALSE;
|
||||
if (!xdr_short (xdrs, &objp->pc_path_max))
|
||||
return FALSE;
|
||||
if (!xdr_short (xdrs, &objp->pc_pipe_buf))
|
||||
return FALSE;
|
||||
|
||||
} else {
|
||||
objp->pc_link_max = IXDR_GET_LONG(buf);
|
||||
objp->pc_max_canon = IXDR_GET_SHORT(buf);
|
||||
objp->pc_max_input = IXDR_GET_SHORT(buf);
|
||||
objp->pc_name_max = IXDR_GET_SHORT(buf);
|
||||
objp->pc_path_max = IXDR_GET_SHORT(buf);
|
||||
objp->pc_pipe_buf = IXDR_GET_SHORT(buf);
|
||||
}
|
||||
if (!xdr_u_char (xdrs, &objp->pc_vdisable))
|
||||
return FALSE;
|
||||
if (!xdr_char (xdrs, &objp->pc_xxx))
|
||||
return FALSE;
|
||||
buf = XDR_INLINE (xdrs, ( 2 ) * BYTES_PER_XDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!xdr_vector (xdrs, (char *)objp->pc_mask, 2,
|
||||
sizeof (short), (xdrproc_t) xdr_short))
|
||||
return FALSE;
|
||||
} else {
|
||||
{
|
||||
register short *genp;
|
||||
|
||||
for (i = 0, genp = objp->pc_mask;
|
||||
i < 2; ++i) {
|
||||
*genp++ = IXDR_GET_SHORT(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!xdr_int (xdrs, &objp->pc_link_max))
|
||||
return FALSE;
|
||||
if (!xdr_short (xdrs, &objp->pc_max_canon))
|
||||
return FALSE;
|
||||
if (!xdr_short (xdrs, &objp->pc_max_input))
|
||||
return FALSE;
|
||||
if (!xdr_short (xdrs, &objp->pc_name_max))
|
||||
return FALSE;
|
||||
if (!xdr_short (xdrs, &objp->pc_path_max))
|
||||
return FALSE;
|
||||
if (!xdr_short (xdrs, &objp->pc_pipe_buf))
|
||||
return FALSE;
|
||||
if (!xdr_u_char (xdrs, &objp->pc_vdisable))
|
||||
return FALSE;
|
||||
if (!xdr_char (xdrs, &objp->pc_xxx))
|
||||
return FALSE;
|
||||
if (!xdr_vector (xdrs, (char *)objp->pc_mask, 2,
|
||||
sizeof (short), (xdrproc_t) xdr_short))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,920 +0,0 @@
|
|||
/*
|
||||
* To compile this file into the proper files:
|
||||
* rpcgen -C -N nfs.x
|
||||
* rpcgen -C -N -m nfs.x > programs.c
|
||||
* rpcgen -C -N -s tcp nfs.x > run_example.c
|
||||
* rpcgen -C -N -Ss nfs.x > server_template.c
|
||||
* rm nfs_clnt.c nfs_svc.c
|
||||
* mv nfs_xdr.c xdr.c
|
||||
*/
|
||||
|
||||
const PROGRAM = 100003;
|
||||
const VERSION = 3;
|
||||
const NFS3_FHSIZE = 64;
|
||||
const NFS3_COOKIEVERFSIZE = 8;
|
||||
const NFS3_CREATEVERFSIZE = 8;
|
||||
const NFS3_WRITEVERFSIZE = 8;
|
||||
|
||||
%#if defined(HAVE_XDR_U_INT64_T)
|
||||
%#define xdr_uint64_t xdr_u_int64_t
|
||||
%#elif !defined(HAVE_XDR_UINT64_T)
|
||||
%#if defined(HAVE_XDR_U_HYPER)
|
||||
%#define xdr_uint64_t xdr_u_hyper
|
||||
%#define xdr_int64_t xdr_hyper
|
||||
%#elif defined(HAVE_XDR_U_LONGLONG_T)
|
||||
%#define xdr_uint64_t xdr_u_longlong_t
|
||||
%#define xdr_int64_t xdr_longlong_t
|
||||
%#endif
|
||||
%#endif
|
||||
|
||||
typedef uint64_t uint64;
|
||||
typedef int64_t int64;
|
||||
typedef unsigned long uint32;
|
||||
typedef long int32;
|
||||
typedef string filename3<>;
|
||||
typedef string nfspath3<>;
|
||||
typedef uint64 fileid3;
|
||||
typedef uint64 cookie3;
|
||||
typedef opaque cookieverf3[NFS3_COOKIEVERFSIZE];
|
||||
typedef opaque createverf3[NFS3_CREATEVERFSIZE];
|
||||
typedef opaque writeverf3[NFS3_WRITEVERFSIZE];
|
||||
typedef uint32 uid3;
|
||||
typedef uint32 gid3;
|
||||
typedef uint64 size3;
|
||||
typedef uint64 offset3;
|
||||
typedef uint32 mode3;
|
||||
typedef uint32 count3;
|
||||
|
||||
enum nfsstat3 {
|
||||
NFS3_OK = 0,
|
||||
NFS3ERR_PERM = 1,
|
||||
NFS3ERR_NOENT = 2,
|
||||
NFS3ERR_IO = 5,
|
||||
NFS3ERR_NXIO = 6,
|
||||
NFS3ERR_ACCES = 13,
|
||||
NFS3ERR_EXIST = 17,
|
||||
NFS3ERR_XDEV = 18,
|
||||
NFS3ERR_NODEV = 19,
|
||||
NFS3ERR_NOTDIR = 20,
|
||||
NFS3ERR_ISDIR = 21,
|
||||
NFS3ERR_INVAL = 22,
|
||||
NFS3ERR_FBIG = 27,
|
||||
NFS3ERR_NOSPC = 28,
|
||||
NFS3ERR_ROFS = 30,
|
||||
NFS3ERR_MLINK = 31,
|
||||
NFS3ERR_NAMETOOLONG = 63,
|
||||
NFS3ERR_NOTEMPTY = 66,
|
||||
NFS3ERR_DQUOT = 69,
|
||||
NFS3ERR_STALE = 70,
|
||||
NFS3ERR_REMOTE = 71,
|
||||
NFS3ERR_BADHANDLE = 10001,
|
||||
|
||||
NFS3ERR_NOT_SYNC = 10002,
|
||||
NFS3ERR_BAD_COOKIE = 10003,
|
||||
NFS3ERR_NOTSUPP = 10004,
|
||||
NFS3ERR_TOOSMALL = 10005,
|
||||
NFS3ERR_SERVERFAULT = 10006,
|
||||
NFS3ERR_BADTYPE = 10007,
|
||||
NFS3ERR_JUKEBOX = 10008
|
||||
};
|
||||
|
||||
enum ftype3 {
|
||||
NF3REG = 1,
|
||||
NF3DIR = 2,
|
||||
NF3BLK = 3,
|
||||
NF3CHR = 4,
|
||||
NF3LNK = 5,
|
||||
NF3SOCK = 6,
|
||||
NF3FIFO = 7
|
||||
};
|
||||
|
||||
struct specdata3 {
|
||||
uint32 specdata1;
|
||||
uint32 specdata2;
|
||||
};
|
||||
|
||||
struct nfs_fh3 {
|
||||
opaque data<NFS3_FHSIZE>;
|
||||
};
|
||||
|
||||
struct nfstime3 {
|
||||
uint32 seconds;
|
||||
uint32 nseconds;
|
||||
};
|
||||
|
||||
struct fattr3 {
|
||||
ftype3 type;
|
||||
mode3 mode;
|
||||
uint32 nlink;
|
||||
uid3 uid;
|
||||
gid3 gid;
|
||||
size3 size;
|
||||
size3 used;
|
||||
specdata3 rdev;
|
||||
uint64 fsid;
|
||||
fileid3 fileid;
|
||||
nfstime3 atime;
|
||||
nfstime3 mtime;
|
||||
nfstime3 ctime;
|
||||
};
|
||||
|
||||
union post_op_attr switch (bool attributes_follow) {
|
||||
case TRUE:
|
||||
fattr3 attributes;
|
||||
case FALSE:
|
||||
void;
|
||||
};
|
||||
|
||||
struct wcc_attr {
|
||||
size3 size;
|
||||
nfstime3 mtime;
|
||||
nfstime3 ctime;
|
||||
};
|
||||
|
||||
union pre_op_attr switch (bool attributes_follow) {
|
||||
case TRUE:
|
||||
wcc_attr attributes;
|
||||
case FALSE:
|
||||
void;
|
||||
};
|
||||
|
||||
struct wcc_data {
|
||||
pre_op_attr before;
|
||||
post_op_attr after;
|
||||
};
|
||||
|
||||
union post_op_fh3 switch (bool handle_follows) {
|
||||
case TRUE:
|
||||
nfs_fh3 handle;
|
||||
case FALSE:
|
||||
void;
|
||||
};
|
||||
|
||||
enum time_how {
|
||||
DONT_CHANGE = 0,
|
||||
SET_TO_SERVER_TIME = 1,
|
||||
SET_TO_CLIENT_TIME = 2
|
||||
};
|
||||
|
||||
union set_mode3 switch (bool set_it) {
|
||||
case TRUE:
|
||||
mode3 mode;
|
||||
default:
|
||||
void;
|
||||
};
|
||||
|
||||
union set_uid3 switch (bool set_it) {
|
||||
case TRUE:
|
||||
uid3 uid;
|
||||
default:
|
||||
void;
|
||||
};
|
||||
|
||||
union set_gid3 switch (bool set_it) {
|
||||
case TRUE:
|
||||
gid3 gid;
|
||||
default:
|
||||
void;
|
||||
};
|
||||
|
||||
union set_size3 switch (bool set_it) {
|
||||
case TRUE:
|
||||
size3 size;
|
||||
default:
|
||||
void;
|
||||
};
|
||||
|
||||
union set_atime switch (time_how set_it) {
|
||||
case SET_TO_CLIENT_TIME:
|
||||
nfstime3 atime;
|
||||
default:
|
||||
void;
|
||||
};
|
||||
|
||||
union set_mtime switch (time_how set_it) {
|
||||
case SET_TO_CLIENT_TIME:
|
||||
nfstime3 mtime;
|
||||
default:
|
||||
void;
|
||||
};
|
||||
|
||||
struct sattr3 {
|
||||
set_mode3 mode;
|
||||
set_uid3 uid;
|
||||
set_gid3 gid;
|
||||
set_size3 size;
|
||||
set_atime atime;
|
||||
set_mtime mtime;
|
||||
|
||||
};
|
||||
|
||||
struct diropargs3 {
|
||||
nfs_fh3 dir;
|
||||
filename3 name;
|
||||
};
|
||||
|
||||
|
||||
program NFS_PROGRAM {
|
||||
version NFS_V3 {
|
||||
|
||||
void
|
||||
NFSPROC3_NULL(void) = 0;
|
||||
|
||||
GETATTR3res
|
||||
NFSPROC3_GETATTR(GETATTR3args) = 1;
|
||||
|
||||
SETATTR3res
|
||||
NFSPROC3_SETATTR(SETATTR3args) = 2;
|
||||
|
||||
LOOKUP3res
|
||||
NFSPROC3_LOOKUP(LOOKUP3args) = 3;
|
||||
|
||||
ACCESS3res
|
||||
NFSPROC3_ACCESS(ACCESS3args) = 4;
|
||||
|
||||
READLINK3res
|
||||
NFSPROC3_READLINK(READLINK3args) = 5;
|
||||
|
||||
READ3res
|
||||
NFSPROC3_READ(READ3args) = 6;
|
||||
|
||||
WRITE3res
|
||||
NFSPROC3_WRITE(WRITE3args) = 7;
|
||||
|
||||
CREATE3res
|
||||
NFSPROC3_CREATE(CREATE3args) = 8;
|
||||
|
||||
MKDIR3res
|
||||
NFSPROC3_MKDIR(MKDIR3args) = 9;
|
||||
|
||||
SYMLINK3res
|
||||
NFSPROC3_SYMLINK(SYMLINK3args) = 10;
|
||||
|
||||
MKNOD3res
|
||||
NFSPROC3_MKNOD(MKNOD3args) = 11;
|
||||
|
||||
REMOVE3res
|
||||
NFSPROC3_REMOVE(REMOVE3args) = 12;
|
||||
|
||||
RMDIR3res
|
||||
NFSPROC3_RMDIR(RMDIR3args) = 13;
|
||||
|
||||
RENAME3res
|
||||
NFSPROC3_RENAME(RENAME3args) = 14;
|
||||
|
||||
LINK3res
|
||||
NFSPROC3_LINK(LINK3args) = 15;
|
||||
|
||||
READDIR3res
|
||||
NFSPROC3_READDIR(READDIR3args) = 16;
|
||||
|
||||
READDIRPLUS3res
|
||||
NFSPROC3_READDIRPLUS(READDIRPLUS3args) = 17;
|
||||
|
||||
FSSTAT3res
|
||||
NFSPROC3_FSSTAT(FSSTAT3args) = 18;
|
||||
|
||||
FSINFO3res
|
||||
NFSPROC3_FSINFO(FSINFO3args) = 19;
|
||||
|
||||
PATHCONF3res
|
||||
NFSPROC3_PATHCONF(PATHCONF3args) = 20;
|
||||
|
||||
COMMIT3res
|
||||
NFSPROC3_COMMIT(COMMIT3args) = 21;
|
||||
|
||||
} = 3;
|
||||
} = 100003;
|
||||
|
||||
struct GETATTR3args {
|
||||
nfs_fh3 object;
|
||||
};
|
||||
|
||||
struct GETATTR3resok {
|
||||
fattr3 obj_attributes;
|
||||
};
|
||||
|
||||
union GETATTR3res switch (nfsstat3 status) {
|
||||
case NFS3_OK:
|
||||
GETATTR3resok resok;
|
||||
default:
|
||||
void;
|
||||
};
|
||||
|
||||
union sattrguard3 switch (bool check) {
|
||||
case TRUE:
|
||||
nfstime3 obj_ctime;
|
||||
case FALSE:
|
||||
void;
|
||||
};
|
||||
|
||||
struct SETATTR3args {
|
||||
nfs_fh3 object;
|
||||
sattr3 new_attributes;
|
||||
sattrguard3 guard;
|
||||
};
|
||||
|
||||
struct SETATTR3resok {
|
||||
wcc_data obj_wcc;
|
||||
};
|
||||
|
||||
struct SETATTR3resfail {
|
||||
wcc_data obj_wcc;
|
||||
};
|
||||
|
||||
union SETATTR3res switch (nfsstat3 status) {
|
||||
case NFS3_OK:
|
||||
SETATTR3resok resok;
|
||||
default:
|
||||
SETATTR3resfail resfail;
|
||||
};
|
||||
|
||||
struct LOOKUP3args {
|
||||
diropargs3 what;
|
||||
};
|
||||
|
||||
struct LOOKUP3resok {
|
||||
nfs_fh3 object;
|
||||
post_op_attr obj_attributes;
|
||||
post_op_attr dir_attributes;
|
||||
};
|
||||
|
||||
struct LOOKUP3resfail {
|
||||
post_op_attr dir_attributes;
|
||||
};
|
||||
|
||||
union LOOKUP3res switch (nfsstat3 status) {
|
||||
case NFS3_OK:
|
||||
LOOKUP3resok resok;
|
||||
default:
|
||||
LOOKUP3resfail resfail;
|
||||
};
|
||||
|
||||
|
||||
const ACCESS3_READ = 0x0001;
|
||||
const ACCESS3_LOOKUP = 0x0002;
|
||||
const ACCESS3_MODIFY = 0x0004;
|
||||
const ACCESS3_EXTEND = 0x0008;
|
||||
const ACCESS3_DELETE = 0x0010;
|
||||
const ACCESS3_EXECUTE = 0x0020;
|
||||
|
||||
struct ACCESS3args {
|
||||
nfs_fh3 object;
|
||||
uint32 access;
|
||||
};
|
||||
|
||||
struct ACCESS3resok {
|
||||
post_op_attr obj_attributes;
|
||||
uint32 access;
|
||||
};
|
||||
|
||||
struct ACCESS3resfail {
|
||||
post_op_attr obj_attributes;
|
||||
};
|
||||
|
||||
union ACCESS3res switch (nfsstat3 status) {
|
||||
case NFS3_OK:
|
||||
ACCESS3resok resok;
|
||||
default:
|
||||
ACCESS3resfail resfail;
|
||||
};
|
||||
|
||||
struct READLINK3args {
|
||||
nfs_fh3 symlink;
|
||||
};
|
||||
|
||||
struct READLINK3resok {
|
||||
post_op_attr symlink_attributes;
|
||||
nfspath3 data;
|
||||
};
|
||||
|
||||
struct READLINK3resfail {
|
||||
post_op_attr symlink_attributes;
|
||||
};
|
||||
|
||||
union READLINK3res switch (nfsstat3 status) {
|
||||
case NFS3_OK:
|
||||
READLINK3resok resok;
|
||||
default:
|
||||
READLINK3resfail resfail;
|
||||
};
|
||||
|
||||
struct READ3args {
|
||||
nfs_fh3 file;
|
||||
offset3 offset;
|
||||
count3 count;
|
||||
};
|
||||
|
||||
struct READ3resok {
|
||||
post_op_attr file_attributes;
|
||||
count3 count;
|
||||
bool eof;
|
||||
opaque data<>;
|
||||
};
|
||||
|
||||
struct READ3resfail {
|
||||
post_op_attr file_attributes;
|
||||
};
|
||||
|
||||
union READ3res switch (nfsstat3 status) {
|
||||
case NFS3_OK:
|
||||
READ3resok resok;
|
||||
default:
|
||||
READ3resfail resfail;
|
||||
};
|
||||
|
||||
enum stable_how {
|
||||
UNSTABLE = 0,
|
||||
DATA_SYNC = 1,
|
||||
FILE_SYNC = 2
|
||||
};
|
||||
|
||||
struct WRITE3args {
|
||||
nfs_fh3 file;
|
||||
offset3 offset;
|
||||
count3 count;
|
||||
stable_how stable;
|
||||
opaque data<>;
|
||||
};
|
||||
|
||||
struct WRITE3resok {
|
||||
wcc_data file_wcc;
|
||||
count3 count;
|
||||
stable_how committed;
|
||||
writeverf3 verf;
|
||||
};
|
||||
|
||||
struct WRITE3resfail {
|
||||
wcc_data file_wcc;
|
||||
};
|
||||
|
||||
union WRITE3res switch (nfsstat3 status) {
|
||||
case NFS3_OK:
|
||||
WRITE3resok resok;
|
||||
default:
|
||||
WRITE3resfail resfail;
|
||||
};
|
||||
|
||||
|
||||
enum createmode3 {
|
||||
UNCHECKED = 0,
|
||||
GUARDED = 1,
|
||||
EXCLUSIVE = 2
|
||||
};
|
||||
|
||||
union createhow3 switch (createmode3 mode) {
|
||||
case UNCHECKED:
|
||||
case GUARDED:
|
||||
sattr3 obj_attributes;
|
||||
case EXCLUSIVE:
|
||||
createverf3 verf;
|
||||
};
|
||||
|
||||
struct CREATE3args {
|
||||
diropargs3 where;
|
||||
createhow3 how;
|
||||
};
|
||||
|
||||
struct CREATE3resok {
|
||||
post_op_fh3 obj;
|
||||
post_op_attr obj_attributes;
|
||||
wcc_data dir_wcc;
|
||||
};
|
||||
|
||||
struct CREATE3resfail {
|
||||
wcc_data dir_wcc;
|
||||
};
|
||||
|
||||
union CREATE3res switch (nfsstat3 status) {
|
||||
case NFS3_OK:
|
||||
CREATE3resok resok;
|
||||
default:
|
||||
CREATE3resfail resfail;
|
||||
};
|
||||
|
||||
|
||||
struct MKDIR3args {
|
||||
diropargs3 where;
|
||||
sattr3 attributes;
|
||||
};
|
||||
|
||||
struct MKDIR3resok {
|
||||
post_op_fh3 obj;
|
||||
post_op_attr obj_attributes;
|
||||
wcc_data dir_wcc;
|
||||
};
|
||||
|
||||
struct MKDIR3resfail {
|
||||
wcc_data dir_wcc;
|
||||
};
|
||||
|
||||
union MKDIR3res switch (nfsstat3 status) {
|
||||
case NFS3_OK:
|
||||
MKDIR3resok resok;
|
||||
default:
|
||||
MKDIR3resfail resfail;
|
||||
};
|
||||
|
||||
|
||||
struct symlinkdata3 {
|
||||
sattr3 symlink_attributes;
|
||||
nfspath3 symlink_data;
|
||||
};
|
||||
|
||||
struct SYMLINK3args {
|
||||
diropargs3 where;
|
||||
symlinkdata3 symlink;
|
||||
};
|
||||
|
||||
struct SYMLINK3resok {
|
||||
post_op_fh3 obj;
|
||||
post_op_attr obj_attributes;
|
||||
wcc_data dir_wcc;
|
||||
};
|
||||
|
||||
struct SYMLINK3resfail {
|
||||
wcc_data dir_wcc;
|
||||
};
|
||||
|
||||
union SYMLINK3res switch (nfsstat3 status) {
|
||||
case NFS3_OK:
|
||||
SYMLINK3resok resok;
|
||||
default:
|
||||
SYMLINK3resfail resfail;
|
||||
};
|
||||
|
||||
|
||||
struct devicedata3 {
|
||||
sattr3 dev_attributes;
|
||||
specdata3 spec;
|
||||
};
|
||||
|
||||
union mknoddata3 switch (ftype3 type) {
|
||||
case NF3CHR:
|
||||
case NF3BLK:
|
||||
devicedata3 device;
|
||||
case NF3SOCK:
|
||||
case NF3FIFO:
|
||||
sattr3 pipe_attributes;
|
||||
default:
|
||||
void;
|
||||
};
|
||||
|
||||
struct MKNOD3args {
|
||||
diropargs3 where;
|
||||
mknoddata3 what;
|
||||
};
|
||||
|
||||
struct MKNOD3resok {
|
||||
post_op_fh3 obj;
|
||||
post_op_attr obj_attributes;
|
||||
wcc_data dir_wcc;
|
||||
};
|
||||
|
||||
struct MKNOD3resfail {
|
||||
wcc_data dir_wcc;
|
||||
};
|
||||
|
||||
union MKNOD3res switch (nfsstat3 status) {
|
||||
case NFS3_OK:
|
||||
MKNOD3resok resok;
|
||||
default:
|
||||
MKNOD3resfail resfail;
|
||||
};
|
||||
|
||||
struct REMOVE3args {
|
||||
diropargs3 object;
|
||||
};
|
||||
|
||||
struct REMOVE3resok {
|
||||
wcc_data dir_wcc;
|
||||
};
|
||||
|
||||
struct REMOVE3resfail {
|
||||
wcc_data dir_wcc;
|
||||
};
|
||||
|
||||
union REMOVE3res switch (nfsstat3 status) {
|
||||
case NFS3_OK:
|
||||
REMOVE3resok resok;
|
||||
default:
|
||||
REMOVE3resfail resfail;
|
||||
};
|
||||
|
||||
|
||||
struct RMDIR3args {
|
||||
diropargs3 object;
|
||||
};
|
||||
|
||||
struct RMDIR3resok {
|
||||
wcc_data dir_wcc;
|
||||
};
|
||||
|
||||
struct RMDIR3resfail {
|
||||
wcc_data dir_wcc;
|
||||
};
|
||||
|
||||
union RMDIR3res switch (nfsstat3 status) {
|
||||
case NFS3_OK:
|
||||
RMDIR3resok resok;
|
||||
default:
|
||||
RMDIR3resfail resfail;
|
||||
};
|
||||
|
||||
struct RENAME3args {
|
||||
diropargs3 from;
|
||||
diropargs3 to;
|
||||
};
|
||||
|
||||
struct RENAME3resok {
|
||||
wcc_data fromdir_wcc;
|
||||
wcc_data todir_wcc;
|
||||
};
|
||||
|
||||
struct RENAME3resfail {
|
||||
wcc_data fromdir_wcc;
|
||||
wcc_data todir_wcc;
|
||||
};
|
||||
|
||||
union RENAME3res switch (nfsstat3 status) {
|
||||
case NFS3_OK:
|
||||
RENAME3resok resok;
|
||||
default:
|
||||
RENAME3resfail resfail;
|
||||
};
|
||||
|
||||
struct LINK3args {
|
||||
nfs_fh3 file;
|
||||
diropargs3 link;
|
||||
};
|
||||
|
||||
struct LINK3resok {
|
||||
post_op_attr file_attributes;
|
||||
wcc_data linkdir_wcc;
|
||||
};
|
||||
|
||||
struct LINK3resfail {
|
||||
post_op_attr file_attributes;
|
||||
wcc_data linkdir_wcc;
|
||||
};
|
||||
|
||||
union LINK3res switch (nfsstat3 status) {
|
||||
case NFS3_OK:
|
||||
|
||||
LINK3resok resok;
|
||||
default:
|
||||
LINK3resfail resfail;
|
||||
};
|
||||
|
||||
struct READDIR3args {
|
||||
nfs_fh3 dir;
|
||||
cookie3 cookie;
|
||||
cookieverf3 cookieverf;
|
||||
count3 count;
|
||||
};
|
||||
|
||||
struct entry3 {
|
||||
fileid3 fileid;
|
||||
filename3 name;
|
||||
cookie3 cookie;
|
||||
entry3 *nextentry;
|
||||
};
|
||||
|
||||
struct dirlist3 {
|
||||
entry3 *entries;
|
||||
bool eof;
|
||||
};
|
||||
|
||||
struct READDIR3resok {
|
||||
post_op_attr dir_attributes;
|
||||
cookieverf3 cookieverf;
|
||||
dirlist3 reply;
|
||||
};
|
||||
|
||||
struct READDIR3resfail {
|
||||
post_op_attr dir_attributes;
|
||||
};
|
||||
|
||||
union READDIR3res switch (nfsstat3 status) {
|
||||
case NFS3_OK:
|
||||
READDIR3resok resok;
|
||||
default:
|
||||
READDIR3resfail resfail;
|
||||
};
|
||||
|
||||
struct READDIRPLUS3args {
|
||||
nfs_fh3 dir;
|
||||
cookie3 cookie;
|
||||
cookieverf3 cookieverf;
|
||||
count3 dircount;
|
||||
count3 maxcount;
|
||||
};
|
||||
|
||||
struct entryplus3 {
|
||||
fileid3 fileid;
|
||||
filename3 name;
|
||||
cookie3 cookie;
|
||||
post_op_attr name_attributes;
|
||||
post_op_fh3 name_handle;
|
||||
entryplus3 *nextentry;
|
||||
};
|
||||
|
||||
struct dirlistplus3 {
|
||||
entryplus3 *entries;
|
||||
bool eof;
|
||||
};
|
||||
|
||||
struct READDIRPLUS3resok {
|
||||
post_op_attr dir_attributes;
|
||||
cookieverf3 cookieverf;
|
||||
dirlistplus3 reply;
|
||||
};
|
||||
|
||||
struct READDIRPLUS3resfail {
|
||||
post_op_attr dir_attributes;
|
||||
};
|
||||
|
||||
union READDIRPLUS3res switch (nfsstat3 status) {
|
||||
case NFS3_OK:
|
||||
READDIRPLUS3resok resok;
|
||||
default:
|
||||
READDIRPLUS3resfail resfail;
|
||||
};
|
||||
|
||||
struct FSSTAT3args {
|
||||
nfs_fh3 fsroot;
|
||||
};
|
||||
|
||||
struct FSSTAT3resok {
|
||||
post_op_attr obj_attributes;
|
||||
size3 tbytes;
|
||||
size3 fbytes;
|
||||
size3 abytes;
|
||||
size3 tfiles;
|
||||
size3 ffiles;
|
||||
size3 afiles;
|
||||
uint32 invarsec;
|
||||
};
|
||||
|
||||
struct FSSTAT3resfail {
|
||||
post_op_attr obj_attributes;
|
||||
};
|
||||
|
||||
union FSSTAT3res switch (nfsstat3 status) {
|
||||
case NFS3_OK:
|
||||
FSSTAT3resok resok;
|
||||
default:
|
||||
FSSTAT3resfail resfail;
|
||||
};
|
||||
|
||||
const FSF3_LINK = 0x0001;
|
||||
const FSF3_SYMLINK = 0x0002;
|
||||
const FSF3_HOMOGENEOUS = 0x0008;
|
||||
const FSF3_CANSETTIME = 0x0010;
|
||||
|
||||
struct FSINFO3args {
|
||||
nfs_fh3 fsroot;
|
||||
};
|
||||
|
||||
struct FSINFO3resok {
|
||||
post_op_attr obj_attributes;
|
||||
uint32 rtmax;
|
||||
uint32 rtpref;
|
||||
uint32 rtmult;
|
||||
uint32 wtmax;
|
||||
uint32 wtpref;
|
||||
uint32 wtmult;
|
||||
uint32 dtpref;
|
||||
|
||||
size3 maxfilesize;
|
||||
nfstime3 time_delta;
|
||||
uint32 properties;
|
||||
};
|
||||
|
||||
struct FSINFO3resfail {
|
||||
post_op_attr obj_attributes;
|
||||
};
|
||||
|
||||
union FSINFO3res switch (nfsstat3 status) {
|
||||
case NFS3_OK:
|
||||
FSINFO3resok resok;
|
||||
default:
|
||||
FSINFO3resfail resfail;
|
||||
};
|
||||
|
||||
struct PATHCONF3args {
|
||||
nfs_fh3 object;
|
||||
};
|
||||
|
||||
struct PATHCONF3resok {
|
||||
post_op_attr obj_attributes;
|
||||
uint32 linkmax;
|
||||
uint32 name_max;
|
||||
bool no_trunc;
|
||||
bool chown_restricted;
|
||||
bool case_insensitive;
|
||||
bool case_preserving;
|
||||
};
|
||||
|
||||
struct PATHCONF3resfail {
|
||||
post_op_attr obj_attributes;
|
||||
};
|
||||
|
||||
union PATHCONF3res switch (nfsstat3 status) {
|
||||
case NFS3_OK:
|
||||
PATHCONF3resok resok;
|
||||
default:
|
||||
PATHCONF3resfail resfail;
|
||||
};
|
||||
|
||||
struct COMMIT3args {
|
||||
nfs_fh3 file;
|
||||
offset3 offset;
|
||||
count3 count;
|
||||
};
|
||||
|
||||
struct COMMIT3resok {
|
||||
wcc_data file_wcc;
|
||||
writeverf3 verf;
|
||||
};
|
||||
|
||||
struct COMMIT3resfail {
|
||||
wcc_data file_wcc;
|
||||
};
|
||||
|
||||
union COMMIT3res switch (nfsstat3 status) {
|
||||
case NFS3_OK:
|
||||
COMMIT3resok resok;
|
||||
default:
|
||||
COMMIT3resfail resfail;
|
||||
};
|
||||
|
||||
|
||||
const MNTPATHLEN3 = 1024; /* Maximum bytes in a path name */
|
||||
const MNTNAMLEN3 = 255; /* Maximum bytes in a name */
|
||||
const FHSIZE3 = 64; /* Maximum bytes in a V3 file handle */
|
||||
|
||||
typedef opaque fhandle3<FHSIZE3>;
|
||||
typedef string dirpath3<MNTPATHLEN3>;
|
||||
typedef string name3<MNTNAMLEN3>;
|
||||
|
||||
enum mountstat3 {
|
||||
MNT3_OK = 0, /* no error */
|
||||
MNT3ERR_PERM = 1, /* Not owner */
|
||||
MNT3ERR_NOENT = 2, /* No such file or directory */
|
||||
MNT3ERR_IO = 5, /* I/O error */
|
||||
MNT3ERR_ACCES = 13, /* Permission denied */
|
||||
MNT3ERR_NOTDIR = 20, /* Not a directory */
|
||||
MNT3ERR_INVAL = 22, /* Invalid argument */
|
||||
MNT3ERR_NAMETOOLONG = 63, /* Filename too long */
|
||||
MNT3ERR_NOTSUPP = 10004, /* Operation not supported */
|
||||
MNT3ERR_SERVERFAULT = 10006 /* A failure on the server */
|
||||
};
|
||||
|
||||
|
||||
program MOUNT_PROGRAM {
|
||||
version MOUNT_V3 {
|
||||
void MOUNTPROC3_NULL(void) = 0;
|
||||
mountres3 MOUNTPROC3_MNT(dirpath3) = 1;
|
||||
mountlist3 MOUNTPROC3_DUMP(void) = 2;
|
||||
void MOUNTPROC3_UMNT(dirpath3) = 3;
|
||||
void MOUNTPROC3_UMNTALL(void) = 4;
|
||||
exports3 MOUNTPROC3_EXPORT(void) = 5;
|
||||
} = 3;
|
||||
} = 100005;
|
||||
|
||||
struct mountres3_ok {
|
||||
fhandle3 fhandle;
|
||||
int auth_flavors<>;
|
||||
};
|
||||
|
||||
union mountres3 switch (mountstat3 fhs_status) {
|
||||
case MNT3_OK:
|
||||
mountres3_ok mountinfo;
|
||||
default:
|
||||
void;
|
||||
};
|
||||
|
||||
typedef struct mountbody3 *mountlist3;
|
||||
|
||||
struct mountbody3 {
|
||||
name3 ml_hostname;
|
||||
dirpath3 ml_directory;
|
||||
mountlist3 ml_next;
|
||||
};
|
||||
|
||||
|
||||
typedef struct groupnode3 *groups3;
|
||||
|
||||
struct groupnode3 {
|
||||
name3 gr_name;
|
||||
groups3 gr_next;
|
||||
};
|
||||
|
||||
typedef struct exportnode3 *exports3;
|
||||
|
||||
struct exportnode3 {
|
||||
dirpath3 ex_dir;
|
||||
groups3 ex_groups;
|
||||
exports3 ex_next;
|
||||
};
|
File diff suppressed because it is too large
Load diff
|
@ -1,30 +0,0 @@
|
|||
check_include_files(utime.h HAVE_UTIME_H)
|
||||
|
||||
configure_file(config-smb.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-smb.h)
|
||||
|
||||
set(kio_smb_PART_SRCS
|
||||
kio_smb.cpp
|
||||
kio_smb_auth.cpp
|
||||
kio_smb_browse.cpp
|
||||
kio_smb_config.cpp
|
||||
kio_smb_dir.cpp
|
||||
kio_smb_file.cpp
|
||||
kio_smb_internal.cpp
|
||||
kio_smb_mount.cpp
|
||||
)
|
||||
|
||||
include_directories(${SAMBA_INCLUDE_DIR})
|
||||
|
||||
kde4_add_plugin(kio_smb ${kio_smb_PART_SRCS})
|
||||
|
||||
|
||||
target_link_libraries(kio_smb ${KDE4_KIO_LIBS} ${SAMBA_LIBRARIES})
|
||||
|
||||
install(TARGETS kio_smb DESTINATION ${KDE4_PLUGIN_INSTALL_DIR})
|
||||
|
||||
|
||||
########### install files ###############
|
||||
|
||||
install( FILES smb.protocol DESTINATION ${KDE4_SERVICES_INSTALL_DIR})
|
||||
install( FILES smb-network.desktop DESTINATION ${KDE4_DATA_INSTALL_DIR}/remoteview)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
#!/bin/bash
|
||||
$XGETTEXT *.cpp -o $podir/kio_smb.pot
|
|
@ -1,2 +0,0 @@
|
|||
/* Define to 1 if you have the <utime.h> header file. */
|
||||
#cmakedefine HAVE_UTIME_H 1
|
|
@ -1,75 +0,0 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Project: SMB kioslave for KDE
|
||||
//
|
||||
// File: Top level implementation file for kio_smb.cpp
|
||||
//
|
||||
// Abstract: member function implementations for SMBSlave
|
||||
//
|
||||
// Author(s): Matthew Peterson <mpeterson@caldera.com>
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2000 Caldera Systems, Inc.
|
||||
//
|
||||
// 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; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; see the file COPYING. If not, please obtain
|
||||
// a copy from http://www.gnu.org/copyleft/gpl.html
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "kio_smb.h"
|
||||
#include "kio_smb_internal.h"
|
||||
#include <kcomponentdata.h>
|
||||
#include <kdemacros.h>
|
||||
#include <QApplication>
|
||||
|
||||
//===========================================================================
|
||||
SMBSlave::SMBSlave(const QByteArray& pool, const QByteArray& app)
|
||||
: SlaveBase( "smb", pool, app ), m_openFd(-1)
|
||||
{
|
||||
m_initialized_smbc = false;
|
||||
|
||||
//read in the default workgroup info...
|
||||
reparseConfiguration();
|
||||
|
||||
//initialize the library...
|
||||
auth_initialize_smbc();
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
SMBSlave::~SMBSlave()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
int KDE_EXPORT kdemain( int argc, char **argv )
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
KComponentData componentData("kio_smb");
|
||||
if( argc != 4 )
|
||||
{
|
||||
kDebug(KIO_SMB) << "Usage: kio_smb protocol domain-socket1 domain-socket2"
|
||||
<< endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
SMBSlave slave( argv[2], argv[3] );
|
||||
|
||||
slave.dispatchLoop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,299 +0,0 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Project: SMB kioslave for KDE
|
||||
//
|
||||
// File: kio_smb.h
|
||||
//
|
||||
// Abstract: The main kio slave class declaration. For convenience,
|
||||
// in concurrent devlopment, the implementation for this class
|
||||
// is separated into several .cpp files -- the file containing
|
||||
// the implementation should be noted in the comments for each
|
||||
// member function.
|
||||
//
|
||||
// Author(s): Matthew Peterson <mpeterson@caldera.com>
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2000 Caldera Systems, Inc.
|
||||
//
|
||||
// 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; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; see the file COPYING. If not, please obtain
|
||||
// a copy from http://www.gnu.org/copyleft/gpl.html
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef KIO_SMB_H_INCLUDED
|
||||
#define KIO_SMB_H_INCLUDED
|
||||
|
||||
#include "config-smb.h"
|
||||
|
||||
//--------------
|
||||
// KDE includes
|
||||
//--------------
|
||||
#include <kdebug.h>
|
||||
#include <kio/global.h>
|
||||
#include <kio/slavebase.h>
|
||||
#include <kurl.h>
|
||||
#include <klocale.h>
|
||||
|
||||
//-----------------------------
|
||||
// Standard C library includes
|
||||
//-----------------------------
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <net/if.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <QObject>
|
||||
|
||||
//-------------------------------
|
||||
// Samba client library includes
|
||||
//-------------------------------
|
||||
extern "C"
|
||||
{
|
||||
#include <libsmbclient.h>
|
||||
}
|
||||
|
||||
//---------------------------
|
||||
// kio_smb internal includes
|
||||
//---------------------------
|
||||
#include "kio_smb_internal.h"
|
||||
|
||||
#define MAX_XFER_BUF_SIZE 65534
|
||||
#define KIO_SMB 7106
|
||||
|
||||
using namespace KIO;
|
||||
|
||||
//===========================================================================
|
||||
|
||||
|
||||
class SMBSlave : public QObject, public KIO::SlaveBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
//---------------------------------------------------------------------
|
||||
// please make sure your private data does not duplicate existing data
|
||||
//---------------------------------------------------------------------
|
||||
bool m_initialized_smbc;
|
||||
|
||||
/**
|
||||
* From Controlcenter
|
||||
*/
|
||||
QString m_default_user;
|
||||
// QString m_default_workgroup; //currently unused, Alex <neundorf@kde.org>
|
||||
QString m_default_password;
|
||||
QString m_default_encoding;
|
||||
|
||||
/**
|
||||
* we store the current url, it's needed for
|
||||
* callback authorization method
|
||||
*/
|
||||
SMBUrl m_current_url;
|
||||
|
||||
/**
|
||||
* From Controlcenter, show SHARE$ or not
|
||||
*/
|
||||
// bool m_showHiddenShares; //currently unused, Alex <neundorf@kde.org>
|
||||
|
||||
/**
|
||||
* libsmbclient need global variables to store in,
|
||||
* else it crashes on exit next method after use cache_stat,
|
||||
* looks like gcc (C/C++) failure
|
||||
*/
|
||||
struct stat st;
|
||||
|
||||
protected:
|
||||
//---------------------------------------------
|
||||
// Authentication functions (kio_smb_auth.cpp)
|
||||
//---------------------------------------------
|
||||
// (please prefix functions with auth)
|
||||
|
||||
|
||||
/**
|
||||
* Description : Initializes the libsmbclient
|
||||
* Return : true on success false with errno set on error
|
||||
*/
|
||||
bool auth_initialize_smbc();
|
||||
|
||||
bool checkPassword(SMBUrl &url);
|
||||
|
||||
|
||||
//---------------------------------------------
|
||||
// Cache functions (kio_smb_auth.cpp)
|
||||
//---------------------------------------------
|
||||
|
||||
//Stat methods
|
||||
|
||||
//-----------------------------------------
|
||||
// Browsing functions (kio_smb_browse.cpp)
|
||||
//-----------------------------------------
|
||||
// (please prefix functions with browse)
|
||||
|
||||
/**
|
||||
* Description : Return a stat of given SMBUrl. Calls cache_stat and
|
||||
* pack it in UDSEntry. UDSEntry will not be cleared
|
||||
* Parameter : SMBUrl the url to stat
|
||||
* ignore_errors do not call error(), but warning()
|
||||
* Return : false if any error occurred (errno), else true
|
||||
*/
|
||||
bool browse_stat_path(const SMBUrl& url, UDSEntry& udsentry, bool ignore_errors);
|
||||
|
||||
/**
|
||||
* Description : call smbc_stat and return stats of the url
|
||||
* Parameter : SMBUrl the url to stat
|
||||
* Return : stat* of the url
|
||||
* Note : it has some problems with stat in method, looks like
|
||||
* something leave(or removed) on the stack. If your
|
||||
* method segfault on returning try to change the stat*
|
||||
* variable
|
||||
*/
|
||||
int cache_stat( const SMBUrl& url, struct stat* st );
|
||||
|
||||
//---------------------------------------------
|
||||
// Configuration functions (kio_smb_config.cpp)
|
||||
//---------------------------------------------
|
||||
// (please prefix functions with config)
|
||||
|
||||
|
||||
//---------------------------------------
|
||||
// Directory functions (kio_smb_dir.cpp)
|
||||
//---------------------------------------
|
||||
// (please prefix functions with dir)
|
||||
|
||||
|
||||
//--------------------------------------
|
||||
// File IO functions (kio_smb_file.cpp)
|
||||
//--------------------------------------
|
||||
// (please prefix functions with file)
|
||||
|
||||
//----------------------------
|
||||
// Misc functions (this file)
|
||||
//----------------------------
|
||||
|
||||
|
||||
/**
|
||||
* Description : correct a given URL
|
||||
* valid URL's are
|
||||
*
|
||||
* smb://[[domain;]user[:password]@]server[:port][/share[/path[/file]]]
|
||||
* smb:/[[domain;]user[:password]@][group/[server[/share[/path[/file]]]]]
|
||||
* domain = workgroup(domain) of the user
|
||||
* user = username
|
||||
* password = password of useraccount
|
||||
* group = workgroup(domain) of server
|
||||
* server = host to connect
|
||||
* share = a share of the server (host)
|
||||
* path = a path of the share
|
||||
* Parameter : KUrl the url to check
|
||||
* Return : new KUrl if it is corrected. else the same KUrl
|
||||
*/
|
||||
KUrl checkURL(const KUrl& kurl) const;
|
||||
|
||||
void reportError(const SMBUrl &kurl, const int &errNum);
|
||||
|
||||
public:
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// smbclient authentication callback (note that this is called by the
|
||||
// global ::auth_smbc_get_data() call.
|
||||
void auth_smbc_get_data(const char *server,const char *share,
|
||||
char *workgroup, int wgmaxlen,
|
||||
char *username, int unmaxlen,
|
||||
char *password, int pwmaxlen);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Overwritten functions from the base class that define the operation of
|
||||
// this slave. (See the base class headerfile slavebase.h for more
|
||||
// details)
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
// Functions overwritten in kio_smb.cpp
|
||||
SMBSlave(const QByteArray& pool, const QByteArray& app);
|
||||
virtual ~SMBSlave();
|
||||
|
||||
// Functions overwritten in kio_smb_browse.cpp
|
||||
virtual void listDir( const KUrl& url );
|
||||
virtual void stat( const KUrl& url );
|
||||
|
||||
// Functions overwritten in kio_smb_config.cpp
|
||||
virtual void reparseConfiguration();
|
||||
|
||||
// Functions overwritten in kio_smb_dir.cpp
|
||||
virtual void copy( const KUrl& src, const KUrl &dest, int permissions, KIO::JobFlags flags );
|
||||
virtual void del( const KUrl& kurl, bool isfile);
|
||||
virtual void mkdir( const KUrl& kurl, int permissions );
|
||||
virtual void rename( const KUrl& src, const KUrl& dest, KIO::JobFlags flags );
|
||||
|
||||
// Functions overwritten in kio_smb_file.cpp
|
||||
virtual void get( const KUrl& kurl );
|
||||
virtual void put( const KUrl& kurl, int permissions, KIO::JobFlags flags );
|
||||
virtual void open( const KUrl& kurl, QIODevice::OpenMode mode );
|
||||
virtual void read( KIO::filesize_t bytesRequested );
|
||||
virtual void write( const QByteArray &fileData );
|
||||
virtual void seek( KIO::filesize_t offset );
|
||||
virtual void close();
|
||||
|
||||
// Functions not implemented (yet)
|
||||
//virtual void setHost(const QString& host, int port, const QString& user, const QString& pass);
|
||||
//virtual void openConnection();
|
||||
//virtual void closeConnection();
|
||||
//virtual void slave_status();
|
||||
virtual void special( const QByteArray & );
|
||||
|
||||
private:
|
||||
void smbCopy(const KUrl& src, const KUrl &dest, int permissions, KIO::JobFlags flags);
|
||||
void smbCopyGet(const KUrl& src, const KUrl& dest, int permissions, KIO::JobFlags flags);
|
||||
void smbCopyPut(const KUrl& src, const KUrl& dest, int permissions, KIO::JobFlags flags);
|
||||
|
||||
/**
|
||||
* Used in open(), read(), write(), and close()
|
||||
* FIXME Placing these in the private section above causes m_openUrl = kurl
|
||||
* to fail in SMBSlave::open. Need to find out why this is.
|
||||
*/
|
||||
int m_openFd;
|
||||
SMBUrl m_openUrl;
|
||||
};
|
||||
|
||||
//==========================================================================
|
||||
// the global libsmbclient authentication callback function
|
||||
extern "C"
|
||||
{
|
||||
|
||||
void auth_smbc_get_data(SMBCCTX * context,
|
||||
const char *server,const char *share,
|
||||
char *workgroup, int wgmaxlen,
|
||||
char *username, int unmaxlen,
|
||||
char *password, int pwmaxlen);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// Main slave entrypoint (see kio_smb.cpp)
|
||||
extern "C"
|
||||
{
|
||||
|
||||
int kdemain( int argc, char **argv );
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif //#endif KIO_SMB_H_INCLUDED
|
|
@ -1,224 +0,0 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Project: SMB kioslave for KDE2
|
||||
//
|
||||
// File: kio_smb_auth.cpp
|
||||
//
|
||||
// Abstract: member function implementations for SMBSlave that deal with
|
||||
// SMB directory access
|
||||
//
|
||||
// Author(s): Matthew Peterson <mpeterson@caldera.com>
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2000 Caldera Systems, Inc.
|
||||
//
|
||||
// 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; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; see the file COPYING. If not, please obtain
|
||||
// a copy from http://www.gnu.org/copyleft/gpl.html
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "kio_smb.h"
|
||||
#include "kio_smb_internal.h"
|
||||
|
||||
#include <kconfig.h>
|
||||
#include <kconfiggroup.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// call for libsmbclient
|
||||
//==========================================================================
|
||||
void auth_smbc_get_data(SMBCCTX * context,
|
||||
const char *server,const char *share,
|
||||
char *workgroup, int wgmaxlen,
|
||||
char *username, int unmaxlen,
|
||||
char *password, int pwmaxlen)
|
||||
//==========================================================================
|
||||
{
|
||||
if (context != NULL) {
|
||||
#ifdef DEPRECATED_SMBC_INTERFACE
|
||||
SMBSlave *theSlave = (SMBSlave*) smbc_getOptionUserData(context);
|
||||
#else
|
||||
SMBSlave *theSlave = (SMBSlave*)smbc_option_get(context, "user_data");
|
||||
#endif
|
||||
theSlave->auth_smbc_get_data(server, share,
|
||||
workgroup,wgmaxlen,
|
||||
username, unmaxlen,
|
||||
password, pwmaxlen);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
void SMBSlave::auth_smbc_get_data(const char *server,const char *share,
|
||||
char *workgroup, int wgmaxlen,
|
||||
char *username, int unmaxlen,
|
||||
char *password, int pwmaxlen)
|
||||
//--------------------------------------------------------------------------
|
||||
{
|
||||
//check this to see if we "really" need to authenticate...
|
||||
SMBUrlType t = m_current_url.getType();
|
||||
if( t == SMBURLTYPE_ENTIRE_NETWORK )
|
||||
{
|
||||
kDebug(KIO_SMB) << "we don't really need to authenticate for this top level url, returning";
|
||||
return;
|
||||
}
|
||||
kDebug(KIO_SMB) << "AAAAAAAAAAAAAA auth_smbc_get_dat: set user=" << username << ", workgroup=" << workgroup
|
||||
<< " server=" << server << ", share=" << share << endl;
|
||||
|
||||
QString s_server = QString::fromUtf8(server);
|
||||
QString s_share = QString::fromUtf8(share);
|
||||
workgroup[wgmaxlen - 1] = 0;
|
||||
QString s_workgroup = QString::fromUtf8(workgroup);
|
||||
username[unmaxlen - 1] = 0;
|
||||
QString s_username = QString::fromUtf8(username);
|
||||
password[pwmaxlen - 1] = 0;
|
||||
QString s_password = QString::fromUtf8(password);
|
||||
|
||||
KIO::AuthInfo info;
|
||||
info.url = KUrl("smb:///");
|
||||
info.url.setHost(s_server);
|
||||
info.url.setPath('/' + s_share);
|
||||
|
||||
info.username = s_username;
|
||||
info.password = s_password;
|
||||
|
||||
kDebug(KIO_SMB) << "libsmb-auth-callback URL:" << info.url;
|
||||
|
||||
if ( !checkCachedAuthentication( info ) )
|
||||
{
|
||||
if ( m_default_user.isEmpty() )
|
||||
{
|
||||
// ok, we do not know the password. Let's try anonymous before we try for real
|
||||
info.username = "anonymous";
|
||||
info.password.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
// user defined a default username/password in kcontrol; try this
|
||||
info.username = m_default_user;
|
||||
info.password = m_default_password;
|
||||
}
|
||||
|
||||
} else
|
||||
kDebug(KIO_SMB) << "got password through cache";
|
||||
|
||||
strncpy(username, info.username.toUtf8(), unmaxlen - 1);
|
||||
strncpy(password, info.password.toUtf8(), pwmaxlen - 1);
|
||||
}
|
||||
|
||||
bool SMBSlave::checkPassword(SMBUrl &url)
|
||||
{
|
||||
kDebug(KIO_SMB) << "checkPassword for " << url;
|
||||
|
||||
KIO::AuthInfo info;
|
||||
info.url = KUrl("smb:///");
|
||||
info.url.setHost(url.host());
|
||||
|
||||
QString share = url.path();
|
||||
int index = share.indexOf('/', 1);
|
||||
if (index > 1)
|
||||
share = share.left(index);
|
||||
if (share.at(0) == '/')
|
||||
share = share.mid(1);
|
||||
info.url.setPath('/' + share);
|
||||
info.keepPassword = true;
|
||||
|
||||
if ( share.isEmpty() )
|
||||
info.prompt = i18n(
|
||||
"<qt>Please enter authentication information for <b>%1</b></qt>" ,
|
||||
url.host() );
|
||||
else
|
||||
info.prompt = i18n(
|
||||
"Please enter authentication information for:\n"
|
||||
"Server = %1\n"
|
||||
"Share = %2" ,
|
||||
url.host() ,
|
||||
share );
|
||||
|
||||
info.username = url.user();
|
||||
kDebug(KIO_SMB) << "call openPasswordDialog for " << info.url;
|
||||
|
||||
if ( openPasswordDialog(info) ) {
|
||||
kDebug(KIO_SMB) << "openPasswordDialog returned " << info.username;
|
||||
url.setUser(info.username);
|
||||
|
||||
if (info.keepPassword) {
|
||||
kDebug(KIO_SMB) << "Caching info.username = " << info.username
|
||||
<< ", info.url = " << info.url.prettyUrl();
|
||||
cacheAuthentication(info);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
kDebug(KIO_SMB) << "no value from openPasswordDialog\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Initializes the smbclient library
|
||||
//
|
||||
// Returns: 0 on success -1 with errno set on error
|
||||
bool SMBSlave::auth_initialize_smbc()
|
||||
{
|
||||
SMBCCTX *smb_context = NULL;
|
||||
|
||||
kDebug(KIO_SMB) << "auth_initialize_smbc ";
|
||||
if(m_initialized_smbc == false)
|
||||
{
|
||||
kDebug(KIO_SMB) << "smbc_init call";
|
||||
KConfig cfg( "kioslaverc", KConfig::SimpleConfig);
|
||||
int debug_level = cfg.group( "SMB" ).readEntry( "DebugLevel", 0 );
|
||||
|
||||
smb_context = smbc_new_context();
|
||||
if (smb_context == NULL) {
|
||||
SlaveBase::error(ERR_INTERNAL, i18n("libsmbclient failed to create context"));
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef DEPRECATED_SMBC_INTERFACE // defined by libsmbclient.h of Samba 3.2
|
||||
|
||||
/* New libsmbclient interface of Samba 3.2 */
|
||||
smbc_setDebug(smb_context, debug_level);
|
||||
smbc_setFunctionAuthDataWithContext(smb_context, ::auth_smbc_get_data);
|
||||
smbc_setOptionUserData(smb_context, this);
|
||||
|
||||
/* Enable Kerberos support */
|
||||
smbc_setOptionUseKerberos(smb_context, 1);
|
||||
smbc_setOptionFallbackAfterKerberos(smb_context, 1);
|
||||
#else
|
||||
smb_context->debug = debug_level;
|
||||
smb_context->callbacks.auth_fn = NULL;
|
||||
smbc_option_set(smb_context, "auth_function", (void*)::auth_smbc_get_data);
|
||||
smbc_option_set(smb_context, "user_data", this);
|
||||
|
||||
#if defined(SMB_CTX_FLAG_USE_KERBEROS) && defined(SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS)
|
||||
smb_context->flags |= SMB_CTX_FLAG_USE_KERBEROS | SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS;
|
||||
#endif
|
||||
#endif /* DEPRECATED_SMBC_INTERFACE */
|
||||
|
||||
if (!smbc_init_context(smb_context)) {
|
||||
smbc_free_context(smb_context, 0);
|
||||
smb_context = NULL;
|
||||
SlaveBase::error(ERR_INTERNAL, i18n("libsmbclient failed to initialize context"));
|
||||
return false;
|
||||
}
|
||||
|
||||
smbc_set_context(smb_context);
|
||||
|
||||
m_initialized_smbc = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1,451 +0,0 @@
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Project: SMB kioslave for KDE2
|
||||
//
|
||||
// File: kio_smb_browse.cpp
|
||||
//
|
||||
// Abstract: member function implementations for SMBSlave that deal with
|
||||
// SMB browsing
|
||||
//
|
||||
// Author(s): Matthew Peterson <mpeterson@caldera.com>
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2000 Caldera Systems, Inc.
|
||||
//
|
||||
// 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; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; see the file COPYING. If not, please obtain
|
||||
// a copy from http://www.gnu.org/copyleft/gpl.html
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
|
||||
|
||||
#include <kglobal.h>
|
||||
|
||||
#include "kio_smb.h"
|
||||
#include "kio_smb_internal.h"
|
||||
|
||||
using namespace KIO;
|
||||
|
||||
int SMBSlave::cache_stat(const SMBUrl &url, struct stat* st )
|
||||
{
|
||||
int cacheStatErr;
|
||||
int result = smbc_stat( url.toSmbcUrl(), st);
|
||||
if (result == 0){
|
||||
cacheStatErr = 0;
|
||||
} else {
|
||||
cacheStatErr = errno;
|
||||
}
|
||||
kDebug(KIO_SMB) << "size " << (KIO::filesize_t)st->st_size;
|
||||
return cacheStatErr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
bool SMBSlave::browse_stat_path(const SMBUrl& _url, UDSEntry& udsentry, bool ignore_errors)
|
||||
// Returns: true on success, false on failure
|
||||
{
|
||||
SMBUrl url = _url;
|
||||
|
||||
int cacheStatErr = cache_stat(url, &st);
|
||||
if(cacheStatErr == 0)
|
||||
{
|
||||
if(!S_ISDIR(st.st_mode) && !S_ISREG(st.st_mode))
|
||||
{
|
||||
kDebug(KIO_SMB) << "mode: "<< st.st_mode;
|
||||
warning(i18n("%1:\n"
|
||||
"Unknown file type, neither directory or file.", url.prettyUrl()));
|
||||
return false;
|
||||
}
|
||||
|
||||
udsentry.insert(KIO::UDSEntry::UDS_FILE_TYPE, st.st_mode & S_IFMT);
|
||||
udsentry.insert(KIO::UDSEntry::UDS_SIZE, st.st_size);
|
||||
|
||||
QString str;
|
||||
uid_t uid = st.st_uid;
|
||||
struct passwd *user = getpwuid( uid );
|
||||
if ( user )
|
||||
str = user->pw_name;
|
||||
else
|
||||
str = QString::number( uid );
|
||||
udsentry.insert(KIO::UDSEntry::UDS_USER, str);
|
||||
|
||||
gid_t gid = st.st_gid;
|
||||
struct group *grp = getgrgid( gid );
|
||||
if ( grp )
|
||||
str = grp->gr_name;
|
||||
else
|
||||
str = QString::number( gid );
|
||||
udsentry.insert(KIO::UDSEntry::UDS_GROUP, str);
|
||||
|
||||
udsentry.insert(KIO::UDSEntry::UDS_ACCESS, st.st_mode & 07777);
|
||||
udsentry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, st.st_mtime);
|
||||
udsentry.insert(KIO::UDSEntry::UDS_ACCESS_TIME, st.st_atime);
|
||||
// No, st_ctime is not UDS_CREATION_TIME...
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ignore_errors) {
|
||||
if (cacheStatErr == EPERM || cacheStatErr == EACCES)
|
||||
if (checkPassword(url)) {
|
||||
redirection( url );
|
||||
return false;
|
||||
}
|
||||
|
||||
reportError(url, cacheStatErr);
|
||||
} else if (cacheStatErr == ENOENT || cacheStatErr == ENOTDIR) {
|
||||
warning(i18n("File does not exist: %1", url.url()));
|
||||
}
|
||||
kDebug(KIO_SMB) << "ERROR!!";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void SMBSlave::stat( const KUrl& kurl )
|
||||
{
|
||||
kDebug(KIO_SMB) << kurl;
|
||||
// make a valid URL
|
||||
KUrl url = checkURL(kurl);
|
||||
|
||||
// if URL is not valid we have to redirect to correct URL
|
||||
if (url != kurl)
|
||||
{
|
||||
kDebug() << "redirection " << url;
|
||||
redirection(url);
|
||||
finished();
|
||||
return;
|
||||
}
|
||||
|
||||
m_current_url = url;
|
||||
|
||||
UDSEntry udsentry;
|
||||
// Set name
|
||||
udsentry.insert( KIO::UDSEntry::UDS_NAME, kurl.fileName() );
|
||||
|
||||
switch(m_current_url.getType())
|
||||
{
|
||||
case SMBURLTYPE_UNKNOWN:
|
||||
error(ERR_MALFORMED_URL,m_current_url.prettyUrl());
|
||||
return;
|
||||
|
||||
case SMBURLTYPE_ENTIRE_NETWORK:
|
||||
case SMBURLTYPE_WORKGROUP_OR_SERVER:
|
||||
udsentry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
|
||||
break;
|
||||
|
||||
case SMBURLTYPE_SHARE_OR_PATH:
|
||||
if (browse_stat_path(m_current_url, udsentry, false))
|
||||
break;
|
||||
else {
|
||||
kDebug(KIO_SMB) << "ERROR!!";
|
||||
finished();
|
||||
return;
|
||||
}
|
||||
default:
|
||||
kDebug(KIO_SMB) << "UNKNOWN " << url;
|
||||
finished();
|
||||
return;
|
||||
}
|
||||
|
||||
statEntry(udsentry);
|
||||
finished();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// TODO: complete checking
|
||||
KUrl SMBSlave::checkURL(const KUrl& kurl) const
|
||||
{
|
||||
kDebug(KIO_SMB) << "checkURL " << kurl;
|
||||
QString surl = kurl.url();
|
||||
if (surl.startsWith(QLatin1String("smb:/"))) {
|
||||
if (surl.length() == 5) // just the above
|
||||
return kurl; // unchanged
|
||||
|
||||
if (surl.at(5) != '/') {
|
||||
surl = "smb://" + surl.mid(5);
|
||||
kDebug(KIO_SMB) << "checkURL return1 " << surl << " " << KUrl(surl);
|
||||
return KUrl(surl);
|
||||
}
|
||||
}
|
||||
|
||||
// smb:/ normaly have no userinfo
|
||||
// we must redirect ourself to remove the username and password
|
||||
if (surl.contains('@') && !surl.contains("smb://")) {
|
||||
KUrl url(kurl);
|
||||
url.setPath('/'+kurl.url().right( kurl.url().length()-kurl.url().indexOf('@') -1));
|
||||
QString userinfo = kurl.url().mid(5, kurl.url().indexOf('@')-5);
|
||||
if(userinfo.contains(':')) {
|
||||
url.setUser(userinfo.left(userinfo.indexOf(':')));
|
||||
url.setPass(userinfo.right(userinfo.length()-userinfo.indexOf(':')-1));
|
||||
} else {
|
||||
url.setUser(userinfo);
|
||||
}
|
||||
kDebug(KIO_SMB) << "checkURL return2 " << url;
|
||||
return url;
|
||||
}
|
||||
|
||||
// no emtpy path
|
||||
KUrl url(kurl);
|
||||
|
||||
if (url.path().isEmpty())
|
||||
url.setPath("/");
|
||||
|
||||
kDebug(KIO_SMB) << "checkURL return3 " << url;
|
||||
return url;
|
||||
}
|
||||
|
||||
void SMBSlave::reportError(const SMBUrl &url, const int &errNum)
|
||||
{
|
||||
kDebug(KIO_SMB) << "errNum" << errNum;
|
||||
|
||||
switch(errNum)
|
||||
{
|
||||
case ENOENT:
|
||||
if (url.getType() == SMBURLTYPE_ENTIRE_NETWORK)
|
||||
error( ERR_SLAVE_DEFINED, i18n("Unable to find any workgroups in your local network. This might be caused by an enabled firewall."));
|
||||
else
|
||||
error( ERR_DOES_NOT_EXIST, url.prettyUrl());
|
||||
break;
|
||||
#ifdef ENOMEDIUM
|
||||
case ENOMEDIUM:
|
||||
error( ERR_SLAVE_DEFINED,
|
||||
i18n( "No media in device for %1", url.prettyUrl() ) );
|
||||
break;
|
||||
#endif
|
||||
#ifdef EHOSTDOWN
|
||||
case EHOSTDOWN:
|
||||
#endif
|
||||
case ECONNREFUSED:
|
||||
error( ERR_SLAVE_DEFINED,
|
||||
i18n( "Could not connect to host for %1", url.prettyUrl() ) );
|
||||
break;
|
||||
case ENOTDIR:
|
||||
error( ERR_CANNOT_ENTER_DIRECTORY, url.prettyUrl());
|
||||
break;
|
||||
case EFAULT:
|
||||
case EINVAL:
|
||||
error( ERR_DOES_NOT_EXIST, url.prettyUrl());
|
||||
break;
|
||||
case EPERM:
|
||||
case EACCES:
|
||||
error( ERR_ACCESS_DENIED, url.prettyUrl() );
|
||||
break;
|
||||
case EIO:
|
||||
case ENETUNREACH:
|
||||
if ( url.getType() == SMBURLTYPE_ENTIRE_NETWORK || url.getType() == SMBURLTYPE_WORKGROUP_OR_SERVER )
|
||||
error( ERR_SLAVE_DEFINED, i18n( "Error while connecting to server responsible for %1", url.prettyUrl() ) );
|
||||
else
|
||||
error( ERR_CONNECTION_BROKEN, url.prettyUrl());
|
||||
break;
|
||||
case ENOMEM:
|
||||
error( ERR_OUT_OF_MEMORY, url.prettyUrl() );
|
||||
break;
|
||||
case ENODEV:
|
||||
error( ERR_SLAVE_DEFINED, i18n("Share could not be found on given server"));
|
||||
break;
|
||||
case EBADF:
|
||||
error( ERR_INTERNAL, i18n("BAD File descriptor"));
|
||||
break;
|
||||
case ETIMEDOUT:
|
||||
error( ERR_SERVER_TIMEOUT, url.host() );
|
||||
break;
|
||||
#ifdef ENOTUNIQ
|
||||
case ENOTUNIQ:
|
||||
error( ERR_SLAVE_DEFINED, i18n( "The given name could not be resolved to a unique server. "
|
||||
"Make sure your network is setup without any name conflicts "
|
||||
"between names used by Windows and by UNIX name resolution." ) );
|
||||
break;
|
||||
#endif
|
||||
case 0: // success
|
||||
error( ERR_INTERNAL, i18n("libsmbclient reported an error, but did not specify "
|
||||
"what the problem is. This might indicate a severe problem "
|
||||
"with your network - but also might indicate a problem with "
|
||||
"libsmbclient.\n"
|
||||
"If you want to help us, please provide a tcpdump of the "
|
||||
"network interface while you try to browse (be aware that "
|
||||
"it might contain private data, so do not post it if you are "
|
||||
"unsure about that - you can send it privately to the developers "
|
||||
"if they ask for it)") );
|
||||
break;
|
||||
default:
|
||||
error( ERR_INTERNAL, i18n("Unknown error condition in stat: %1", QString::fromLocal8Bit( strerror(errNum))) );
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void SMBSlave::listDir( const KUrl& kurl )
|
||||
{
|
||||
kDebug(KIO_SMB) << kurl;
|
||||
int errNum = 0;
|
||||
|
||||
// check (correct) URL
|
||||
KUrl url = checkURL(kurl);
|
||||
// if URL is not valid we have to redirect to correct URL
|
||||
if (url != kurl)
|
||||
{
|
||||
redirection(url);
|
||||
finished();
|
||||
return;
|
||||
}
|
||||
|
||||
m_current_url = kurl;
|
||||
|
||||
int dirfd;
|
||||
struct smbc_dirent *dirp = NULL;
|
||||
UDSEntry udsentry;
|
||||
|
||||
dirfd = smbc_opendir( m_current_url.toSmbcUrl() );
|
||||
if (dirfd > 0){
|
||||
errNum = 0;
|
||||
} else {
|
||||
errNum = errno;
|
||||
}
|
||||
|
||||
kDebug(KIO_SMB) << "open " << m_current_url.toSmbcUrl() << " " << m_current_url.getType() << " " << dirfd;
|
||||
if(dirfd >= 0)
|
||||
{
|
||||
do {
|
||||
kDebug(KIO_SMB) << "smbc_readdir ";
|
||||
dirp = smbc_readdir(dirfd);
|
||||
if(dirp == 0)
|
||||
break;
|
||||
|
||||
// Set name
|
||||
QString udsName;
|
||||
const QString dirpName = QString::fromUtf8( dirp->name );
|
||||
// We cannot trust dirp->commentlen has it might be with or without the NUL character
|
||||
// See KDE bug #111430 and Samba bug #3030
|
||||
const QString comment = QString::fromUtf8( dirp->comment );
|
||||
if ( dirp->smbc_type == SMBC_SERVER || dirp->smbc_type == SMBC_WORKGROUP ) {
|
||||
udsName = dirpName.toLower();
|
||||
udsName[0] = dirpName.at( 0 ).toUpper();
|
||||
if ( !comment.isEmpty() && dirp->smbc_type == SMBC_SERVER )
|
||||
udsName += " (" + comment + ')';
|
||||
} else
|
||||
udsName = dirpName;
|
||||
|
||||
kDebug(KIO_SMB) << "dirp->name " << dirp->name << " " << dirpName << " '" << comment << "'" << " " << dirp->smbc_type;
|
||||
|
||||
udsentry.insert( KIO::UDSEntry::UDS_NAME, udsName );
|
||||
|
||||
// Mark all administrative shares, e.g ADMIN$, as hidden. #197903
|
||||
if (dirpName.endsWith(QLatin1Char('$'))) {
|
||||
//kDebug(KIO_SMB) << dirpName << "marked as hidden";
|
||||
udsentry.insert(KIO::UDSEntry::UDS_HIDDEN, 1);
|
||||
}
|
||||
|
||||
if (udsName == "." || udsName == "..")
|
||||
{
|
||||
// fprintf(stderr,"----------- hide: -%s-\n",dirp->name);
|
||||
// do nothing and hide the hidden shares
|
||||
}
|
||||
else if(dirp->smbc_type == SMBC_FILE)
|
||||
{
|
||||
// Set stat information
|
||||
m_current_url.addPath(dirpName);
|
||||
browse_stat_path(m_current_url, udsentry, true);
|
||||
m_current_url.cd("..");
|
||||
|
||||
// Call base class to list entry
|
||||
listEntry(udsentry, false);
|
||||
}
|
||||
else if(dirp->smbc_type == SMBC_DIR)
|
||||
{
|
||||
m_current_url.addPath(dirpName);
|
||||
browse_stat_path(m_current_url, udsentry, true);
|
||||
m_current_url.cd("..");
|
||||
|
||||
// Call base class to list entry
|
||||
listEntry(udsentry, false);
|
||||
}
|
||||
else if(dirp->smbc_type == SMBC_SERVER ||
|
||||
dirp->smbc_type == SMBC_FILE_SHARE)
|
||||
{
|
||||
// Set type
|
||||
udsentry.insert( KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR );
|
||||
|
||||
// Set permissions
|
||||
udsentry.insert(KIO::UDSEntry::UDS_ACCESS, (S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH));
|
||||
|
||||
if (dirp->smbc_type == SMBC_SERVER) {
|
||||
// QString workgroup = m_current_url.host().toUpper();
|
||||
KUrl u("smb:/");
|
||||
u.setHost(dirpName);
|
||||
|
||||
// when libsmbclient knows
|
||||
// u = QString("smb://%1?WORKGROUP=%2").arg(dirpName).arg(workgroup.toUpper());
|
||||
kDebug(KIO_SMB) << "list item " << u;
|
||||
udsentry.insert(KIO::UDSEntry::UDS_URL, u.url());
|
||||
|
||||
udsentry.insert(KIO::UDSEntry::UDS_MIME_TYPE, QString::fromLatin1("application/x-smb-server"));
|
||||
}
|
||||
|
||||
// Call base class to list entry
|
||||
listEntry(udsentry, false);
|
||||
}
|
||||
else if(dirp->smbc_type == SMBC_WORKGROUP)
|
||||
{
|
||||
// Set type
|
||||
udsentry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR);
|
||||
|
||||
// Set permissions
|
||||
udsentry.insert(KIO::UDSEntry::UDS_ACCESS, (S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH));
|
||||
|
||||
udsentry.insert(KIO::UDSEntry::UDS_MIME_TYPE, QString::fromLatin1("application/x-smb-workgroup"));
|
||||
|
||||
// QString workgroup = m_current_url.host().toUpper();
|
||||
KUrl u("smb:/");
|
||||
u.setHost(dirpName);
|
||||
udsentry.insert(KIO::UDSEntry::UDS_URL, u.url());
|
||||
|
||||
// Call base class to list entry
|
||||
listEntry(udsentry, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
kDebug(KIO_SMB) << "SMBC_UNKNOWN :" << dirpName;
|
||||
// TODO: we don't handle SMBC_IPC_SHARE, SMBC_PRINTER_SHARE
|
||||
// SMBC_LINK, SMBC_COMMS_SHARE
|
||||
//SlaveBase::error(ERR_INTERNAL, TEXT_UNSUPPORTED_FILE_TYPE);
|
||||
// continue;
|
||||
}
|
||||
udsentry.clear();
|
||||
} while (dirp); // checked already in the head
|
||||
|
||||
// clean up
|
||||
smbc_closedir(dirfd);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (errNum == EPERM || errNum == EACCES) {
|
||||
if (checkPassword(m_current_url)) {
|
||||
redirection( m_current_url );
|
||||
finished();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
reportError(m_current_url, errNum);
|
||||
return;
|
||||
}
|
||||
|
||||
listEntry(udsentry, true);
|
||||
finished();
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Project: SMB kioslave for KDE2
|
||||
//
|
||||
// File: kio_smb_config.cpp
|
||||
//
|
||||
// Abstract: member function implementations for SMBSlave that deal with
|
||||
// KDE/SMB slave configuration
|
||||
//
|
||||
// Author(s): Matthew Peterson <mpeterson@caldera.com>
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2000 Caldera Systems, Inc.
|
||||
//
|
||||
// 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; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; see the file COPYING. If not, please obtain
|
||||
// a copy from http://www.gnu.org/copyleft/gpl.html
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "kio_smb.h"
|
||||
#include "kio_smb_internal.h"
|
||||
#include <kconfig.h>
|
||||
#include <kconfiggroup.h>
|
||||
|
||||
#include <QTextCodec>
|
||||
//===========================================================================
|
||||
void SMBSlave::reparseConfiguration()
|
||||
{
|
||||
KConfig cfg("kioslaverc", KConfig::NoGlobals);
|
||||
const KConfigGroup group = cfg.group("Browser Settings/SMBro");
|
||||
m_default_user = group.readEntry("User");
|
||||
// m_default_workgroup=group.readEntry("Workgroup");
|
||||
// m_showHiddenShares=group.readEntry("ShowHiddenShares", QVariant(false)).toBool();
|
||||
|
||||
QString m_encoding = QTextCodec::codecForLocale()->name();
|
||||
m_default_encoding = group.readEntry( "Encoding", m_encoding.toLower() );
|
||||
|
||||
// unscramble, taken from Nicola Brodu's smb ioslave
|
||||
//not really secure, but better than storing the plain password
|
||||
QString scrambled = group.readEntry( "Password" );
|
||||
m_default_password = "";
|
||||
for (int i=0; i<scrambled.length()/3; i++)
|
||||
{
|
||||
QChar qc1 = scrambled[i*3];
|
||||
QChar qc2 = scrambled[i*3+1];
|
||||
QChar qc3 = scrambled[i*3+2];
|
||||
unsigned int a1 = qc1.toLatin1() - '0';
|
||||
unsigned int a2 = qc2.toLatin1() - 'A';
|
||||
unsigned int a3 = qc3.toLatin1() - '0';
|
||||
unsigned int num = ((a1 & 0x3F) << 10) | ((a2& 0x1F) << 5) | (a3 & 0x1F);
|
||||
m_default_password[i] = QChar((uchar)((num - 17) ^ 173)); // restore
|
||||
}
|
||||
}
|
|
@ -1,794 +0,0 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Project: SMB kioslave for KDE2
|
||||
//
|
||||
// File: kio_smb_dir.cpp
|
||||
//
|
||||
// Abstract: member function implementations for SMBSlave that deal with
|
||||
// SMB directory access
|
||||
//
|
||||
// Author(s): Matthew Peterson <mpeterson@caldera.com>
|
||||
//
|
||||
////---------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2000 Caldera Systems, Inc.
|
||||
//
|
||||
// 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; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; see the file COPYING. If not, please obtain
|
||||
// a copy from http://www.gnu.org/copyleft/gpl.html
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "kio_smb.h"
|
||||
#include "kio_smb_internal.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <kde_file.h>
|
||||
#include <kconfiggroup.h>
|
||||
#include <kdeversion.h>
|
||||
#include <kio/ioslave_defaults.h>
|
||||
|
||||
//===========================================================================
|
||||
void SMBSlave::copy(const KUrl& src, const KUrl& dst, int permissions, KIO::JobFlags flags)
|
||||
{
|
||||
const bool isSourceLocal = src.isLocalFile();
|
||||
const bool isDestinationLocal = dst.isLocalFile();
|
||||
|
||||
if (!isSourceLocal && isDestinationLocal) {
|
||||
smbCopyGet(src, dst, permissions, flags);
|
||||
} else if (isSourceLocal && !isDestinationLocal) {
|
||||
smbCopyPut(src, dst, permissions, flags);
|
||||
} else {
|
||||
smbCopy(src, dst, permissions, flags);
|
||||
}
|
||||
}
|
||||
|
||||
void SMBSlave::smbCopy(const KUrl& ksrc, const KUrl& kdst, int permissions, KIO::JobFlags flags)
|
||||
{
|
||||
|
||||
SMBUrl src;
|
||||
SMBUrl dst;
|
||||
mode_t initialmode;
|
||||
ssize_t n;
|
||||
int dstflags;
|
||||
int srcfd = -1;
|
||||
int dstfd = -1;
|
||||
int errNum = 0;
|
||||
KIO::filesize_t processed_size = 0;
|
||||
unsigned char buf[MAX_XFER_BUF_SIZE];
|
||||
|
||||
kDebug(KIO_SMB) << "SMBSlave::copy with src = " << ksrc << "and dest = " << kdst;
|
||||
|
||||
// setup urls
|
||||
src = ksrc;
|
||||
dst = kdst;
|
||||
|
||||
// Obtain information about source
|
||||
errNum = cache_stat(src, &st );
|
||||
if( errNum != 0 )
|
||||
{
|
||||
if ( errNum == EACCES )
|
||||
{
|
||||
error( KIO::ERR_ACCESS_DENIED, src.prettyUrl());
|
||||
}
|
||||
else
|
||||
{
|
||||
error( KIO::ERR_DOES_NOT_EXIST, src.prettyUrl());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ( S_ISDIR( st.st_mode ) )
|
||||
{
|
||||
error( KIO::ERR_IS_DIRECTORY, src.prettyUrl() );
|
||||
return;
|
||||
}
|
||||
totalSize(st.st_size);
|
||||
|
||||
// Check to se if the destination exists
|
||||
errNum = cache_stat(dst, &st);
|
||||
if( errNum == 0 )
|
||||
{
|
||||
if(S_ISDIR(st.st_mode))
|
||||
{
|
||||
error( KIO::ERR_DIR_ALREADY_EXIST, dst.prettyUrl());
|
||||
return;
|
||||
}
|
||||
if(!(flags & KIO::Overwrite))
|
||||
{
|
||||
error( KIO::ERR_FILE_ALREADY_EXIST, dst.prettyUrl());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Open the source file
|
||||
srcfd = smbc_open(src.toSmbcUrl(), O_RDONLY, 0);
|
||||
if (srcfd < 0){
|
||||
errNum = errno;
|
||||
} else {
|
||||
errNum = 0;
|
||||
}
|
||||
|
||||
if(srcfd < 0)
|
||||
{
|
||||
if(errNum == EACCES)
|
||||
{
|
||||
error( KIO::ERR_ACCESS_DENIED, src.prettyUrl() );
|
||||
}
|
||||
else
|
||||
{
|
||||
error( KIO::ERR_DOES_NOT_EXIST, src.prettyUrl() );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine initial creation mode
|
||||
if(permissions != -1)
|
||||
{
|
||||
initialmode = permissions | S_IWUSR;
|
||||
}
|
||||
else
|
||||
{
|
||||
initialmode = 0 | S_IWUSR;//0666;
|
||||
}
|
||||
|
||||
|
||||
// Open the destination file
|
||||
dstflags = O_CREAT | O_TRUNC | O_WRONLY;
|
||||
if(!(flags & KIO::Overwrite))
|
||||
{
|
||||
dstflags |= O_EXCL;
|
||||
}
|
||||
dstfd = smbc_open(dst.toSmbcUrl(), dstflags, initialmode);
|
||||
if (dstfd < 0){
|
||||
errNum = errno;
|
||||
} else {
|
||||
errNum = 0;
|
||||
}
|
||||
|
||||
if(dstfd < 0)
|
||||
{
|
||||
if(errNum == EACCES)
|
||||
{
|
||||
error(KIO::ERR_WRITE_ACCESS_DENIED, dst.prettyUrl());
|
||||
}
|
||||
else
|
||||
{
|
||||
error(KIO::ERR_CANNOT_OPEN_FOR_READING, dst.prettyUrl());
|
||||
}
|
||||
|
||||
if(srcfd >= 0 )
|
||||
{
|
||||
smbc_close(srcfd);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Perform copy
|
||||
while(1)
|
||||
{
|
||||
n = smbc_read(srcfd, buf, MAX_XFER_BUF_SIZE );
|
||||
if(n > 0)
|
||||
{
|
||||
n = smbc_write(dstfd, buf, n);
|
||||
if(n == -1)
|
||||
{
|
||||
kDebug(KIO_SMB) << "SMBSlave::copy copy now KIO::ERR_COULD_NOT_WRITE";
|
||||
error( KIO::ERR_COULD_NOT_WRITE, dst.prettyUrl());
|
||||
break;
|
||||
}
|
||||
|
||||
processed_size += n;
|
||||
processedSize(processed_size);
|
||||
}
|
||||
else if(n == 0)
|
||||
{
|
||||
break; // finished
|
||||
}
|
||||
else
|
||||
{
|
||||
error( KIO::ERR_COULD_NOT_READ, src.prettyUrl());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FINISHED:
|
||||
|
||||
if(srcfd >= 0 )
|
||||
{
|
||||
smbc_close(srcfd);
|
||||
}
|
||||
|
||||
if(dstfd >= 0)
|
||||
{
|
||||
if(smbc_close(dstfd) == 0)
|
||||
{
|
||||
|
||||
// TODO: set final permissions
|
||||
}
|
||||
else
|
||||
{
|
||||
error( KIO::ERR_COULD_NOT_WRITE, dst.prettyUrl());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
finished();
|
||||
}
|
||||
|
||||
void SMBSlave::smbCopyGet(const KUrl& ksrc, const KUrl& kdst, int permissions, KIO::JobFlags flags)
|
||||
{
|
||||
kDebug(KIO_SMB) << "src = " << ksrc << ", dest = " << kdst;
|
||||
|
||||
// check if destination is ok ...
|
||||
const QString dstFile = kdst.toLocalFile();
|
||||
const QFileInfo dstInfo (dstFile);
|
||||
|
||||
if(dstInfo.exists()) {
|
||||
if(dstInfo.isDir()) {
|
||||
error (ERR_IS_DIRECTORY, kdst.prettyUrl());
|
||||
return;
|
||||
}
|
||||
|
||||
if(!(flags & KIO::Overwrite)) {
|
||||
error(ERR_FILE_ALREADY_EXIST, kdst.prettyUrl());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool bResume = false;
|
||||
const QFileInfo partInfo (dstFile + QLatin1String(".part"));
|
||||
const bool bPartExists = partInfo.exists();
|
||||
const bool bMarkPartial = config()->readEntry("MarkPartial", true);
|
||||
|
||||
if (bMarkPartial && bPartExists && partInfo.size() > 0) {
|
||||
if (partInfo.isDir()) {
|
||||
error(ERR_IS_DIRECTORY, partInfo.absoluteFilePath());
|
||||
return;
|
||||
}
|
||||
bResume = canResume(partInfo.size());
|
||||
}
|
||||
|
||||
if (bPartExists && !bResume) // get rid of an unwanted ".part" file
|
||||
QFile::remove(partInfo.absoluteFilePath());
|
||||
|
||||
// open the output file...
|
||||
QFile::OpenMode mode;
|
||||
QString filename;
|
||||
if (bResume) {
|
||||
filename = partInfo.absoluteFilePath();
|
||||
mode = QFile::WriteOnly | QFile::Append;
|
||||
}
|
||||
else {
|
||||
filename = (bMarkPartial ? partInfo.absoluteFilePath() : dstFile);
|
||||
mode = QFile::WriteOnly | QFile::Truncate;
|
||||
}
|
||||
|
||||
QFile file (filename);
|
||||
if (!bResume) {
|
||||
QFile::Permissions perms;
|
||||
if (permissions == -1) {
|
||||
perms = QFile::ReadOwner | QFile::WriteOwner;
|
||||
} else {
|
||||
perms = KIO::convertPermissions(permissions | QFile::WriteOwner);
|
||||
}
|
||||
file.setPermissions(perms);
|
||||
}
|
||||
|
||||
if (!file.open(mode)) {
|
||||
kDebug(KIO_SMB) << "could not write to" << dstFile;
|
||||
switch (file.error()) {
|
||||
case QFile::OpenError:
|
||||
if (bResume) {
|
||||
error (ERR_CANNOT_RESUME, kdst.prettyUrl());
|
||||
} else {
|
||||
error(ERR_CANNOT_OPEN_FOR_WRITING, kdst.prettyUrl());
|
||||
}
|
||||
break;
|
||||
case QFile::PermissionsError:
|
||||
error(ERR_WRITE_ACCESS_DENIED, kdst.prettyUrl());
|
||||
break;
|
||||
default:
|
||||
error(ERR_CANNOT_OPEN_FOR_WRITING, kdst.prettyUrl());
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// setup the source urls
|
||||
const SMBUrl src(ksrc);
|
||||
|
||||
// Obtain information about source
|
||||
int errNum = cache_stat (src, &st);
|
||||
if (errNum != 0) {
|
||||
if (errNum == EACCES) {
|
||||
error (KIO::ERR_ACCESS_DENIED, src.prettyUrl());
|
||||
} else {
|
||||
error (KIO::ERR_DOES_NOT_EXIST, src.prettyUrl());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (S_ISDIR( st.st_mode )) {
|
||||
error (KIO::ERR_IS_DIRECTORY, src.prettyUrl());
|
||||
return;
|
||||
}
|
||||
totalSize(st.st_size);
|
||||
|
||||
// Open the source file
|
||||
KIO::filesize_t processed_size = 0;
|
||||
int srcfd = smbc_open(src.toSmbcUrl(), O_RDONLY, 0);
|
||||
if (srcfd < 0){
|
||||
errNum = errno;
|
||||
} else {
|
||||
errNum = 0;
|
||||
if (bResume) {
|
||||
kDebug(KIO_SMB) << "seeking to size" << partInfo.size();
|
||||
off_t offset = smbc_lseek(srcfd, partInfo.size(), SEEK_SET);
|
||||
if (offset == -1) {
|
||||
error(KIO::ERR_COULD_NOT_SEEK, src.prettyUrl());
|
||||
smbc_close(srcfd);
|
||||
return;
|
||||
} else {
|
||||
processed_size += offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (srcfd < 0) {
|
||||
if(errNum == EACCES) {
|
||||
error( KIO::ERR_ACCESS_DENIED, src.prettyUrl() );
|
||||
} else {
|
||||
error( KIO::ERR_DOES_NOT_EXIST, src.prettyUrl() );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Perform the copy
|
||||
char buf[MAX_XFER_BUF_SIZE];
|
||||
bool isErr = false;
|
||||
|
||||
while (1) {
|
||||
const ssize_t bytesRead = smbc_read(srcfd, buf, MAX_XFER_BUF_SIZE);
|
||||
if (bytesRead <= 0) {
|
||||
if (bytesRead < 0) {
|
||||
error( KIO::ERR_COULD_NOT_READ, src.prettyUrl());
|
||||
isErr = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
const qint64 bytesWritten = file.write(buf, bytesRead);
|
||||
if (bytesWritten == -1) {
|
||||
kDebug(KIO_SMB) << "copy now KIO::ERR_COULD_NOT_WRITE";
|
||||
error( KIO::ERR_COULD_NOT_WRITE, kdst.prettyUrl());
|
||||
isErr = true;
|
||||
break;
|
||||
}
|
||||
|
||||
processed_size += bytesWritten;
|
||||
processedSize(processed_size);
|
||||
}
|
||||
|
||||
// FINISHED
|
||||
smbc_close(srcfd);
|
||||
|
||||
// Handle error condition.
|
||||
if (isErr) {
|
||||
const QString sPart = partInfo.absoluteFilePath();
|
||||
if (bMarkPartial) {
|
||||
const int size = config()->readEntry("MinimumKeepSize", DEFAULT_MINIMUM_KEEP_SIZE);
|
||||
if (partInfo.size() < size) {
|
||||
QFile::remove(sPart);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Rename partial file to its original name.
|
||||
if (bMarkPartial) {
|
||||
const QString sPart = partInfo.absoluteFilePath();
|
||||
// Remove old dest file if it exists..
|
||||
if (dstInfo.exists()) {
|
||||
QFile::remove(dstFile);
|
||||
}
|
||||
if (!QFile::rename(sPart, dstFile)) {
|
||||
kDebug(KIO_SMB) << "failed to rename" << sPart << "to" << dstFile;
|
||||
error(ERR_CANNOT_RENAME_PARTIAL, sPart);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#if KDE_VERSION < KDE_MAKE_VERSION(4,11,80)
|
||||
if (permissions != -1 && !bResume) {
|
||||
if (KDE::chmod(dstFile, permissions) < 0) {
|
||||
kWarning(KIO_SMB) << "failed to set permission on" << dstFile;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Restore the mtime on the file.
|
||||
const QString mtimeStr = metaData("modified");
|
||||
kDebug(KIO_SMB) << "modified:" << mtimeStr;
|
||||
if (!mtimeStr.isEmpty()) {
|
||||
QDateTime dt = QDateTime::fromString(mtimeStr, Qt::ISODate);
|
||||
if (dt.isValid()) {
|
||||
struct utimbuf utbuf;
|
||||
utbuf.actime = QFileInfo(file).lastRead().toTime_t(); // access time, unchanged
|
||||
utbuf.modtime = dt.toTime_t(); // modification time
|
||||
KDE::utime(dstFile, &utbuf);
|
||||
}
|
||||
}
|
||||
|
||||
finished();
|
||||
}
|
||||
|
||||
void SMBSlave::smbCopyPut(const KUrl& ksrc, const KUrl& kdst, int permissions, KIO::JobFlags flags)
|
||||
{
|
||||
kDebug(KIO_SMB) << "src = " << ksrc << ", dest = " << kdst;
|
||||
|
||||
QFile srcFile (ksrc.toLocalFile());
|
||||
const QFileInfo srcInfo (srcFile);
|
||||
|
||||
if (srcInfo.exists()) {
|
||||
if (srcInfo.isDir()) {
|
||||
error(KIO::ERR_IS_DIRECTORY, ksrc.prettyUrl());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
error(KIO::ERR_DOES_NOT_EXIST, ksrc.prettyUrl());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!srcFile.open(QFile::ReadOnly)) {
|
||||
kDebug(KIO_SMB) << "could not read from" << ksrc;
|
||||
switch (srcFile.error()) {
|
||||
case QFile::PermissionsError:
|
||||
error(KIO::ERR_WRITE_ACCESS_DENIED, ksrc.prettyUrl());
|
||||
break;
|
||||
case QFile::OpenError:
|
||||
default:
|
||||
error(KIO::ERR_CANNOT_OPEN_FOR_READING, ksrc.prettyUrl());
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
totalSize(static_cast<filesize_t>(srcInfo.size()));
|
||||
|
||||
bool bResume = false;
|
||||
bool bPartExists = false;
|
||||
const bool bMarkPartial = config()->readEntry("MarkPartial", true);
|
||||
const SMBUrl dstOrigUrl (kdst);
|
||||
|
||||
if (bMarkPartial) {
|
||||
const int errNum = cache_stat(dstOrigUrl.partUrl(), &st);
|
||||
bPartExists = (errNum == 0);
|
||||
if (bPartExists) {
|
||||
if (!(flags & KIO::Overwrite) && !(flags & KIO::Resume)) {
|
||||
bResume = canResume(st.st_size);
|
||||
} else {
|
||||
bResume = (flags & KIO::Resume);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int dstfd = -1;
|
||||
int errNum = cache_stat(dstOrigUrl, &st);
|
||||
|
||||
if (errNum == 0 && !(flags & KIO::Overwrite) && !(flags & KIO::Resume)) {
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
error( KIO::ERR_IS_DIRECTORY, dstOrigUrl.prettyUrl());
|
||||
} else {
|
||||
error( KIO::ERR_FILE_ALREADY_EXIST, dstOrigUrl.prettyUrl());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
KIO::filesize_t processed_size = 0;
|
||||
const SMBUrl dstUrl(bMarkPartial ? dstOrigUrl.partUrl() : dstOrigUrl);
|
||||
|
||||
if (bResume) {
|
||||
// append if resuming
|
||||
kDebug(KIO_SMB) << "resume" << dstUrl;
|
||||
dstfd = smbc_open(dstUrl.toSmbcUrl(), O_RDWR, 0 );
|
||||
if (dstfd < 0) {
|
||||
errNum = errno;
|
||||
} else {
|
||||
const off_t offset = smbc_lseek(dstfd, 0, SEEK_END);
|
||||
if (offset == (off_t)-1) {
|
||||
error(KIO::ERR_COULD_NOT_SEEK, dstUrl.prettyUrl());
|
||||
smbc_close(dstfd);
|
||||
return;
|
||||
} else {
|
||||
processed_size = offset;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mode_t mode;
|
||||
if (permissions == -1) {
|
||||
mode = 600;
|
||||
} else {
|
||||
mode = permissions | S_IRUSR | S_IWUSR;
|
||||
}
|
||||
|
||||
kDebug(KIO_SMB) << "NO resume" << dstUrl;
|
||||
dstfd = smbc_open(dstUrl.toSmbcUrl(), O_CREAT | O_TRUNC | O_WRONLY, mode);
|
||||
if (dstfd < 0) {
|
||||
errNum = errno;
|
||||
}
|
||||
}
|
||||
|
||||
if (dstfd < 0) {
|
||||
if (errNum == EACCES) {
|
||||
kDebug(KIO_SMB) << "access denied";
|
||||
error( KIO::ERR_WRITE_ACCESS_DENIED, dstUrl.prettyUrl());
|
||||
}
|
||||
else {
|
||||
kDebug(KIO_SMB) << "can not open for writing";
|
||||
error( KIO::ERR_CANNOT_OPEN_FOR_WRITING, dstUrl.prettyUrl());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
bool isErr = false;
|
||||
|
||||
if (processed_size == 0 || srcFile.seek(processed_size)) {
|
||||
// Perform the copy
|
||||
char buf[MAX_XFER_BUF_SIZE];
|
||||
|
||||
while (1) {
|
||||
const ssize_t bytesRead = srcFile.read(buf, MAX_XFER_BUF_SIZE);
|
||||
if (bytesRead <= 0) {
|
||||
if (bytesRead < 0) {
|
||||
error(KIO::ERR_COULD_NOT_READ, ksrc.prettyUrl());
|
||||
isErr = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
const qint64 bytesWritten = smbc_write(dstfd, buf, bytesRead);
|
||||
if (bytesWritten == -1) {
|
||||
error(KIO::ERR_COULD_NOT_WRITE, kdst.prettyUrl());
|
||||
isErr = true;
|
||||
break;
|
||||
}
|
||||
|
||||
processed_size += bytesWritten;
|
||||
processedSize(processed_size);
|
||||
}
|
||||
} else {
|
||||
isErr = true;
|
||||
error(KIO::ERR_COULD_NOT_SEEK, ksrc.prettyUrl());
|
||||
}
|
||||
|
||||
// FINISHED
|
||||
if (smbc_close(dstfd) < 0) {
|
||||
kDebug(KIO_SMB) << dstUrl << "could not write";
|
||||
error( KIO::ERR_COULD_NOT_WRITE, dstUrl.prettyUrl());
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle error condition.
|
||||
if (isErr) {
|
||||
if (bMarkPartial) {
|
||||
const int size = config()->readEntry("MinimumKeepSize", DEFAULT_MINIMUM_KEEP_SIZE);
|
||||
const int errNum = cache_stat(dstUrl, &st);
|
||||
if (errNum == 0 && st.st_size < size) {
|
||||
smbc_unlink(dstUrl.toSmbcUrl());
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Rename partial file to its original name.
|
||||
if (bMarkPartial) {
|
||||
smbc_unlink(dstOrigUrl.toSmbcUrl());
|
||||
if (smbc_rename(dstUrl.toSmbcUrl(), dstOrigUrl.toSmbcUrl()) < 0) {
|
||||
kDebug(KIO_SMB) << "failed to rename" << dstUrl << "to" << dstOrigUrl << "->" << strerror(errno);
|
||||
error(ERR_CANNOT_RENAME_PARTIAL, dstUrl.prettyUrl());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_UTIME_H
|
||||
// set modification time
|
||||
const QString mtimeStr = metaData( "modified" );
|
||||
if (!mtimeStr.isEmpty() ) {
|
||||
QDateTime dt = QDateTime::fromString( mtimeStr, Qt::ISODate );
|
||||
if ( dt.isValid() ) {
|
||||
struct utimbuf utbuf;
|
||||
utbuf.actime = st.st_atime; // access time, unchanged
|
||||
utbuf.modtime = dt.toTime_t(); // modification time
|
||||
smbc_utime( dstUrl.toSmbcUrl(), &utbuf );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// We have done our job => finish
|
||||
finished();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void SMBSlave::del( const KUrl &kurl, bool isfile)
|
||||
{
|
||||
kDebug(KIO_SMB) << kurl;
|
||||
m_current_url = kurl;
|
||||
int errNum = 0;
|
||||
int retVal = 0;
|
||||
|
||||
if(isfile)
|
||||
{
|
||||
// Delete file
|
||||
kDebug(KIO_SMB) << kurl;
|
||||
retVal = smbc_unlink(m_current_url.toSmbcUrl());
|
||||
if ( retVal < 0 ){
|
||||
errNum = errno;
|
||||
} else {
|
||||
errNum = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
kDebug(KIO_SMB) << kurl;
|
||||
// Delete directory
|
||||
retVal = smbc_rmdir(m_current_url.toSmbcUrl());
|
||||
if( retVal < 0 ) {
|
||||
errNum = errno;
|
||||
} else {
|
||||
errNum = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if( errNum != 0 )
|
||||
{
|
||||
reportError(kurl, errNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
finished();
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void SMBSlave::mkdir( const KUrl &kurl, int permissions )
|
||||
{
|
||||
kDebug(KIO_SMB) << kurl;
|
||||
int errNum = 0;
|
||||
int retVal = 0;
|
||||
m_current_url = kurl;
|
||||
|
||||
retVal = smbc_mkdir(m_current_url.toSmbcUrl(), 0777);
|
||||
if( retVal < 0 ){
|
||||
errNum = errno;
|
||||
} else {
|
||||
errNum = 0;
|
||||
}
|
||||
|
||||
if( retVal < 0 )
|
||||
{
|
||||
if (errNum == EEXIST) {
|
||||
errNum = cache_stat(m_current_url, &st );
|
||||
if (errNum == 0 && S_ISDIR(st.st_mode))
|
||||
{
|
||||
error( KIO::ERR_DIR_ALREADY_EXIST, m_current_url.prettyUrl());
|
||||
}
|
||||
else
|
||||
{
|
||||
error( KIO::ERR_FILE_ALREADY_EXIST, m_current_url.prettyUrl());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
reportError(kurl, errNum);
|
||||
}
|
||||
kDebug(KIO_SMB) << "exit with error " << kurl;
|
||||
}
|
||||
else // success
|
||||
{
|
||||
if(permissions != -1)
|
||||
{
|
||||
// TODO enable the following when complete
|
||||
//smbc_chmod( url.toSmbcUrl(), permissions );
|
||||
}
|
||||
finished();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
void SMBSlave::rename( const KUrl& ksrc, const KUrl& kdest, KIO::JobFlags flags )
|
||||
{
|
||||
|
||||
SMBUrl src;
|
||||
SMBUrl dst;
|
||||
int errNum = 0;
|
||||
int retVal = 0;
|
||||
|
||||
kDebug(KIO_SMB) << "old name = " << ksrc << ", new name = " << kdest;
|
||||
|
||||
src = ksrc;
|
||||
dst = kdest;
|
||||
|
||||
// Check to se if the destination exists
|
||||
|
||||
kDebug(KIO_SMB) << "stat dst";
|
||||
errNum = cache_stat(dst, &st);
|
||||
if( errNum == 0 )
|
||||
{
|
||||
if(S_ISDIR(st.st_mode))
|
||||
{
|
||||
kDebug(KIO_SMB) << "KIO::ERR_DIR_ALREADY_EXIST";
|
||||
error( KIO::ERR_DIR_ALREADY_EXIST, dst.prettyUrl());
|
||||
return;
|
||||
}
|
||||
if(!(flags & KIO::Overwrite))
|
||||
{
|
||||
kDebug(KIO_SMB) << "KIO::ERR_FILE_ALREADY_EXIST";
|
||||
error( KIO::ERR_FILE_ALREADY_EXIST, dst.prettyUrl());
|
||||
return;
|
||||
}
|
||||
}
|
||||
kDebug(KIO_SMB ) << "smbc_rename " << src.toSmbcUrl() << " " << dst.toSmbcUrl();
|
||||
retVal = smbc_rename(src.toSmbcUrl(), dst.toSmbcUrl());
|
||||
if( retVal < 0 ){
|
||||
errNum = errno;
|
||||
} else {
|
||||
errNum = 0;
|
||||
}
|
||||
|
||||
if( retVal < 0 )
|
||||
{
|
||||
kDebug(KIO_SMB ) << "failed ";
|
||||
switch(errNum)
|
||||
{
|
||||
case ENOENT:
|
||||
errNum = cache_stat(src, &st);
|
||||
if( errNum != 0 )
|
||||
{
|
||||
if(errNum == EACCES)
|
||||
{
|
||||
kDebug(KIO_SMB) << "KIO::ERR_ACCESS_DENIED";
|
||||
error(KIO::ERR_ACCESS_DENIED, src.prettyUrl());
|
||||
}
|
||||
else
|
||||
{
|
||||
kDebug(KIO_SMB) << "KIO::ERR_DOES_NOT_EXIST";
|
||||
error(KIO::ERR_DOES_NOT_EXIST, src.prettyUrl());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EACCES:
|
||||
case EPERM:
|
||||
kDebug(KIO_SMB) << "KIO::ERR_ACCESS_DENIED";
|
||||
error( KIO::ERR_ACCESS_DENIED, dst.prettyUrl() );
|
||||
break;
|
||||
|
||||
default:
|
||||
kDebug(KIO_SMB) << "KIO::ERR_CANNOT_RENAME";
|
||||
error( KIO::ERR_CANNOT_RENAME, src.prettyUrl() );
|
||||
|
||||
}
|
||||
|
||||
kDebug(KIO_SMB) << "exit with error";
|
||||
return;
|
||||
}
|
||||
|
||||
kDebug(KIO_SMB ) << "everything fine\n";
|
||||
finished();
|
||||
}
|
|
@ -1,463 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Project: SMB kioslave for KDE2
|
||||
//
|
||||
// File: kio_smb_file.cpp
|
||||
//
|
||||
// Abstract: member function implementations for SMBSlave that deal with
|
||||
// SMB file access
|
||||
//
|
||||
// Author(s): Matthew Peterson <mpeterson@caldera.com>
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2000 Caldera Systems, Inc.
|
||||
//
|
||||
// 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; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; see the file COPYING. If not, please obtain
|
||||
// a copy from http://www.gnu.org/copyleft/gpl.html
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "kio_smb.h"
|
||||
#include "kio_smb_internal.h"
|
||||
|
||||
#include <QVarLengthArray>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <kmimetype.h>
|
||||
|
||||
//===========================================================================
|
||||
void SMBSlave::get( const KUrl& kurl )
|
||||
{
|
||||
char buf[MAX_XFER_BUF_SIZE];
|
||||
int filefd = 0;
|
||||
int errNum = 0;
|
||||
ssize_t bytesread = 0;
|
||||
// time_t curtime = 0;
|
||||
time_t lasttime = 0;
|
||||
time_t starttime = 0;
|
||||
KIO::filesize_t totalbytesread = 0;
|
||||
QByteArray filedata;
|
||||
SMBUrl url;
|
||||
|
||||
kDebug(KIO_SMB) << kurl;
|
||||
|
||||
// check (correct) URL
|
||||
KUrl kvurl = checkURL(kurl);
|
||||
// if URL is not valid we have to redirect to correct URL
|
||||
if (kvurl != kurl) {
|
||||
redirection(kvurl);
|
||||
finished();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!auth_initialize_smbc())
|
||||
return;
|
||||
|
||||
// Stat
|
||||
url = kurl;
|
||||
errNum = cache_stat(url,&st);
|
||||
if( errNum != 0 )
|
||||
{
|
||||
if ( errNum == EACCES )
|
||||
error( KIO::ERR_ACCESS_DENIED, url.prettyUrl());
|
||||
else
|
||||
error( KIO::ERR_DOES_NOT_EXIST, url.prettyUrl());
|
||||
return;
|
||||
}
|
||||
if ( S_ISDIR( st.st_mode ) ) {
|
||||
error( KIO::ERR_IS_DIRECTORY, url.prettyUrl());
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the total size
|
||||
totalSize( st.st_size );
|
||||
|
||||
// Open and read the file
|
||||
filefd = smbc_open(url.toSmbcUrl(),O_RDONLY,0);
|
||||
if(filefd >= 0)
|
||||
{
|
||||
bool isFirstPacket = true;
|
||||
lasttime = starttime = time(NULL);
|
||||
while(1)
|
||||
{
|
||||
bytesread = smbc_read(filefd, buf, MAX_XFER_BUF_SIZE);
|
||||
if(bytesread == 0)
|
||||
{
|
||||
// All done reading
|
||||
break;
|
||||
}
|
||||
else if(bytesread < 0)
|
||||
{
|
||||
error( KIO::ERR_COULD_NOT_READ, url.prettyUrl());
|
||||
return;
|
||||
}
|
||||
|
||||
filedata = QByteArray::fromRawData(buf,bytesread);
|
||||
if (isFirstPacket)
|
||||
{
|
||||
KMimeType::Ptr p_mimeType = KMimeType::findByNameAndContent(url.fileName(), filedata);
|
||||
mimeType(p_mimeType->name());
|
||||
isFirstPacket = false;
|
||||
}
|
||||
data( filedata );
|
||||
filedata.clear();
|
||||
|
||||
// increment total bytes read
|
||||
totalbytesread += bytesread;
|
||||
|
||||
processedSize(totalbytesread);
|
||||
}
|
||||
|
||||
smbc_close(filefd);
|
||||
data( QByteArray() );
|
||||
processedSize(static_cast<KIO::filesize_t>(st.st_size));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
error( KIO::ERR_CANNOT_OPEN_FOR_READING, url.prettyUrl());
|
||||
return;
|
||||
}
|
||||
|
||||
finished();
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
void SMBSlave::open( const KUrl& kurl, QIODevice::OpenMode mode)
|
||||
{
|
||||
int errNum = 0;
|
||||
kDebug(KIO_SMB) << kurl;
|
||||
|
||||
// check (correct) URL
|
||||
KUrl kvurl = checkURL(kurl);
|
||||
|
||||
// if URL is not valid we have to redirect to correct URL
|
||||
if (kvurl != kurl) {
|
||||
redirection(kvurl);
|
||||
finished();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!auth_initialize_smbc()) {
|
||||
error( KIO::ERR_ACCESS_DENIED, kurl.prettyUrl());
|
||||
return;
|
||||
}
|
||||
|
||||
// Save the URL as a private member
|
||||
// FIXME For some reason m_openUrl has be be declared in bottom private
|
||||
// section of the class SMBSlave declaratiom instead of the top section
|
||||
// or else this assignment fails
|
||||
m_openUrl = kurl;
|
||||
|
||||
// Stat
|
||||
errNum = cache_stat(m_openUrl,&st);
|
||||
if( errNum != 0 )
|
||||
{
|
||||
if ( errNum == EACCES )
|
||||
error( KIO::ERR_ACCESS_DENIED, m_openUrl.prettyUrl());
|
||||
else
|
||||
error( KIO::ERR_DOES_NOT_EXIST, m_openUrl.prettyUrl());
|
||||
return;
|
||||
}
|
||||
if ( S_ISDIR( st.st_mode ) ) {
|
||||
error( KIO::ERR_IS_DIRECTORY, m_openUrl.prettyUrl());
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the total size
|
||||
totalSize( st.st_size );
|
||||
|
||||
// Convert permissions
|
||||
int flags = 0;
|
||||
if (mode & QIODevice::ReadOnly) {
|
||||
if (mode & QIODevice::WriteOnly) {
|
||||
flags = O_RDWR | O_CREAT;
|
||||
} else {
|
||||
flags = O_RDONLY;
|
||||
}
|
||||
} else if (mode & QIODevice::WriteOnly) {
|
||||
flags = O_WRONLY | O_CREAT;
|
||||
}
|
||||
|
||||
if (mode & QIODevice::Append) {
|
||||
flags |= O_APPEND;
|
||||
} else if (mode & QIODevice::Truncate) {
|
||||
flags |= O_TRUNC;
|
||||
}
|
||||
|
||||
// Open the file
|
||||
m_openFd = smbc_open(m_openUrl.toSmbcUrl(), flags, 0);
|
||||
if(m_openFd < 0)
|
||||
{
|
||||
error( KIO::ERR_CANNOT_OPEN_FOR_READING, m_openUrl.prettyUrl());
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine the mimetype of the file to be retrieved, and emit it.
|
||||
// This is mandatory in all slaves (for KRun/BrowserRun to work).
|
||||
// If we're not opening the file ReadOnly or ReadWrite, don't attempt to
|
||||
// read the file and send the mimetype.
|
||||
if (mode & QIODevice::ReadOnly){
|
||||
ssize_t bytesRequested = 1024;
|
||||
ssize_t bytesRead = 0;
|
||||
QVarLengthArray<char> buffer(bytesRequested);
|
||||
bytesRead = smbc_read(m_openFd, buffer.data(), bytesRequested);
|
||||
if(bytesRead < 0)
|
||||
{
|
||||
error( KIO::ERR_COULD_NOT_READ, m_openUrl.prettyUrl());
|
||||
close();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
QByteArray fileData = QByteArray::fromRawData(buffer.data(),bytesRead);
|
||||
KMimeType::Ptr p_mimeType = KMimeType::findByNameAndContent(m_openUrl.fileName(), fileData);
|
||||
mimeType(p_mimeType->name());
|
||||
|
||||
off_t res = smbc_lseek(m_openFd, 0, SEEK_SET);
|
||||
if (res == (off_t)-1) {
|
||||
error(KIO::ERR_COULD_NOT_SEEK, m_openUrl.path());
|
||||
close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
position( 0 );
|
||||
emit opened();
|
||||
}
|
||||
|
||||
|
||||
void SMBSlave::read( KIO::filesize_t bytesRequested )
|
||||
{
|
||||
Q_ASSERT(m_openFd != -1);
|
||||
|
||||
QVarLengthArray<char> buffer(bytesRequested);
|
||||
ssize_t bytesRead = 0;
|
||||
|
||||
bytesRead = smbc_read(m_openFd, buffer.data(), bytesRequested);
|
||||
Q_ASSERT(bytesRead <= static_cast<ssize_t>(bytesRequested));
|
||||
|
||||
if(bytesRead < 0)
|
||||
{
|
||||
kDebug(KIO_SMB) << "Could not read " << m_openUrl;
|
||||
error( KIO::ERR_COULD_NOT_READ, m_openUrl.prettyUrl());
|
||||
close();
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray fileData = QByteArray::fromRawData(buffer.data(), bytesRead);
|
||||
data( fileData );
|
||||
}
|
||||
|
||||
|
||||
void SMBSlave::write(const QByteArray &fileData)
|
||||
{
|
||||
Q_ASSERT(m_openFd != -1);
|
||||
|
||||
QByteArray buf(fileData);
|
||||
|
||||
ssize_t size = smbc_write(m_openFd, buf.data(), buf.size());
|
||||
if (size < 0)
|
||||
{
|
||||
kDebug(KIO_SMB) << "Could not write to " << m_openUrl;
|
||||
error( KIO::ERR_COULD_NOT_WRITE, m_openUrl.prettyUrl());
|
||||
close();
|
||||
return;
|
||||
}
|
||||
|
||||
written(size);
|
||||
}
|
||||
|
||||
void SMBSlave::seek(KIO::filesize_t offset)
|
||||
{
|
||||
off_t res = smbc_lseek(m_openFd, static_cast<off_t>(offset), SEEK_SET);
|
||||
if (res == (off_t)-1) {
|
||||
error(KIO::ERR_COULD_NOT_SEEK, m_openUrl.path());
|
||||
close();
|
||||
} else {
|
||||
kDebug( KIO_SMB ) << "res" << res;
|
||||
position( res );
|
||||
}
|
||||
}
|
||||
|
||||
void SMBSlave::close()
|
||||
{
|
||||
smbc_close(m_openFd);
|
||||
finished();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void SMBSlave::put( const KUrl& kurl,
|
||||
int permissions,
|
||||
KIO::JobFlags flags )
|
||||
{
|
||||
|
||||
void *buf;
|
||||
size_t bufsize;
|
||||
|
||||
m_current_url = kurl;
|
||||
|
||||
int filefd;
|
||||
bool exists;
|
||||
int errNum = 0;
|
||||
off_t retValLSeek = 0;
|
||||
mode_t mode;
|
||||
QByteArray filedata;
|
||||
|
||||
kDebug(KIO_SMB) << kurl;
|
||||
|
||||
errNum = cache_stat(m_current_url, &st);
|
||||
exists = (errNum == 0);
|
||||
if ( exists && !(flags & KIO::Overwrite) && !(flags & KIO::Resume))
|
||||
{
|
||||
if (S_ISDIR(st.st_mode))
|
||||
{
|
||||
kDebug(KIO_SMB) << kurl <<" already isdir !!";
|
||||
error( KIO::ERR_DIR_ALREADY_EXIST, m_current_url.prettyUrl());
|
||||
}
|
||||
else
|
||||
{
|
||||
kDebug(KIO_SMB) << kurl <<" already exist !!";
|
||||
error( KIO::ERR_FILE_ALREADY_EXIST, m_current_url.prettyUrl());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (exists && !(flags & KIO::Resume) && (flags & KIO::Overwrite))
|
||||
{
|
||||
kDebug(KIO_SMB) << "exists try to remove " << m_current_url.toSmbcUrl();
|
||||
// remove(m_current_url.url().toLocal8Bit());
|
||||
}
|
||||
|
||||
|
||||
if (flags & KIO::Resume)
|
||||
{
|
||||
// append if resuming
|
||||
kDebug(KIO_SMB) << "resume " << m_current_url.toSmbcUrl();
|
||||
filefd = smbc_open(m_current_url.toSmbcUrl(), O_RDWR, 0 );
|
||||
if (filefd < 0) {
|
||||
errNum = errno;
|
||||
} else {
|
||||
errNum = 0;
|
||||
}
|
||||
|
||||
retValLSeek = smbc_lseek(filefd, 0, SEEK_END);
|
||||
if (retValLSeek == (off_t)-1) {
|
||||
errNum = errno;
|
||||
} else {
|
||||
errNum = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (permissions != -1)
|
||||
{
|
||||
mode = permissions | S_IWUSR | S_IRUSR;
|
||||
}
|
||||
else
|
||||
{
|
||||
mode = 600;//0666;
|
||||
}
|
||||
|
||||
kDebug(KIO_SMB) << "NO resume " << m_current_url.toSmbcUrl();
|
||||
filefd = smbc_open(m_current_url.toSmbcUrl(), O_CREAT | O_TRUNC | O_WRONLY, mode);
|
||||
if (filefd < 0) {
|
||||
errNum = errno;
|
||||
} else {
|
||||
errNum = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( filefd < 0 )
|
||||
{
|
||||
if ( errNum == EACCES )
|
||||
{
|
||||
kDebug(KIO_SMB) << "error " << kurl <<" access denied !!";
|
||||
error( KIO::ERR_WRITE_ACCESS_DENIED, m_current_url.prettyUrl());
|
||||
}
|
||||
else
|
||||
{
|
||||
kDebug(KIO_SMB) << "error " << kurl <<" can not open for writing !!";
|
||||
error( KIO::ERR_CANNOT_OPEN_FOR_WRITING, m_current_url.prettyUrl());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Loop until we got 0 (end of data)
|
||||
while(1)
|
||||
{
|
||||
kDebug(KIO_SMB) << "request data ";
|
||||
dataReq(); // Request for data
|
||||
kDebug(KIO_SMB) << "write " << m_current_url.toSmbcUrl();
|
||||
|
||||
if (readData(filedata) <= 0)
|
||||
{
|
||||
kDebug(KIO_SMB) << "readData <= 0";
|
||||
break;
|
||||
}
|
||||
kDebug(KIO_SMB) << "write " << m_current_url.toSmbcUrl();
|
||||
buf = filedata.data();
|
||||
bufsize = filedata.size();
|
||||
ssize_t size = smbc_write(filefd, buf, bufsize);
|
||||
if ( size < 0)
|
||||
{
|
||||
kDebug(KIO_SMB) << "error " << kurl << "could not write !!";
|
||||
error( KIO::ERR_COULD_NOT_WRITE, m_current_url.prettyUrl());
|
||||
return;
|
||||
}
|
||||
kDebug(KIO_SMB ) << "wrote " << size;
|
||||
}
|
||||
kDebug(KIO_SMB) << "close " << m_current_url.toSmbcUrl();
|
||||
|
||||
if(smbc_close(filefd) < 0)
|
||||
{
|
||||
kDebug(KIO_SMB) << kurl << "could not write !!";
|
||||
error( KIO::ERR_COULD_NOT_WRITE, m_current_url.prettyUrl());
|
||||
return;
|
||||
}
|
||||
|
||||
// set final permissions, if the file was just created
|
||||
if ( permissions != -1 && !exists )
|
||||
{
|
||||
// TODO: did the smbc_chmod fail?
|
||||
// TODO: put in call to chmod when it is working!
|
||||
// smbc_chmod(url.toSmbcUrl(),permissions);
|
||||
}
|
||||
#ifdef HAVE_UTIME_H
|
||||
// set modification time
|
||||
const QString mtimeStr = metaData( "modified" );
|
||||
if ( !mtimeStr.isEmpty() ) {
|
||||
QDateTime dt = QDateTime::fromString( mtimeStr, Qt::ISODate );
|
||||
if ( dt.isValid() ) {
|
||||
if (cache_stat( m_current_url, &st ) == 0) {
|
||||
struct utimbuf utbuf;
|
||||
utbuf.actime = st.st_atime; // access time, unchanged
|
||||
utbuf.modtime = dt.toTime_t(); // modification time
|
||||
smbc_utime( m_current_url.toSmbcUrl(), &utbuf );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// We have done our job => finish
|
||||
finished();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,141 +0,0 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Project: SMB kioslave for KDE2
|
||||
//
|
||||
// File: kio_smb_internal.cpp
|
||||
//
|
||||
// Abstract: Utility class implementation used by SMBSlave
|
||||
//
|
||||
// Author(s): Matthew Peterson <mpeterson@caldera.com>
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2000 Caldera Systems, Inc.
|
||||
//
|
||||
// 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; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; see the file COPYING. If not, please obtain
|
||||
// a copy from http://www.gnu.org/copyleft/gpl.html
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "kio_smb_internal.h"
|
||||
#include "kio_smb.h"
|
||||
|
||||
|
||||
#include <kconfig.h>
|
||||
#include <kglobal.h>
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// SMBUrl Function Implementation
|
||||
//===========================================================================
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
SMBUrl::SMBUrl()
|
||||
{
|
||||
m_type = SMBURLTYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
SMBUrl::SMBUrl(const KUrl& kurl)
|
||||
: KUrl(kurl)
|
||||
//-----------------------------------------------------------------------
|
||||
{
|
||||
updateCache();
|
||||
}
|
||||
|
||||
SMBUrl::SMBUrl(const SMBUrl& other)
|
||||
: KUrl(other),
|
||||
m_surl(other.m_surl),
|
||||
m_type(other.m_type)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void SMBUrl::addPath(const QString &filedir)
|
||||
{
|
||||
KUrl::addPath(filedir);
|
||||
updateCache();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
bool SMBUrl::cd(const QString &filedir)
|
||||
{
|
||||
if (!KUrl::cd(filedir))
|
||||
return false;
|
||||
updateCache();
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void SMBUrl::updateCache()
|
||||
//-----------------------------------------------------------------------
|
||||
{
|
||||
cleanPath();
|
||||
|
||||
// SMB URLs are UTF-8 encoded
|
||||
kDebug(KIO_SMB) << "updateCache " << KUrl::path();
|
||||
|
||||
if ( KUrl::url() == "smb:/" )
|
||||
m_surl = "smb://";
|
||||
else
|
||||
m_surl = KUrl::url( RemoveTrailingSlash ).toUtf8();
|
||||
|
||||
m_type = SMBURLTYPE_UNKNOWN;
|
||||
// update m_type
|
||||
(void)getType();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
SMBUrlType SMBUrl::getType() const
|
||||
// Returns the type of this SMBUrl:
|
||||
// SMBURLTYPE_UNKNOWN - Type could not be determined. Bad SMB Url.
|
||||
// SMBURLTYPE_ENTIRE_NETWORK - "smb:/" is entire network
|
||||
// SMBURLTYPE_WORKGROUP_OR_SERVER - "smb:/mygroup" or "smb:/myserver"
|
||||
// SMBURLTYPE_SHARE_OR_PATH - "smb:/mygroupe/mymachine/myshare/mydir"
|
||||
//-----------------------------------------------------------------------
|
||||
{
|
||||
if(m_type != SMBURLTYPE_UNKNOWN)
|
||||
return m_type;
|
||||
|
||||
if (protocol() != "smb")
|
||||
{
|
||||
m_type = SMBURLTYPE_UNKNOWN;
|
||||
return m_type;
|
||||
}
|
||||
|
||||
if (path(KUrl::AddTrailingSlash) == "/")
|
||||
{
|
||||
if (host().isEmpty())
|
||||
m_type = SMBURLTYPE_ENTIRE_NETWORK;
|
||||
else
|
||||
m_type = SMBURLTYPE_WORKGROUP_OR_SERVER;
|
||||
return m_type;
|
||||
}
|
||||
|
||||
// Check for the path if we get this far
|
||||
m_type = SMBURLTYPE_SHARE_OR_PATH;
|
||||
|
||||
return m_type;
|
||||
}
|
||||
|
||||
SMBUrl SMBUrl::partUrl() const
|
||||
{
|
||||
if (m_type == SMBURLTYPE_SHARE_OR_PATH && !fileName().isEmpty()) {
|
||||
SMBUrl url (*this);
|
||||
url.setFileName(fileName() + QLatin1String(".part"));
|
||||
return url;
|
||||
}
|
||||
|
||||
return SMBUrl();
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Project: SMB kioslave for KDE2
|
||||
//
|
||||
// File: kio_smb_internal.h
|
||||
//
|
||||
// Abstract: Utility classes used by SMBSlave
|
||||
//
|
||||
// Author(s): Matthew Peterson <mpeterson@caldera.com>
|
||||
// Frank Schwanz <schwanz@fh-brandenburg.de>
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2000 Caldera Systems, Inc.
|
||||
//
|
||||
// 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; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; see the file COPYING. If not, please obtain
|
||||
// a copy from http://www.gnu.org/copyleft/gpl.html
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef KIO_SMB_INTERNAL_H_INCLUDED
|
||||
#define KIO_SMB_INTERNAL_H_INCLUDED
|
||||
|
||||
#include <kio/authinfo.h>
|
||||
//Added by qt3to4:
|
||||
#include <QByteArray>
|
||||
|
||||
/**
|
||||
* Types of a SMBURL :
|
||||
* SMBURLTYPE_UNKNOWN - Type could not be determined. Bad SMB Url.
|
||||
* SMBURLTYPE_ENTIRE_NETWORK - "smb:/" is entire network
|
||||
* SMBURLTYPE_WORKGROUP_OR_SERVER - "smb:/mygroup" or "smb:/myserver"
|
||||
* URLTYPE_SHARE_OR_PATH - "smb:/mygroupe/mymachine/myshare/mydir"
|
||||
*/
|
||||
enum SMBUrlType {
|
||||
SMBURLTYPE_UNKNOWN = 0, SMBURLTYPE_ENTIRE_NETWORK = 1,
|
||||
SMBURLTYPE_WORKGROUP_OR_SERVER = 2, SMBURLTYPE_SHARE_OR_PATH = 3
|
||||
};
|
||||
|
||||
|
||||
//===========================================================================
|
||||
/**
|
||||
* Class to handle URL's
|
||||
* it can convert KUrl to smbUrl
|
||||
* and Handle UserInfo
|
||||
* it also check the correctness of the URL
|
||||
*/
|
||||
class SMBUrl : public KUrl
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
SMBUrl();
|
||||
SMBUrl(const SMBUrl&);
|
||||
SMBUrl(const KUrl & kurl);
|
||||
|
||||
/**
|
||||
* Appends the specified file and dir to this SMBUrl
|
||||
* "smb://server/share" --> "smb://server/share/filedir"
|
||||
*/
|
||||
void addPath(const QString &filedir);
|
||||
|
||||
bool cd(const QString &dir);
|
||||
|
||||
/**
|
||||
* Returns the type of this SMBUrl:
|
||||
* SMBURLTYPE_UNKNOWN - Type could not be determined. Bad SMB Url.
|
||||
* SMBURLTYPE_ENTIRE_NETWORK - "smb:/" is entire network
|
||||
* SMBURLTYPE_WORKGROUP_OR_SERVER - "smb:/mygroup" or "smb:/myserver"
|
||||
* URLTYPE_SHARE_OR_PATH - "smb:/mygroupe/mymachine/myshare/mydir"
|
||||
*/
|
||||
SMBUrlType getType() const;
|
||||
|
||||
void setPass( const QString& _txt ) { KUrl::setPass(_txt); updateCache(); }
|
||||
void setUser( const QString& _txt ) { KUrl::setUser(_txt); updateCache(); }
|
||||
void setHost( const QString& _txt ) { KUrl::setHost(_txt); updateCache(); }
|
||||
void setFileName(const QString& _txt) { KUrl::setFileName(_txt); updateCache(); }
|
||||
|
||||
/**
|
||||
* Returns the workgroup if it given in url
|
||||
*/
|
||||
// QString getWorkgroup() const;
|
||||
|
||||
/**
|
||||
* Returns path after workgroup
|
||||
*/
|
||||
// QString getServerShareDir() const;
|
||||
|
||||
/**
|
||||
* Return a URL that is suitable for libsmbclient
|
||||
*/
|
||||
QByteArray toSmbcUrl() const { return m_surl; }
|
||||
|
||||
/**
|
||||
* Returns the partial URL.
|
||||
*/
|
||||
SMBUrl partUrl() const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Change from QString to QCString (MS Windows's character encoding)
|
||||
*/
|
||||
QByteArray fromUnicode( const QString &_str ) const;
|
||||
|
||||
void updateCache();
|
||||
QByteArray m_surl;
|
||||
|
||||
/**
|
||||
* Type of URL
|
||||
* @see _SMBUrlType
|
||||
*/
|
||||
mutable SMBUrlType m_type;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,191 +0,0 @@
|
|||
/* This file is part of the KDE project
|
||||
|
||||
Copyright (C) 2000 Alexander Neundorf <neundorf@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "kio_smb.h"
|
||||
#include <kstandarddirs.h>
|
||||
#include <unistd.h>
|
||||
#include <QByteArray>
|
||||
#include <QDir>
|
||||
#include <QProcess>
|
||||
#include <kshell.h>
|
||||
|
||||
void SMBSlave::special( const QByteArray & data)
|
||||
{
|
||||
kDebug(KIO_SMB)<<"Smb::special()";
|
||||
int tmp;
|
||||
QDataStream stream(data);
|
||||
stream >> tmp;
|
||||
//mounting and umounting are both blocking, "guarded" by a SIGALARM in the future
|
||||
switch (tmp)
|
||||
{
|
||||
case 1:
|
||||
case 3:
|
||||
{
|
||||
QString remotePath, mountPoint, user;
|
||||
stream >> remotePath >> mountPoint;
|
||||
|
||||
QStringList sl=remotePath.split('/');
|
||||
QString share,host;
|
||||
if (sl.count()>=2)
|
||||
{
|
||||
host=sl.at(0).mid(2);
|
||||
share=sl.at(1);
|
||||
kDebug(KIO_SMB)<<"special() host -"<< host <<"- share -" << share <<"-";
|
||||
}
|
||||
|
||||
remotePath.replace('\\', '/'); // smbmounterplugin sends \\host/share
|
||||
|
||||
kDebug(KIO_SMB) << "mounting: " << remotePath.toLocal8Bit() << " to " << mountPoint.toLocal8Bit();
|
||||
|
||||
if (tmp==3) {
|
||||
if (!KStandardDirs::makeDir(mountPoint)) {
|
||||
error(KIO::ERR_COULD_NOT_MKDIR, mountPoint);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SMBUrl smburl(KUrl("smb:///"));
|
||||
smburl.setHost(host);
|
||||
smburl.setPath('/' + share);
|
||||
|
||||
if ( !checkPassword(smburl) )
|
||||
{
|
||||
finished();
|
||||
return;
|
||||
}
|
||||
|
||||
// using smbmount instead of "mount -t smbfs", because mount does not allow a non-root
|
||||
// user to do a mount, but a suid smbmnt does allow this
|
||||
|
||||
QProcess proc;
|
||||
proc.setProcessChannelMode(QProcess::SeparateChannels);
|
||||
|
||||
QStringList procArgs;
|
||||
QString options;
|
||||
|
||||
if ( smburl.user().isEmpty() )
|
||||
{
|
||||
user = "guest";
|
||||
options = "guest";
|
||||
}
|
||||
else
|
||||
{
|
||||
options = "username=" + smburl.user();
|
||||
user = smburl.user();
|
||||
|
||||
if ( ! smburl.pass().isEmpty() )
|
||||
options += ",password=" + smburl.pass();
|
||||
}
|
||||
|
||||
// TODO: check why the control center uses encodings with a blank char, e.g. "cp 1250"
|
||||
//if ( ! m_default_encoding.isEmpty() )
|
||||
//options += ",codepage=" + KShell::quoteArg(m_default_encoding);
|
||||
|
||||
procArgs << remotePath;
|
||||
procArgs << mountPoint;
|
||||
procArgs << "-o" << options;
|
||||
|
||||
proc.start("smbmount", procArgs);
|
||||
if (!proc.waitForFinished())
|
||||
{
|
||||
error(KIO::ERR_CANNOT_LAUNCH_PROCESS,
|
||||
"smbmount"+i18n("\nMake sure that the samba package is installed properly on your system."));
|
||||
return;
|
||||
}
|
||||
|
||||
QString mybuf = QString::fromLocal8Bit(proc.readAllStandardOutput());
|
||||
QString mystderr = QString::fromLocal8Bit(proc.readAllStandardError());
|
||||
|
||||
kDebug(KIO_SMB) << "mount exit " << proc.exitCode()
|
||||
<< "stdout:" << mybuf << endl << "stderr:" << mystderr << endl;
|
||||
|
||||
if (proc.exitCode() != 0)
|
||||
{
|
||||
error( KIO::ERR_COULD_NOT_MOUNT,
|
||||
i18n("Mounting of share \"%1\" from host \"%2\" by user \"%3\" failed.\n%4",
|
||||
share, host, user, mybuf + '\n' + mystderr));
|
||||
return;
|
||||
}
|
||||
|
||||
finished();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case 4:
|
||||
{
|
||||
QString mountPoint;
|
||||
stream >> mountPoint;
|
||||
|
||||
QProcess proc;
|
||||
proc.setProcessChannelMode(QProcess::SeparateChannels);
|
||||
|
||||
proc.start("smbumount", QStringList() << mountPoint);
|
||||
if ( !proc.waitForFinished() )
|
||||
{
|
||||
error(KIO::ERR_CANNOT_LAUNCH_PROCESS,
|
||||
"smbumount"+i18n("\nMake sure that the samba package is installed properly on your system."));
|
||||
return;
|
||||
}
|
||||
|
||||
QString mybuf = QString::fromLocal8Bit(proc.readAllStandardOutput());
|
||||
QString mystderr = QString::fromLocal8Bit(proc.readAllStandardError());
|
||||
|
||||
kDebug(KIO_SMB) << "smbumount exit " << proc.exitCode()
|
||||
<< "stdout:" << mybuf << endl << "stderr:" << mystderr << endl;
|
||||
|
||||
if (proc.exitCode() != 0)
|
||||
{
|
||||
error(KIO::ERR_COULD_NOT_UNMOUNT,
|
||||
i18n("Unmounting of mountpoint \"%1\" failed.\n%2",
|
||||
mountPoint, mybuf + '\n' + mystderr));
|
||||
return;
|
||||
}
|
||||
|
||||
if ( tmp == 4 )
|
||||
{
|
||||
bool ok;
|
||||
|
||||
QDir dir(mountPoint);
|
||||
dir.cdUp();
|
||||
ok = dir.rmdir(mountPoint);
|
||||
if ( ok )
|
||||
{
|
||||
QString p=dir.path();
|
||||
dir.cdUp();
|
||||
ok = dir.rmdir(p);
|
||||
}
|
||||
|
||||
if ( !ok )
|
||||
{
|
||||
error(KIO::ERR_COULD_NOT_RMDIR, mountPoint);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
finished();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
finished();
|
||||
}
|
||||
|
||||
#include "moc_kio_smb.cpp"
|
|
@ -1,11 +0,0 @@
|
|||
HOWTO get the libsmbclient built, so that you can get the new smb ioslave built...
|
||||
|
||||
1. Check out the samba sources from cvs with ( full directions are at: http://www.samba.org/samba/cvs.html
|
||||
cvs -d :pserver:cvs@pserver.samba.org:/cvsroot login
|
||||
use "cvs" as the password
|
||||
cvs -z5 -d :pserver:cvs@pserver.samba.org:/cvsroot co -r SAMBA_3_0 samba/source
|
||||
2. cd samba/source
|
||||
3. sh autogen.sh
|
||||
4. run ./configure && make
|
||||
5. when compiling is done- shouldn't take more than 5-15 minutes depending on your machine,
|
||||
you need to "make installclientlib installdat" - if you want all of samba, do "make install"
|
|
@ -1,94 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Icon=network-workgroup
|
||||
Name=Samba Shares
|
||||
Name[af]=Samba Hulpbronne
|
||||
Name[ar]=مشاركات السامبا
|
||||
Name[ast]=Comparticiones Samba
|
||||
Name[be]=Агульныя тэчкі Samba
|
||||
Name[be@latin]=Supolnyja resursy „Samba”
|
||||
Name[bg]=Ресурси на Samba
|
||||
Name[bn]=সাম্বা শেয়ার
|
||||
Name[bn_IN]=Samba শেয়ার
|
||||
Name[br]=Rannadoù Samba
|
||||
Name[bs]=Samba dijeljenja
|
||||
Name[ca]=Recursos compartits de Samba
|
||||
Name[ca@valencia]=Recursos compartits de Samba
|
||||
Name[cs]=Sdílené disky Samby
|
||||
Name[csb]=Dostónczi Sambë
|
||||
Name[cy]=Cydranniad Samba
|
||||
Name[da]=Samba-shares
|
||||
Name[de]=Samba-Freigaben
|
||||
Name[el]=Κοινόχρηστοι πόροι Samba
|
||||
Name[en_GB]=Samba Shares
|
||||
Name[eo]=Samba-kunhavigoj
|
||||
Name[es]=Recursos compartidos Samba
|
||||
Name[et]=SMB jagatud ressursid
|
||||
Name[eu]=Samba partekatzeak
|
||||
Name[fa]=اشتراکهای سامبا
|
||||
Name[fi]=Samba-jaot
|
||||
Name[fr]=Partages Samba
|
||||
Name[fy]=Sambanetwurk
|
||||
Name[ga]=Comhranna Samba
|
||||
Name[gl]=Comparticións de Samba
|
||||
Name[gu]=સામ્બા ભાગીદારીઓ
|
||||
Name[he]=שיתופי Samba
|
||||
Name[hi]=साम्बा साझेदारी
|
||||
Name[hne]=साम्बा साझेदारी
|
||||
Name[hr]=Dijeljenja u Sambi
|
||||
Name[hsb]=Zhromadne zapiski a graty wot Samba
|
||||
Name[hu]=Samba-megosztások
|
||||
Name[ia]=Samba Shares (Areas compartite de Samba)
|
||||
Name[id]=Pembagian Samba
|
||||
Name[is]=Samba sameignir
|
||||
Name[it]=Condivisioni Samba
|
||||
Name[ja]=Samba 共有
|
||||
Name[ka]=Samba-ს საზიაროები
|
||||
Name[kk]=Samba ресурстары
|
||||
Name[km]=ការចែករំលែក Samba
|
||||
Name[kn]=ಸಾಂಬಾ ಹಂಚಿಕೆಗಳು (ಶೇರ್)
|
||||
Name[ko]=삼바 공유
|
||||
Name[ku]=Parvekirinên Sambayê
|
||||
Name[lt]=Samba bendri diskai
|
||||
Name[lv]=Samba koplietojumi
|
||||
Name[mai]=साम्बा साझेदारी
|
||||
Name[mk]=Samba-заеднички
|
||||
Name[ml]=സാംബവഴി പങ്കിട്ടവ
|
||||
Name[mr]=साम्बा शेअर
|
||||
Name[ms]=Perkongsian Samba
|
||||
Name[nb]=Samba-ressurser
|
||||
Name[nds]=Samba-Freegaven
|
||||
Name[ne]=साम्बा साझेदारी
|
||||
Name[nl]=Sambanetwerk
|
||||
Name[nn]=Samba-ressursar
|
||||
Name[or]=Samba ସହଭାଗୀ
|
||||
Name[pa]=ਸਾਂਬਾ ਸਾਂਝ
|
||||
Name[pl]=Zasoby Samby
|
||||
Name[pt]=Partilhas de Samba
|
||||
Name[pt_BR]=Compartilhamentos do Samba
|
||||
Name[ro]=Partajări Samba
|
||||
Name[ru]=Общие папки Samba
|
||||
Name[se]=Samba-resurssat
|
||||
Name[si]=Samba හවුල්
|
||||
Name[sk]=Zdieľania Samby
|
||||
Name[sl]=Souporabe Sambe
|
||||
Name[sr]=Самба дељења
|
||||
Name[sr@ijekavian]=Самба дељења
|
||||
Name[sr@ijekavianlatin]=Samba deljenja
|
||||
Name[sr@latin]=Samba deljenja
|
||||
Name[sv]=Samba-utdelningar
|
||||
Name[ta]=சம்பா பங்குகள்
|
||||
Name[te]=సాంబా భాగస్వామ్యాలు
|
||||
Name[tg]=Мубодилаи Samba
|
||||
Name[th]=พื้นที่ใช้ร่วมกันของ Samba
|
||||
Name[tr]=Samba Paylaşımları
|
||||
Name[ug]=Samba ھەمبەھىر
|
||||
Name[uk]=Спільні ресурси Samba
|
||||
Name[vi]=Chia sẻ Samba
|
||||
Name[wa]=Pårtaedjes Samba
|
||||
Name[xh]=Izahlulo ze Samba
|
||||
Name[x-test]=xxSamba Sharesxx
|
||||
Name[zh_CN]=Samba 共享
|
||||
Name[zh_TW]=Samba 資源分享
|
||||
Open=false
|
||||
Type=Link
|
||||
URL=smb:/
|
|
@ -1,18 +0,0 @@
|
|||
[Protocol]
|
||||
exec=kio_smb
|
||||
protocol=smb
|
||||
input=none
|
||||
output=filesystem
|
||||
listing=Name,Type,Size,Date,Access,Owner,Group
|
||||
reading=true
|
||||
writing=true
|
||||
makedir=true
|
||||
deleting=true
|
||||
opening=true
|
||||
moving=true
|
||||
copyToFile=true
|
||||
copyFromFile=true
|
||||
maxInstances=20
|
||||
maxInstancesPerHost=5
|
||||
X-DocPath=kioslave/smb/index.html
|
||||
Icon=network-workgroup
|
|
@ -1,4 +1,2 @@
|
|||
- add a browser for SMB?
|
||||
- plugin / desktop file interface for adding more protocols
|
||||
- integrate kdnssd?
|
||||
|
||||
|
|
|
@ -44,8 +44,6 @@ KNetAttach::KNetAttach( QWidget* parent )
|
|||
|
||||
_ftp->setEnabled(KProtocolInfo::isKnownProtocol("ftp"));
|
||||
_sftp->setEnabled(KProtocolInfo::isKnownProtocol("sftp"));
|
||||
_nfs->setEnabled(KProtocolInfo::isKnownProtocol("nfs"));
|
||||
_smb->setEnabled(KProtocolInfo::isKnownProtocol("smb"));
|
||||
|
||||
connect(_recent, SIGNAL(toggled(bool)), _recentConnectionName, SLOT(setEnabled(bool)));
|
||||
connect(_connectionName, SIGNAL(textChanged(QString)), this, SLOT(updateParametersPageStatus()));
|
||||
|
@ -92,10 +90,6 @@ void KNetAttach::setInformationText(const QString &type)
|
|||
text = i18n("Enter a name for this <i>File Transfer Protocol connection</i> as well as a server address and folder path to use and press the <b>Save & Connect</b> button.");
|
||||
} else if (type=="SFTP") {
|
||||
text = i18n("Enter a name for this <i>SSH File Transfer Protocol</i> as well as a server address, port and folder path to use and press the <b>Save & Connect</b> button.");
|
||||
} else if (type=="NFS") {
|
||||
text = i18n("Enter a name for this <i>Network File System</i> as well as a server address, port and folder path to use and press the <b>Save & Connect</b> button.");
|
||||
} else if (type=="SMB") {
|
||||
text = i18n("Enter a name for this <i>Microsoft Windows network drive</i> as well as a server address and folder path to use and press the <b>Save & Connect</b> button.");
|
||||
}
|
||||
|
||||
_informationText->setText(text);
|
||||
|
@ -130,16 +124,6 @@ bool KNetAttach::validateCurrentPage()
|
|||
if (_path->text().isEmpty()) {
|
||||
_path->setText("/");
|
||||
}
|
||||
} else if (_nfs->isChecked()) {
|
||||
setInformationText("NFS");
|
||||
updateForProtocol("NFS");
|
||||
_port->setValue(2049);
|
||||
if (_path->text().isEmpty()) {
|
||||
_path->setText("/");
|
||||
}
|
||||
} else if (_smb->isChecked()) {
|
||||
setInformationText("SMB");
|
||||
updateForProtocol("SMB");
|
||||
} else { //if (_recent->isChecked()) {
|
||||
KConfig recent( "krecentconnections", KConfig::NoGlobals );
|
||||
if (!recent.hasGroup(_recentConnectionName->currentText())) {
|
||||
|
@ -186,11 +170,6 @@ bool KNetAttach::validateCurrentPage()
|
|||
} else if (_type == "SFTP") {
|
||||
url.setProtocol("sftp");
|
||||
url.setPort(_port->value());
|
||||
} else if (_type == "NFS") {
|
||||
url.setProtocol("nfs");
|
||||
url.setPort(_port->value());
|
||||
} else if (_type == "SMB") {
|
||||
url.setProtocol("smb");
|
||||
} else { // recent
|
||||
}
|
||||
|
||||
|
@ -252,7 +231,7 @@ bool KNetAttach::validateCurrentPage()
|
|||
}
|
||||
recent = KConfigGroup(&_recent,name);
|
||||
recent.writeEntry("URL", url.prettyUrl());
|
||||
if (_type == "FTP" || _type == "SFTP" || _type == "NFS") {
|
||||
if (_type == "FTP" || _type == "SFTP") {
|
||||
recent.writeEntry("Port", _port->value());
|
||||
}
|
||||
recent.writeEntry("Type", _type);
|
||||
|
@ -289,20 +268,6 @@ bool KNetAttach::updateForProtocol(const QString& protocol)
|
|||
_user->show();
|
||||
_encodingText->hide();
|
||||
_encoding->hide();
|
||||
} else if (protocol == "NFS") {
|
||||
_portText->show();
|
||||
_port->show();
|
||||
_userText->show();
|
||||
_user->show();
|
||||
_encodingText->hide();
|
||||
_encoding->hide();
|
||||
} else if (protocol == "SMB") {
|
||||
_portText->hide();
|
||||
_port->hide();
|
||||
_userText->hide();
|
||||
_user->hide();
|
||||
_encodingText->hide();
|
||||
_encoding->hide();
|
||||
} else {
|
||||
_type = "";
|
||||
return false;
|
||||
|
|
|
@ -59,14 +59,7 @@
|
|||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="3" column="0">
|
||||
<widget class="QRadioButton" name="_nfs">
|
||||
<property name="text">
|
||||
<string>N&etwork File System (nfs)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="3" column="1">
|
||||
<widget class="KComboBox" name="_recentConnectionName">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
|
@ -85,13 +78,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QRadioButton" name="_recent">
|
||||
<property name="text">
|
||||
<string>&Recent connection:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="_ftp">
|
||||
<property name="text">
|
||||
|
@ -102,6 +88,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QRadioButton" name="_recent">
|
||||
<property name="text">
|
||||
<string>&Recent connection:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="_sftp">
|
||||
<property name="text">
|
||||
|
@ -112,13 +105,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QRadioButton" name="_smb">
|
||||
<property name="text">
|
||||
<string>&Microsoft® Windows® network drive (smb)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include <solid/block.h>
|
||||
#include <solid/storagevolume.h>
|
||||
#include <solid/storageaccess.h>
|
||||
#include <solid/networkshare.h>
|
||||
#include <solid/solidnamespace.h>
|
||||
|
||||
#include "deviceactionsdialog.h"
|
||||
|
@ -177,37 +176,6 @@ void SolidUiServer::onActionDialogFinished()
|
|||
int SolidUiServer::mountDevice(const QString &udi)
|
||||
{
|
||||
Solid::Device device(udi);
|
||||
|
||||
Solid::NetworkShare *networkshare = device.as<Solid::NetworkShare>();
|
||||
if (networkshare) {
|
||||
// qDebug() << Q_FUNC_INFO << udi << networkshare->url();
|
||||
|
||||
const QString deviceuuid = device.product();
|
||||
QString devicenode;
|
||||
QString devicefstype;
|
||||
switch (networkshare->type()) {
|
||||
case Solid::NetworkShare::Unknown: {
|
||||
return int(Solid::ErrorType::MissingDriver);
|
||||
}
|
||||
case Solid::NetworkShare::Nfs: {
|
||||
devicenode = QString::fromLatin1("%1:%2").arg(device.product()).arg(device.vendor());
|
||||
devicefstype = QString::fromLatin1("nfs");
|
||||
break;
|
||||
}
|
||||
case Solid::NetworkShare::Cifs: {
|
||||
devicenode = QString::fromLatin1("//%1/%2").arg(device.product()).arg(device.vendor());
|
||||
devicefstype = QString::fromLatin1("cifs");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
kWarning() << "Invalid network share type" << networkshare->type();
|
||||
return int(Solid::ErrorType::InvalidOption);
|
||||
}
|
||||
}
|
||||
|
||||
return doMount(deviceuuid, devicenode, devicefstype);
|
||||
}
|
||||
|
||||
Solid::StorageVolume *storagevolume = device.as<Solid::StorageVolume>();
|
||||
Solid::Block *block = device.as<Solid::Block>();
|
||||
if (!storagevolume || !block) {
|
||||
|
@ -271,13 +239,7 @@ int SolidUiServer::mountDevice(const QString &udi)
|
|||
int SolidUiServer::unmountDevice(const QString &udi)
|
||||
{
|
||||
Solid::Device device(udi);
|
||||
|
||||
Solid::NetworkShare *networkshare = device.as<Solid::NetworkShare>();
|
||||
Solid::StorageAccess *storageaccess = device.as<Solid::StorageAccess>();
|
||||
if (networkshare && storageaccess) {
|
||||
return doUnmount(storageaccess->filePath());
|
||||
}
|
||||
|
||||
Solid::StorageVolume *storagevolume = device.as<Solid::StorageVolume>();
|
||||
if (!storagevolume || !storageaccess) {
|
||||
return int(Solid::ErrorType::InvalidOption);
|
||||
|
|
Loading…
Add table
Reference in a new issue