1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * fs/hmdfs/hmdfs_share.h 4 * 5 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 6 */ 7 8 #ifndef HMDFS_SHARE_H 9 #define HMDFS_SHARE_H 10 11 #include <linux/file.h> 12 #include <linux/slab.h> 13 #include <linux/namei.h> 14 15 #include "hmdfs_device_view.h" 16 #include "comm/connection.h" 17 18 #define HMDFS_SHARE_ITEM_TIMEOUT_S 120 19 #define HMDFS_SHARE_ITEMS_MAX 128 20 21 #define SHARE_RESERVED_DIR ".share" 22 #define SHARE_ALL_DEVICE "0" 23 24 struct hmdfs_share_control { 25 __u32 src_fd; 26 char cid[HMDFS_CID_SIZE]; 27 }; 28 29 struct hmdfs_share_item { 30 struct file *file; 31 struct qstr relative_path; 32 char cid[HMDFS_CID_SIZE]; 33 bool opened; 34 bool timeout; 35 struct list_head list; 36 struct delayed_work d_work; 37 struct hmdfs_share_table *hst; 38 }; 39 40 bool hmdfs_is_share_file(struct file *file); 41 struct hmdfs_share_item *hmdfs_lookup_share_item(struct hmdfs_share_table *st, 42 struct qstr *cur_relative_path); 43 int insert_share_item(struct hmdfs_share_table *st, struct qstr *relative_path, 44 struct file *file, char *cid); 45 void update_share_item(struct hmdfs_share_item *item, struct file *file, 46 char *cid); 47 bool in_share_dir(struct dentry *child_dentry); 48 inline bool is_share_dir(struct inode *inode, const char *name); 49 int get_path_from_share_table(struct hmdfs_sb_info *sbi, 50 struct dentry *cur_dentry, struct path *src_path); 51 52 void hmdfs_clear_share_item_offline(struct hmdfs_peer *conn); 53 void reset_item_opened_status(struct hmdfs_sb_info *sbi, const char *filename); 54 void hmdfs_close_share_item(struct hmdfs_sb_info *sbi, struct file *file, 55 char *cid); 56 int hmdfs_check_share_access_permission(struct hmdfs_sb_info *sbi, 57 const char *filename, char *cid); 58 59 int hmdfs_init_share_table(struct hmdfs_sb_info *sbi); 60 void hmdfs_clear_share_table(struct hmdfs_sb_info *sbi); 61 int hmdfs_clear_first_item(struct hmdfs_share_table *st); 62 63 #endif // HMDFS_SHARE_H 64