代码拉取完成,页面将自动刷新
/* -*- mode:c; tab-width:8; c-basic-offset:8; indent-tabs-mode:nil; -*- */
/*
Copyright (C) 2016 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define _GNU_SOURCE
#include <fcntl.h>
#include <inttypes.h>
#include <poll.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include "smb2.h"
#include "libsmb2.h"
#include "libsmb2-raw.h"
int usage(void)
{
fprintf(stderr, "Usage:\n"
"smb2-stat-sync <smb2-url>\n\n"
"URL format: "
"smb://[<domain;][<username>@]<host>>[:<port>]/<share>/<path>\n");
exit(1);
}
int main(int argc, char *argv[])
{
struct smb2_context *smb2;
struct smb2_url *url;
struct smb2_stat_64 st;
time_t t;
if (argc < 2) {
usage();
}
smb2 = smb2_init_context();
if (smb2 == NULL) {
fprintf(stderr, "Failed to init context\n");
exit(0);
}
url = smb2_parse_url(smb2, argv[1]);
if (url == NULL) {
fprintf(stderr, "Failed to parse url: %s\n",
smb2_get_error(smb2));
exit(0);
}
smb2_set_security_mode(smb2, SMB2_NEGOTIATE_SIGNING_ENABLED);
if (smb2_connect_share(smb2, url->server, url->share, url->user) != 0) {
printf("smb2_connect_share failed. %s\n", smb2_get_error(smb2));
exit(10);
}
if (smb2_stat(smb2, url->path, &st) < 0) {
printf("smb2_stat failed. %s\n", smb2_get_error(smb2));
exit(10);
}
switch (st.smb2_type) {
case SMB2_TYPE_FILE:
printf("Type:FILE\n");
break;
case SMB2_TYPE_DIRECTORY:
printf("Type:DIRECTORY\n");
break;
default:
printf("Type:unknown\n");
break;
}
printf("Size:%"PRIu64"\n", st.smb2_size);
printf("Inode:0x%"PRIx64"\n", st.smb2_ino);
printf("Links:%"PRIu32"\n", st.smb2_nlink);
t = (time_t)st.smb2_atime;
printf("Atime:%s", asctime(localtime(&t)));
t = (time_t)st.smb2_mtime;
printf("Mtime:%s", asctime(localtime(&t)));
t = (time_t)st.smb2_ctime;
printf("Ctime:%s", asctime(localtime(&t)));
t = (time_t)st.smb2_btime;
printf("Btime:%s", asctime(localtime(&t)));
smb2_disconnect_share(smb2);
smb2_destroy_url(url);
smb2_destroy_context(smb2);
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。