linuxÏÂntpʵÏÖ
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define NTP_SERVER "clock.via.net"
#define NTP_PORT 123
//
//rfc1305 defined from 1900 so also 2208988800 (1900 - 1970 ) seconds left
//
//timeval.tv_sec + JAN_1970 = timestamp.coarse
#define JAN_1970 0x83aa7e80
//timeval.tv_usec=>timestamp.fine
#define NTPFRAC(x) (4294 * (x) + ((1981 * (x))>>11))
//timeval.tv_usec<=timestamp.fine
#define USEC(x) (((x) >> 12) - 759 * ((((x) >> 10) + 32768) >> 16))
#define Data(i) ntohl(((unsigned int *)data)[i])
#define LI 0
#define VN 3
#define MODE 3
#define STRATUM 0
#define POLL 4
#define PREC -6
struct ntptime
{
unsigned int coarse;
unsigned int fine;
};
void send_packet(int fd)
{
unsigned int data[12];
struct timeval now;
int ret;
if (sizeof(data) != 48)
{
fprintf(stderr,"size error\n");
return;
}
memset((char*)data, 0, sizeof(data));
data[0] = htonl((LI << 30) | (VN << 27) | (MODE << 24)
| (STRATUM << 16) | (POLL << 8) | (PREC & 0xff));
data[1] = htonl(1<<16); /* Root Delay (seconds) */
data[2] = htonl(1<<16); /* Root Dispersion (seconds) */
gettimeofday(&now, NULL);
data[10] = htonl(now.tv_sec + JAN_1970); /* Transmit Timestamp coarse */
data[11] = htonl(NTPFRAC(now.tv_usec)); /* Transmit Timestamp fine */
send(fd, data, 48, 0);
}
void get_udp_arrival_local_timestamp(struct ntptime *udp_arrival_local_timestamp)
{
struct timeval udp_arrival_local_time;
gettimeofday(&udp_arrival_local_time, NULL);
//print just precise to second
printf("local time=>%s\n",ctime(&(udp_arrival_local_time.tv_sec)));
}
void get_new_time(unsigned i
Ïà¹ØÎĵµ£º
°²×°rpm°ü
ÅäÖãº
ÖØÆðvsftpd·þÎñ£ºservice vsftpd restart
Æô¶¯vsftpd·þÎñ£ºservice vsftpd start
1£® ÄäÃû·þÎñÆ÷µÄÁ¬½Ó£¨¶ÀÁ¢µÄ·þÎñÆ÷£©
ÐÞ¸Ä/etc/vsftpd/vsftpd.confÅäÖÃÎļþÒ»ÏÂÏûÓÐÔòÌí¼Ó£º
Anonymous_enable=yes (ÔÊÐíÄäÃûµÇ½)
Dirmessage_enable=yes
£¨Çл»Ä¿Â¼Ê±£¬ÏÔʾĿ¼ÏÂ.messageµÄÄÚÈÝ£©
Loca ......
Óû§¿ÉÒÔÓÃÈκα༳ÌÐòÀ´±àдShell³ÌÐò¡£ÒòΪShell³ÌÐòÊǽâÊÍÖ´Ðеģ¬ËùÒÔ²»ÐèÒª±àÒë³ÉÄ¿µÄ³ÌÐò¡£°´ÕÕShell±à³ÌµÄ¹ßÀý£¬ÒÔ bashΪÀý£¬³ÌÐòµÄµÚÒ»ÐÐÒ»°ãΪ“#£¡/bin/bash”£¬ÆäÖÐ # ±íʾ¸ÃÐÐÊÇ×¢ÊÍ£¬Ì¾ºÅ £¡ ¸æËßShellÔËÐÐ̾ºÅÖ®ºóµÄÃüÁî²¢ÓÃÎĵµµÄÆäÓಿ·Ö×÷ΪÊäÈ룬Ҳ¾ÍÊÇÔËÐÐ/bin/bash²¢ÈÃ/bin/bashÈ¥Ö´ÐÐShel ......
linux limits.conf ÅäÖÃ
¡¡¡¡limits.conf Îļþʵ¼ÊÊÇ Linux PAM£¨²åÈëʽÈÏ֤ģ¿é£¬Pluggable Authentication Modules£©ÖÐ pam_limits.so µÄÅäÖÃÎļþ£¬¶øÇÒÖ»Õë¶ÔÓÚµ¥¸ö»á»°¡£
¡¡¡¡limits.confµÄ¸ñʽÈçÏ£º
¡¡¡¡username|@groupname type resource limit
¡¡¡¡username|@groupname£ºÉèÖÃÐèÒª±»ÏÞÖÆµÄÓû§Ãû£¬×éÃûÇ°Ãæ¼Ó@º ......
Book Note: Linux Device Driver Dos and Don'ts
http://janitor.kernelnewbies.org/docs/driver-howto.html
what a hardened (robust) device
driver should mean and how it should be implemented and measured.
1.3 Robust device drivers
-Follows the Linux CodingStyle.
-Efficient in managing faults and ha ......
²»ÖªµÀÔÚʲçÛʱºò£¬×ªÔØLinux ³öÏÖÁË module ÕâÖÖ¶«Î÷£¬µÄÈ·£¬ËüÊÇ Linux µÄÒ»´ó¸ïС£ÓÐÁË module Ö®ºó£¬Ð´
device driver ²»ÔÙÊÇÒ»Ïî¶ñÃΣ¬ÐÞ¸Ä kernel Ò²²»ÔÙÊÇÒ»¼þÍ´¿àµÄÊÂÁË¡£ÒòΪÄã²»ÐèҪÿ´ÎÒª²âÊÔ driver ¾ÍÖØÐÂ
compile kernel Ò»´Î¡£ÄǼòÖ±ÊÇ»áÀÛËÀÈË¡£Module ¿ÉÒÔÔÊÐíÎÒÃǶ¯Ì¬µÄ¸Ä±ä kernel£¬¼ÓÔØ device
dri ......