📄 mount.myfs.c
字号:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netdb.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <mntent.h>
struct fs_mount_data {
uint32_t info_magic;
uint32_t flags;
uint16_t port;
char mgr[100];
char dir[PATH_MAX];
};
/* sematics for mmount
#mmount
required arguments: 1 destination host
2 destination directory
3 local mount point
*/
int main(int argc, char **argv)
/* Fill the mount arguments myself! */
{
int ret, flags = 0;
char type[] = "myfs";
struct fs_mount_data data;
char special[PATH_MAX+1];
char mnt_point[PATH_MAX+1];
struct stat mntpt;
strcpy( special, "10.0.0.2:/myfs-meta" );
strcpy( mnt_point, "/mnt/myfs" );
//desthost:destmeta -- used to specify the device name
//special is actually not used.
data.info_magic = 0;
data.flags = 0;
data.port = 6000;
strcpy(data.mgr, "10.0.0.2");
strcpy(data.dir, "/myfs-meta");
//data struct will be transferred to myfs_read_super
flags |= 0xC0ED0000;
/* verify that local mountpoint exists and is a directory */
if (stat( data.dir, &mntpt) < 0 || !S_ISDIR(mntpt.st_mode)) {
fprintf(stderr, "mount.myfs: invalid mount point %s (should be a local directory)\n", data.dir);
return 1;
}
// printf("calling mount(special = %s, mountpoint = %s, type = %s,"
// " flags = %x, data = %lx)\n", special, data.dir, type, flags, (unsigned long) &data);
if ((ret = mount(special, mnt_point, type, flags, (void *) &data)) < 0){
printf("Error mount.myfs!\n");
printf(stderr, "mount.myfs: server %s alive, but mount failed (invalid metadata directory name?)\n",
data.mgr);
return (ret);
}
return(ret);
} /* end of main() */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -