⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 status.c

📁 samba-3.0.22.tar.gz 编译smb服务器的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
/*    Unix SMB/CIFS implementation.   status reporting   Copyright (C) Andrew Tridgell 1994-1998      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., 675 Mass Ave, Cambridge, MA 02139, USA.   Revision History:   12 aug 96: Erik.Devriendt@te6.siemens.be   added support for shared memory implementation of share mode locking   21-Jul-1998: rsharpe@ns.aus.com (Richard Sharpe)   Added -L (locks only) -S (shares only) flags and code*//* * This program reports current SMB connections */#include "includes.h"#define SMB_MAXPIDS		2048static uid_t 		Ucrit_uid = 0;               /* added by OH */static pid_t		Ucrit_pid[SMB_MAXPIDS];  /* Ugly !!! */   /* added by OH */static int		Ucrit_MaxPid=0;                    /* added by OH */static unsigned int	Ucrit_IsActive = 0;                /* added by OH */static int verbose, brief;static int            shares_only = 0;            /* Added by RJS */static int            locks_only  = 0;            /* Added by RJS */static BOOL processes_only=False;static int show_brl;static BOOL numeric_only = False;const char *username = NULL;/* added by OH */static void Ucrit_addUid(uid_t uid){	Ucrit_uid = uid;	Ucrit_IsActive = 1;}static unsigned int Ucrit_checkUid(uid_t uid){	if ( !Ucrit_IsActive ) 		return 1;		if ( uid == Ucrit_uid ) 		return 1;		return 0;}static unsigned int Ucrit_checkPid(pid_t pid){	int i;		if ( !Ucrit_IsActive ) 		return 1;		for (i=0;i<Ucrit_MaxPid;i++) {		if( pid == Ucrit_pid[i] ) 			return 1;	}		return 0;}static BOOL Ucrit_addPid( pid_t pid ){	if ( !Ucrit_IsActive )		return True;	if ( Ucrit_MaxPid >= SMB_MAXPIDS ) {		d_printf("ERROR: More than %d pids for user %s!\n",			 SMB_MAXPIDS, uidtoname(Ucrit_uid));		return False;	}	Ucrit_pid[Ucrit_MaxPid++] = pid;		return True;}static void print_share_mode(const struct share_mode_entry *e, const char *sharepath, const char *fname){	static int count;	if (!is_valid_share_mode_entry(e)) {		return;	}	if (count==0) {		d_printf("Locked files:\n");		d_printf("Pid          DenyMode   Access      R/W        Oplock           SharePath           Name\n");		d_printf("----------------------------------------------------------------------------------------\n");	}	count++;	if (Ucrit_checkPid(procid_to_pid(&e->pid))) {		d_printf("%-11s  ",procid_str_static(&e->pid));		switch (map_share_mode_to_deny_mode(e->share_access,						    e->private_options)) {			case DENY_NONE: d_printf("DENY_NONE  "); break;			case DENY_ALL:  d_printf("DENY_ALL   "); break;			case DENY_DOS:  d_printf("DENY_DOS   "); break;			case DENY_READ: d_printf("DENY_READ  "); break;			case DENY_WRITE:printf("DENY_WRITE "); break;			case DENY_FCB:  d_printf("DENY_FCB "); break;			default: {				d_printf("unknown-please report ! "					 "e->share_access = 0x%x, "					 "e->private_options = 0x%x\n",					 (unsigned int)e->share_access,					 (unsigned int)e->private_options );				break;			}		}		d_printf("0x%-8x  ",(unsigned int)e->access_mask);		if ((e->access_mask & (FILE_READ_DATA|FILE_WRITE_DATA))==				(FILE_READ_DATA|FILE_WRITE_DATA)) {			d_printf("RDWR       ");		} else if (e->access_mask & FILE_WRITE_DATA) {			d_printf("WRONLY     ");		} else {			d_printf("RDONLY     ");		}		if((e->op_type & (EXCLUSIVE_OPLOCK|BATCH_OPLOCK)) == 					(EXCLUSIVE_OPLOCK|BATCH_OPLOCK)) {			d_printf("EXCLUSIVE+BATCH ");		} else if (e->op_type & EXCLUSIVE_OPLOCK) {			d_printf("EXCLUSIVE       ");		} else if (e->op_type & BATCH_OPLOCK) {			d_printf("BATCH           ");		} else if (e->op_type & LEVEL_II_OPLOCK) {			d_printf("LEVEL_II        ");		} else {			d_printf("NONE            ");		}		d_printf(" %s   %s   %s",sharepath, fname, asctime(localtime((time_t *)&e->time.tv_sec)));	}}static void print_brl(SMB_DEV_T dev, SMB_INO_T ino, struct process_id pid, 		      enum brl_type lock_type,		      br_off start, br_off size){	static int count;	if (count==0) {		d_printf("Byte range locks:\n");		d_printf("   Pid     dev:inode  R/W      start        size\n");		d_printf("------------------------------------------------\n");	}	count++;	d_printf("%8s   %05x:%05x    %s  %9.0f   %9.0f\n", 	       procid_str_static(&pid), (int)dev, (int)ino, 	       lock_type==READ_LOCK?"R":"W",	       (double)start, (double)size);}/******************************************************************* dump the elements of the profile structure  ******************************************************************/static int profile_dump(void){#ifdef WITH_PROFILE	if (!profile_setup(True)) {		fprintf(stderr,"Failed to initialise profile memory\n");		return -1;	}	d_printf("smb_count:                      %u\n", profile_p->smb_count);	d_printf("uid_changes:                    %u\n", profile_p->uid_changes);	d_printf("************************ System Calls ****************************\n");	d_printf("opendir_count:                  %u\n", profile_p->syscall_opendir_count);	d_printf("opendir_time:                   %u\n", profile_p->syscall_opendir_time);	d_printf("readdir_count:                  %u\n", profile_p->syscall_readdir_count);	d_printf("readdir_time:                   %u\n", profile_p->syscall_readdir_time);	d_printf("mkdir_count:                    %u\n", profile_p->syscall_mkdir_count);	d_printf("mkdir_time:                     %u\n", profile_p->syscall_mkdir_time);	d_printf("rmdir_count:                    %u\n", profile_p->syscall_rmdir_count);	d_printf("rmdir_time:                     %u\n", profile_p->syscall_rmdir_time);	d_printf("closedir_count:                 %u\n", profile_p->syscall_closedir_count);	d_printf("closedir_time:                  %u\n", profile_p->syscall_closedir_time);	d_printf("open_count:                     %u\n", profile_p->syscall_open_count);	d_printf("open_time:                      %u\n", profile_p->syscall_open_time);	d_printf("close_count:                    %u\n", profile_p->syscall_close_count);	d_printf("close_time:                     %u\n", profile_p->syscall_close_time);	d_printf("read_count:                     %u\n", profile_p->syscall_read_count);	d_printf("read_time:                      %u\n", profile_p->syscall_read_time);	d_printf("read_bytes:                     %u\n", profile_p->syscall_read_bytes);	d_printf("write_count:                    %u\n", profile_p->syscall_write_count);	d_printf("write_time:                     %u\n", profile_p->syscall_write_time);	d_printf("write_bytes:                    %u\n", profile_p->syscall_write_bytes);	d_printf("pread_count:                    %u\n", profile_p->syscall_pread_count);	d_printf("pread_time:                     %u\n", profile_p->syscall_pread_time);	d_printf("pread_bytes:                    %u\n", profile_p->syscall_pread_bytes);	d_printf("pwrite_count:                   %u\n", profile_p->syscall_pwrite_count);	d_printf("pwrite_time:                    %u\n", profile_p->syscall_pwrite_time);	d_printf("pwrite_bytes:                   %u\n", profile_p->syscall_pwrite_bytes);#ifdef WITH_SENDFILE	d_printf("sendfile_count:                 %u\n", profile_p->syscall_sendfile_count);	d_printf("sendfile_time:                  %u\n", profile_p->syscall_sendfile_time);	d_printf("sendfile_bytes:                 %u\n", profile_p->syscall_sendfile_bytes);#endif	d_printf("lseek_count:                    %u\n", profile_p->syscall_lseek_count);	d_printf("lseek_time:                     %u\n", profile_p->syscall_lseek_time);	d_printf("rename_count:                   %u\n", profile_p->syscall_rename_count);	d_printf("rename_time:                    %u\n", profile_p->syscall_rename_time);	d_printf("fsync_count:                    %u\n", profile_p->syscall_fsync_count);	d_printf("fsync_time:                     %u\n", profile_p->syscall_fsync_time);	d_printf("stat_count:                     %u\n", profile_p->syscall_stat_count);	d_printf("stat_time:                      %u\n", profile_p->syscall_stat_time);	d_printf("fstat_count:                    %u\n", profile_p->syscall_fstat_count);	d_printf("fstat_time:                     %u\n", profile_p->syscall_fstat_time);	d_printf("lstat_count:                    %u\n", profile_p->syscall_lstat_count);	d_printf("lstat_time:                     %u\n", profile_p->syscall_lstat_time);	d_printf("unlink_count:                   %u\n", profile_p->syscall_unlink_count);	d_printf("unlink_time:                    %u\n", profile_p->syscall_unlink_time);	d_printf("chmod_count:                    %u\n", profile_p->syscall_chmod_count);	d_printf("chmod_time:                     %u\n", profile_p->syscall_chmod_time);	d_printf("fchmod_count:                   %u\n", profile_p->syscall_fchmod_count);	d_printf("fchmod_time:                    %u\n", profile_p->syscall_fchmod_time);	d_printf("chown_count:                    %u\n", profile_p->syscall_chown_count);	d_printf("chown_time:                     %u\n", profile_p->syscall_chown_time);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -