48 #include <io/config-kdirwatch.h>
54 #include <QtCore/QDir>
55 #include <QtCore/QFile>
56 #include <QtCore/QSocketNotifier>
57 #include <QtCore/QTimer>
58 #include <QtCore/QCoreApplication>
71 #include <sys/ioctl.h>
74 #include <sys/utsname.h>
89 if (method == QLatin1String(
"Fam")) {
91 }
else if (method == QLatin1String(
"Stat")) {
93 }
else if (method == QLatin1String(
"QFSWatch")) {
158 delayRemove( false ),
162 timer.setObjectName(QLatin1String(
"KDirWatchPrivate::timer"));
175 QList<QByteArray> availableMethods;
177 availableMethods <<
"Stat";
180 rescan_timer.setObjectName(QString::fromLatin1(
"KDirWatchPrivate::rescan_timer"));
186 if (FAMOpen(&fc) ==0) {
187 availableMethods <<
"FAM";
189 sn =
new QSocketNotifier( FAMCONNECTION_GETFD(&fc),
190 QSocketNotifier::Read,
this);
191 connect( sn, SIGNAL(activated(
int)),
195 kDebug(7001) <<
"Can't use FAM (fam daemon not running?)";
200 #ifdef HAVE_SYS_INOTIFY_H
201 supports_inotify =
true;
203 m_inotify_fd = inotify_init();
205 if ( m_inotify_fd <= 0 ) {
206 kDebug(7001) <<
"Can't use Inotify, kernel doesn't support it";
207 supports_inotify =
false;
212 int major, minor, patch;
213 if (uname(&uts) < 0) {
214 supports_inotify =
false;
215 kDebug(7001) <<
"Unable to get uname";
216 }
else if (sscanf(uts.release,
"%d.%d", &major, &minor) != 2) {
217 supports_inotify =
false;
218 kDebug(7001) <<
"The version is malformed: " << uts.release;
219 }
else if(major == 2 && minor == 6) {
220 if (sscanf(uts.release,
"%d.%d.%d", &major, &minor, &patch) != 3) {
221 supports_inotify =
false;
222 kDebug() <<
"Detected 2.6 kernel but can't know more: " << uts.release;
223 }
else if (major * 1000000 + minor * 1000 + patch < 2006014 ){
224 supports_inotify =
false;
225 kDebug(7001) <<
"Can't use INotify, Linux kernel too old " << uts.release;
230 kDebug(7001) <<
"INotify available: " << supports_inotify;
231 if ( supports_inotify ) {
232 availableMethods <<
"INotify";
233 fcntl(m_inotify_fd, F_SETFD, FD_CLOEXEC);
235 mSn =
new QSocketNotifier( m_inotify_fd, QSocketNotifier::Read,
this );
236 connect( mSn, SIGNAL(activated(
int)),
240 #ifdef HAVE_QFILESYSTEMWATCHER
241 availableMethods <<
"QFileSystemWatcher";
262 #ifdef HAVE_SYS_INOTIFY_H
263 if ( supports_inotify )
264 ::close( m_inotify_fd );
266 #ifdef HAVE_QFILESYSTEMWATCHER
274 #ifdef HAVE_SYS_INOTIFY_H
275 if ( !supports_inotify )
279 int offsetStartRead = 0;
281 assert( m_inotify_fd > -1 );
282 ioctl( m_inotify_fd, FIONREAD, &pending );
284 while ( pending > 0 ) {
286 const int bytesToRead = qMin( pending, (
int)
sizeof( buf ) - offsetStartRead );
288 int bytesAvailable = read( m_inotify_fd, &buf[offsetStartRead], bytesToRead );
289 pending -= bytesAvailable;
290 bytesAvailable += offsetStartRead;
293 int offsetCurrent = 0;
294 while ( bytesAvailable >= (
int)
sizeof(
struct inotify_event ) ) {
295 const struct inotify_event *
const event = (
struct inotify_event *) &buf[offsetCurrent];
296 const int eventSize =
sizeof(
struct inotify_event ) + event->len;
297 if ( bytesAvailable < eventSize ) {
301 bytesAvailable -= eventSize;
302 offsetCurrent += eventSize;
305 QByteArray cpath(event->name, event->len);
307 path = QFile::decodeName ( cpath );
319 if ( e->wd == event->wd ) {
326 if( event->mask & IN_DELETE_SELF) {
327 if (s_verboseDebug) {
328 kDebug(7001) <<
"-->got deleteself signal for" << e->
path;
337 if ( event->mask & IN_IGNORED ) {
341 if ( event->mask & (IN_CREATE|IN_MOVED_TO) ) {
342 const QString tpath = e->
path + QLatin1Char(
'/') + path;
345 if (s_verboseDebug) {
346 kDebug(7001) <<
"-->got CREATE signal for" << (tpath) <<
"sub_entry=" << sub_entry;
353 sub_entry->
dirty =
true;
358 Q_FOREACH(
Client *client, clients) {
366 if (!clients.isEmpty()) {
368 kDebug(7001).nospace() << clients.count() <<
" instance(s) monitoring the new "
369 << (isDir ?
"dir " :
"file ") << tpath;
371 e->m_pendingFileChanges.append(e->
path);
376 if (event->mask & (IN_DELETE|IN_MOVED_FROM)) {
377 const QString tpath = e->
path + QLatin1Char(
'/') + path;
378 if (s_verboseDebug) {
379 kDebug(7001) <<
"-->got DELETE signal for" << tpath;
387 KDE_struct_stat stat_buf;
392 bool isDir = S_ISDIR(stat_buf.st_mode);
406 if (event->mask & (IN_MODIFY|IN_ATTRIB)) {
408 const QString tpath = e->
path + QLatin1Char(
'/') + path;
409 if (s_verboseDebug) {
410 kDebug(7001) <<
"-->got MODIFY signal for" << (tpath);
427 e->m_pendingFileChanges.append(tpath);
438 if (bytesAvailable > 0) {
440 memmove(buf, &buf[offsetCurrent], bytesAvailable);
441 offsetStartRead = bytesAvailable;
455 if (!sub_entry->
dirty)
457 sub_entry->
dirty =
true;
468 KDirWatch::WatchModes watchModes)
473 foreach(
Client* client, m_clients) {
488 m_clients.append(client);
493 QList<Client *>::iterator it = m_clients.begin();
494 const QList<Client *>::iterator end = m_clients.end();
495 for ( ; it != end ; ++it ) {
499 if (client->
count == 0) {
512 foreach(
Client* client, m_clients)
513 clients += client->
count;
520 return QDir::cleanPath(path + QLatin1String(
"/.."));
526 KDE_struct_stat stat_buf;
528 *isDir = S_ISDIR(stat_buf.st_mode);
529 const KDirWatch::WatchModes flag =
531 Q_FOREACH(
Client *client, this->m_clients) {
547 debug.nospace() <<
"[ Entry for " << entry.
path <<
", " << (entry.
isDir ?
"dir" :
"file");
549 debug <<
", non-existent";
555 #ifdef HAVE_SYS_INOTIFY_H
557 debug <<
" inotify_wd=" << entry.wd;
559 debug <<
", has " << entry.
m_clients.count() <<
" clients";
562 debug <<
", nonexistent subentries:";
564 debug << subEntry << subEntry->
path;
573 if (_path.isEmpty() || QDir::isRelativePath(_path)) {
579 if ( path.length() > 1 && path.endsWith( QLatin1Char(
'/' ) ) )
580 path.truncate( path.length() - 1 );
598 kDebug(7001) <<
"Global Poll Freq is now" <<
freq <<
"msec";
603 #if defined(HAVE_FAM)
605 bool KDirWatchPrivate::useFAM(Entry* e)
607 if (!use_fam)
return false;
619 addEntry(0, e->parentDirectory(), e,
true);
622 int res =FAMMonitorDirectory(&fc, QFile::encodeName(e->path),
630 kDebug(7001).nospace() <<
" Setup FAM (Req " << FAMREQUEST_GETREQNUM(&(e->fr))
631 <<
") for " << e->path;
637 addEntry(0, QFileInfo(e->path).absolutePath(), e,
true);
640 int res = FAMMonitorFile(&fc, QFile::encodeName(e->path),
649 kDebug(7001).nospace() <<
" Setup FAM (Req " << FAMREQUEST_GETREQNUM(&(e->fr))
650 <<
") for " << e->path;
662 #ifdef HAVE_SYS_INOTIFY_H
664 bool KDirWatchPrivate::useINotify( Entry* e )
671 if (!supports_inotify)
return false;
676 addEntry(0, e->parentDirectory(), e,
true);
681 int mask = IN_DELETE|IN_DELETE_SELF|IN_CREATE|IN_MOVE|IN_MOVE_SELF|IN_DONT_FOLLOW|IN_MOVED_FROM|IN_MODIFY|IN_ATTRIB;
683 if ( ( e->wd = inotify_add_watch( m_inotify_fd,
684 QFile::encodeName( e->path ), mask) ) >= 0)
686 if (s_verboseDebug) {
687 kDebug(7001) <<
"inotify successfully used for monitoring" << e->path <<
"wd=" << e->wd;
692 kDebug(7001) <<
"inotify failed for monitoring" << e->path <<
":" << strerror(errno);
696 #ifdef HAVE_QFILESYSTEMWATCHER
707 kDebug(7001) <<
"fsWatcher->addPath" << e->
path;
732 kDebug(7001) <<
" Started Polling Timer, freq " <<
freq;
736 kDebug(7001) <<
" Setup Stat (freq " << e->
freq <<
") for " << e->
path;
748 Entry* sub_entry,
bool isDir, KDirWatch::WatchModes watchModes)
753 || path == QLatin1String(
"/dev")
754 || (path.startsWith(QLatin1String(
"/dev/")) && !path.startsWith(QLatin1String(
"/dev/.")))
759 if ( path.length() > 1 && path.endsWith( QLatin1Char(
'/' ) ) )
760 path.truncate( path.length() - 1 );
766 (*it).m_entries.append(sub_entry);
767 if (s_verboseDebug) {
768 kDebug(7001) <<
"Added already watched Entry" << path
769 <<
"(for" << sub_entry->
path <<
")";
771 #ifdef HAVE_SYS_INOTIFY_H
774 int mask = IN_DELETE|IN_DELETE_SELF|IN_CREATE|IN_MOVE|IN_MOVE_SELF|IN_DONT_FOLLOW;
776 mask |= IN_MODIFY|IN_ATTRIB;
780 inotify_rm_watch (m_inotify_fd, e->wd);
781 e->wd = inotify_add_watch( m_inotify_fd, QFile::encodeName( e->
path ),
788 (*it).addClient(instance, watchModes);
789 if (s_verboseDebug) {
790 kDebug(7001) <<
"Added already watched Entry" << path
791 <<
"(now" << (*it).clientCount() <<
"clients)"
792 << QString::fromLatin1(
"[%1]").arg(instance->objectName());
800 KDE_struct_stat stat_buf;
801 bool exists = (
KDE::stat(path, &stat_buf) == 0);
805 Entry* e = &(*newIt);
808 e->
isDir = S_ISDIR(stat_buf.st_mode);
810 if (e->
isDir && !isDir) {
812 if (S_ISLNK(stat_buf.st_mode))
816 qWarning() <<
"KDirWatch:" << path <<
"is a directory. Use addDir!";
817 }
else if (!e->
isDir && isDir)
818 qWarning(
"KDirWatch: %s is a file. Use addFile!", qPrintable(path));
821 qWarning() <<
"KDirWatch:" << path <<
"is a file. You can't use recursive or "
822 "watchFiles options";
828 e->
m_ctime = stat_buf.st_mtime;
830 e->
m_ctime = stat_buf.st_ctime;
833 e->
m_nlink = stat_buf.st_nlink;
834 e->
m_ino = stat_buf.st_ino;
850 kDebug(7001).nospace() <<
"Added " << (e->
isDir ?
"Dir " :
"File ") << path
852 <<
" for " << (sub_entry ? sub_entry->
path :
QString())
853 <<
" [" << (instance ? instance->objectName() :
QString()) <<
"]";
863 QFlags<QDir::Filter> filters = QDir::NoDotAndDotDot;
867 filters |= (QDir::Dirs|QDir::Files);
868 }
else if (watchModes & KDirWatch::WatchSubDirs) {
869 filters |= QDir::Dirs;
871 filters |= QDir::Files;
874 #if defined(HAVE_SYS_INOTIFY_H)
881 filters &= ~QDir::Files;
885 QDir basedir (e->
path);
886 const QFileInfoList contents = basedir.entryInfoList(filters);
887 for (QFileInfoList::const_iterator iter = contents.constBegin();
888 iter != contents.constEnd(); ++iter)
890 const QFileInfo &fileInfo = *iter;
892 bool isDir = fileInfo.isDir() && !fileInfo.isSymLink();
894 addEntry (instance, fileInfo.absoluteFilePath(), 0, isDir,
920 bool entryAdded =
false;
921 switch (preferredMethod) {
922 #if defined(HAVE_FAM)
925 #if defined(HAVE_SYS_INOTIFY_H)
928 #if defined(HAVE_QFILESYSTEMWATCHER)
937 #if defined(HAVE_SYS_INOTIFY_H)
938 if (useINotify(e))
return;
940 #if defined(HAVE_FAM)
941 if (useFAM(e))
return;
943 #if defined(HAVE_QFILESYSTEMWATCHER)
954 FAMCancelMonitor(&fc, &(e->fr) );
955 kDebug(7001).nospace() <<
"Cancelled FAM (Req " << FAMREQUEST_GETREQNUM(&(e->fr))
956 <<
") for " << e->
path;
959 #ifdef HAVE_SYS_INOTIFY_H
961 (void) inotify_rm_watch( m_inotify_fd, e->wd );
962 if (s_verboseDebug) {
963 kDebug(7001).nospace() <<
"Cancelled INotify (fd " << m_inotify_fd <<
", "
964 << e->wd <<
") for " << e->
path;
968 #ifdef HAVE_QFILESYSTEMWATCHER
971 kDebug(7001) <<
"fsWatcher->removePath" << e->
path;
981 if (s_verboseDebug) {
982 kDebug(7001) <<
"path=" << _path <<
"sub_entry:" << sub_entry;
986 kWarning(7001) <<
"doesn't know" << _path;
1027 kDebug(7001) <<
" Stopped Polling Timer";
1031 if (s_verboseDebug) {
1032 kDebug(7001).nospace() <<
"Removed " << (e->
isDir ?
"Dir ":
"File ") << e->
path
1033 <<
" for " << (sub_entry ? sub_entry->
path :
QString())
1034 <<
" [" << (instance ? instance->objectName() :
QString()) <<
"]";
1045 int minfreq = 3600000;
1052 foreach(
Client* client, (*it).m_clients) {
1053 if (client->
instance == instance) {
1060 pathList.append((*it).path);
1062 else if ( (*it).m_mode ==
StatMode && (*it).freq < minfreq )
1063 minfreq = (*it).freq;
1066 foreach(
const QString &path, pathList)
1069 if (minfreq >
freq) {
1073 kDebug(7001) <<
"Poll Freq now" <<
freq <<
"msec";
1080 int stillWatching = 0;
1082 if (!instance || instance == client->
instance)
1085 stillWatching += client->
count;
1088 kDebug(7001) << (instance ? instance->objectName() : QString::fromLatin1(
"all"))
1089 <<
"stopped scanning" << e->
path <<
"(now"
1090 << stillWatching <<
"watchers)";
1092 if (stillWatching == 0) {
1107 int wasWatching = 0, newWatching = 0;
1110 wasWatching += client->
count;
1111 else if (!instance || instance == client->
instance) {
1113 newWatching += client->
count;
1116 if (newWatching == 0)
1119 kDebug(7001) << (instance ? instance->objectName() : QString::fromLatin1(
"all"))
1120 <<
"restarted scanning" << e->
path
1121 <<
"(now" << wasWatching+newWatching <<
"watchers)";
1126 if (wasWatching == 0) {
1128 KDE_struct_stat stat_buf;
1133 e->
m_ctime = stat_buf.st_mtime;
1135 e->
m_ctime = stat_buf.st_ctime;
1138 if (s_verboseDebug) {
1139 kDebug(7001) <<
"Setting status to Normal for" << e << e->
path;
1141 e->
m_nlink = stat_buf.st_nlink;
1142 e->
m_ino = stat_buf.st_ino;
1151 if (s_verboseDebug) {
1152 kDebug(7001) <<
"Setting status to NonExistent for" << e << e->
path;
1174 bool notify,
bool skippedToo )
1193 foreach(
Client* client, (*it).m_clients) {
1223 KDE_struct_stat stat_buf;
1230 e->
m_ctime = qMax(stat_buf.st_ctime, stat_buf.st_mtime);
1232 e->
m_ino = stat_buf.st_ino;
1233 if (s_verboseDebug) {
1234 kDebug(7001) <<
"Setting status to Normal for just created" << e << e->
path;
1242 #if 1 // for debugging the if() below
1243 if (s_verboseDebug) {
1244 struct tm* tmp = localtime(&e->
m_ctime);
1246 strftime(outstr,
sizeof(outstr),
"%T", tmp);
1248 <<
"stat_buf.st_ctime=" << stat_buf.st_ctime
1249 <<
"e->m_nlink=" << e->
m_nlink
1250 <<
"stat_buf.st_nlink=" << stat_buf.st_nlink
1251 <<
"e->m_ino=" << e->
m_ino
1252 <<
"stat_buf.st_ino=" << stat_buf.st_ino;
1257 (qMax(stat_buf.st_ctime, stat_buf.st_mtime) != e->
m_ctime ||
1258 stat_buf.st_ino != e->
m_ino ||
1259 stat_buf.st_nlink != nlink_t(e->
m_nlink)))
1267 e->
m_ctime = qMax(stat_buf.st_ctime, stat_buf.st_mtime);
1268 e->
m_nlink = stat_buf.st_nlink;
1269 if (e->
m_ino != stat_buf.st_ino) {
1274 e->
m_ino = stat_buf.st_ino;
1302 if (!fileName.isEmpty()) {
1303 if (!QDir::isRelativePath(fileName))
1307 path += QLatin1Char(
'/') + fileName;
1308 #elif defined(Q_WS_WIN)
1310 path += QDir::currentPath().left(2) + QLatin1Char(
'/') + fileName;
1315 if (s_verboseDebug) {
1340 QMetaObject::invokeMethod(c->
instance,
"setDeleted", Qt::QueuedConnection, Q_ARG(
QString, path));
1346 QMetaObject::invokeMethod(c->
instance,
"setCreated", Qt::QueuedConnection, Q_ARG(
QString, path));
1351 QMetaObject::invokeMethod(c->
instance,
"setDirty", Qt::QueuedConnection, Q_ARG(
QString, path));
1377 EntryMap::Iterator it;
1383 bool timerRunning =
timer.isActive();
1406 (*it).propagate_dirty();
1409 #ifdef HAVE_SYS_INOTIFY_H
1410 QList<Entry*> cList;
1417 if (!entry->
isValid())
continue;
1421 kDebug(7001) <<
"scanEntry for" << entry->
path <<
"says" << ev;
1424 #ifdef HAVE_SYS_INOTIFY_H
1428 kDebug(7001) <<
"scanEntry says" << entry->
path <<
"was deleted";
1432 kDebug(7001) <<
"scanEntry says" << entry->
path <<
"was created. wd=" << entry->wd;
1433 if (entry->wd < 0) {
1434 cList.append(entry);
1451 #ifdef HAVE_SYS_INOTIFY_H
1457 QStringList pendingFileChanges = entry->m_pendingFileChanges;
1458 pendingFileChanges.removeDuplicates();
1459 Q_FOREACH(
const QString &changedFilename, pendingFileChanges) {
1460 if (s_verboseDebug) {
1461 kDebug(7001) <<
"processing pending file change for" << changedFilename;
1465 entry->m_pendingFileChanges.clear();
1477 #ifdef HAVE_SYS_INOTIFY_H
1479 Q_FOREACH(
Entry* e, cList)
1489 if ( *filename ==
'.') {
1490 if (strncmp(filename,
".X.err", 6) == 0)
return true;
1491 if (strncmp(filename,
".xsession-errors", 16) == 0)
return true;
1494 if (strncmp(filename,
".fonts.cache", 12) == 0)
return true;
1509 while(use_fam && FAMPending(&fc)) {
1510 if (FAMNextEvent(&fc, &fe) == -1) {
1511 kWarning(7001) <<
"FAM connection problem, switching to polling.";
1518 if ((*it).m_mode ==
FAMMode && (*it).m_clients.count()>0) {
1530 void KDirWatchPrivate::checkFAMEvent(FAMEvent* fe)
1535 if ((fe->code == FAMExists) ||
1536 (fe->code == FAMEndExist) ||
1537 (fe->code == FAMAcknowledge))
return;
1545 if (FAMREQUEST_GETREQNUM(&( (*it).fr )) ==
1546 FAMREQUEST_GETREQNUM(&(fe->fr)) ) {
1553 if (s_verboseDebug) {
1554 kDebug(7001) <<
"Processing FAM event ("
1555 << ((fe->code == FAMChanged) ?
"FAMChanged" :
1556 (fe->code == FAMDeleted) ?
"FAMDeleted" :
1557 (fe->code == FAMStartExecuting) ?
"FAMStartExecuting" :
1558 (fe->code == FAMStopExecuting) ?
"FAMStopExecuting" :
1559 (fe->code == FAMCreated) ?
"FAMCreated" :
1560 (fe->code == FAMMoved) ?
"FAMMoved" :
1561 (fe->code == FAMAcknowledge) ?
"FAMAcknowledge" :
1562 (fe->code == FAMExists) ?
"FAMExists" :
1563 (fe->code == FAMEndExist) ?
"FAMEndExist" :
"Unknown Code")
1564 <<
", " << fe->filename
1565 <<
", Req " << FAMREQUEST_GETREQNUM(&(fe->fr)) <<
") e=" << e;
1575 kDebug(7001) <<
"FAM event for nonExistent entry " << e->path;
1588 if (!QDir::isRelativePath(QFile::decodeName(fe->filename))) {
1589 FAMCancelMonitor(&fc, &(e->fr) );
1590 kDebug(7001) <<
"Cancelled FAMReq"
1591 << FAMREQUEST_GETREQNUM(&(e->fr))
1592 <<
"for" << e->path;
1597 addEntry(0, e->parentDirectory(), e,
true );
1608 QString tpath(e->path + QLatin1Char(
'/') + QFile::decodeName(fe->filename));
1611 Entry* sub_entry = e->findSubEntry(tpath);
1615 sub_entry->dirty =
true;
1617 }
else if (e->isDir && !e->m_clients.empty()) {
1619 const QList<Client *> clients = e->clientsForFileOrDir(tpath, &isDir);
1620 Q_FOREACH(Client *client, clients) {
1621 addEntry (client->instance, tpath, 0, isDir,
1625 if (!clients.isEmpty()) {
1628 kDebug(7001).nospace() << clients.count() <<
" instance(s) monitoring the new "
1629 << (isDir ?
"dir " :
"file ") << tpath;
1641 kWarning (7001) <<
"Fam event received but FAM is not supported";
1648 EntryMap::Iterator it;
1650 kDebug(7001) <<
"Entries watched:";
1652 kDebug(7001) <<
" None.";
1658 kDebug(7001) <<
" " << *e;
1666 if (!pending.isEmpty()) pending =
" (pending: " + pending +
')';
1667 pending =
", stopped" + pending;
1670 <<
" (" << c->
count <<
" times)" << pending;
1673 kDebug(7001) <<
" dependent entries:";
1676 if (s_verboseDebug) {
1685 #ifdef HAVE_QFILESYSTEMWATCHER
1697 kDebug(7001) <<
"scanEntry for" << e->
path <<
"says" << ev;
1704 addEntry(0, QFileInfo(e->
path).absolutePath(), e,
true);
1708 }
else if (e->
isDir) {
1720 kWarning (7001) <<
"QFileSystemWatcher event received but QFileSystemWatcher is not supported";
1722 #endif // HAVE_QFILESYSTEMWATCHER
1731 return s_pKDirWatchSelf;
1737 return s_pKDirWatchSelf.exists();
1742 s_pKDirWatchSelf->deleteQFSWatcher();
1748 static int nameCounter = 0;
1751 setObjectName(QString::fromLatin1(
"KDirWatch-%1").arg(nameCounter) );
1757 static bool cleanupRegistered =
false;
1758 if (!cleanupRegistered) {
1759 cleanupRegistered =
true;
1778 if (d) d->
addEntry(
this, _path, 0,
true, watchModes);
1786 d->
addEntry(
this, _path, 0,
false);
1874 kDebug(7001) <<
"KDirWatch not used";
1883 kDebug(7001) << objectName() <<
"emitting created" << _file;
1890 emit
dirty( _file );
1895 kDebug(7001) << objectName() <<
"emitting deleted" << _file;
1905 #include "kdirwatch.moc"
1906 #include "kdirwatch_p.moc"