CN113064876A - IPFS file processing method - Google Patents
IPFS file processing method Download PDFInfo
- Publication number
- CN113064876A CN113064876A CN202110319399.XA CN202110319399A CN113064876A CN 113064876 A CN113064876 A CN 113064876A CN 202110319399 A CN202110319399 A CN 202110319399A CN 113064876 A CN113064876 A CN 113064876A
- Authority
- CN
- China
- Prior art keywords
- file
- ipfs
- interface
- fsnode
- searching
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 52
- 238000000034 method Methods 0.000 claims description 69
- 238000012545 processing Methods 0.000 claims description 2
- 230000000694 effects Effects 0.000 abstract description 4
- 238000012986 modification Methods 0.000 abstract description 4
- 230000004048 modification Effects 0.000 abstract description 4
- 238000012217 deletion Methods 0.000 abstract description 3
- 230000037430 deletion Effects 0.000 abstract description 3
- 230000006870 function Effects 0.000 description 12
- 238000010586 diagram Methods 0.000 description 4
- 238000004590 computer program Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 230000002085 persistent effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000010998 test method Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/18—File system types
- G06F16/182—Distributed file systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/13—File access structures, e.g. distributed indices
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/14—Details of searching files based on file metadata
- G06F16/148—File search processing
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1097—Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Library & Information Science (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention provides an IPFS file processing method, which relates to the technical field of computers, and is characterized in that program data are stored in an IPFS file through a general readable and writable file system, the IPFS file is processed through the general readable and writable file system, the general readable and writable file system is realized in a linux system based on a FUSE frame, a readable and writable file system object is created, and a Root () interface of FUSE is realized in the file system object; creating a Dir object, and implementing a functional interface of FUSE in the Dir object; creating a File object, and implementing a File attribute acquisition interface, a File reading interface and a File writing interface of FUSE in the File object; calling a Mount () function of FUSE to Mount a general file system; the service () function of the FUSE is called, a file object is transmitted into the file system, the universal read-write file system is accessed through linux, all programs can carry out file addition and deletion modification and check through the read-write file system, and the data of the programs are stored on the IPFS through the file system, so that the effect of seamless connection of the IPFS is achieved.
Description
Technical Field
The invention relates to the technical field of computers, in particular to an IPFS file processing method.
Background
The English language of IPFS is all called: inter planet File System, chinese name: the interplanetary file system, hereinafter referred to as IPFS, is referred to as an abbreviation. IPFS is a network transport protocol aimed at creating persistent and distributed storage and shared files. It is a content addressable peer-to-peer hypermedia distribution protocol. The nodes in the IPFS network will constitute a distributed file system. It is an open source code project that was developed by Protocol Labs with the help of open source communities since 2014. Originally designed by JuanBenet.
PFS is a distributed file system that is increasingly being adopted because of its decentralized, secure, inexpensive, and efficient nature. The method is applied to the storage industry, the block chain industry, the edge computing industry and the like.
One of the features of IPFS is content addressing, and content addressing only. This address is called CID, CID english name: a content identifier. In brief, the CID is a value obtained by performing a Hash operation on the contents of a file and then encoding the operation result according to the format. The usual CID is similar to "qmqpens jpyvwpfdvhb77w8G42Fvo15z4bG2X8D2 GhfbSXc", and when accessing a file, this CID is part of the file path.
When the specific IPFS is on the terminal machine, the file content can only be read and written through the terminal command or the special API provided by the IPFS, that is, if the existing application uses the IPFS as storage, a corresponding interface must be called for performing the read and write access.
The common conventional file access method, no matter the common unix-like system or windows system, uses the file name and directory as the path for access. The unix-like system is broadly referred to herein as unix system or derivative system such as linux, MacOS, etc. In the unix-like system, "/a/b" represents a b-file under the "a" directory. The "C: \ Program Files \" of the windows system represents the "Program Files" directory under the C disk directory. Such path and file name rules are now common rules for data storage and access.
The following technical problems exist in the prior art:
firstly, the method comprises the following steps: because IPFS addresses with CID, unlike addressing in the file name, existing applications cannot directly use IPFS for read and write operations.
Secondly, the method comprises the following steps: after the content of the file is modified, the hash value of the file is changed, and then the corresponding CID is also changed, so that the latest file cannot be tracked through the old CID.
Disclosure of Invention
The invention aims to provide an IPFS file processing method, so that an application program can read and write an IPFS file system according to a conventional file name path mode, and a file path does not need to be updated after a file is updated.
The embodiment of the invention provides an IPFS file processing method which is realized by software and comprises the following steps:
storing program data to an IPFS file through a general readable and writable file system, and processing the IPFS file through the general readable and writable file system;
the universal read-write file system is realized in a linux system based on a FUSE framework, and the specific method comprises the following steps:
s001: creating a readable and writable file system object, and implementing a Root () interface of FUSE in the file system object;
s002: creating a directory object, and realizing a directory reading interface, a file searching interface, a directory creating interface, a file creating interface, a renaming interface, an interface deleting interface and a file attribute obtaining interface of FUSE in the directory object;
s003: creating an IPFS file object, and implementing a file attribute acquisition interface, a file reading interface and a file writing interface of FUSE in the IPFS file object;
s004: calling a Mount function of FUSE, and mounting a general file system;
s005: calling a Server function of the FUSE, transmitting a file system object, and accessing the general readable and writable file system through linux;
s006: and waiting for the mounted directory to perform read-write operation.
Further, the file processing method includes a method of reading a directory, and the method of reading a directory includes:
s101: reading a directory interface to obtain a directory name transmitted by an application program;
s102: according to the directory name, searching a directory in the IPFS system;
s103: after searching the IPFS file, obtaining an FSNode type file in the IPFS, and judging whether the file type is a directory or not;
s104: analyzing the FSNode type file to obtain all Node lists;
s105: and sequentially reading the types and names of the files in the Node list, forming a universal file name and returning the universal file name to the upper application.
Further, the file processing method includes a method of searching for a file, and the method of searching for a file includes:
s201: searching a file interface to obtain a file name transmitted by an application program;
s202: searching files in the IPFS system according to the path name;
s203: after searching the IPFS file, obtaining an FSNode type file in the IPFS;
s204: and analyzing the FSNode type file, judging whether the file is a directory or a file, forming a general file format according to the analyzed content, and returning the file to an upper layer for calling.
Further, the step of creating a directory includes:
s301: creating a directory interface to obtain a file name transmitted by an application program;
s302: searching files in the IPFS system according to the path name;
s303: calling an IPFS interface to create a directory according to the file name;
s304: calling an IPFS (Internet protocol file system) search file interface to search the created directory;
s305: and analyzing the searched FSNode type file to form a general file format, and returning the file format to an upper layer for calling.
Further, the file processing method includes a method of deleting a directory, and the method of deleting a directory includes:
s401: deleting a directory interface to obtain a file name transmitted by an application program;
s402: searching files in the IPFS system according to the path name;
s403: after searching the IPFS file, obtaining an FSNode type file in the IPFS;
s404: analyzing the FSNode type file to see whether the file type is a directory type;
s405: calling an IPFS file deleting interface to delete the FSNode file;
s406: and refreshing the IPFS cache and returning success.
Further, the file processing method includes a method of creating a file, the method of creating a file including:
s501: creating a file interface to obtain a file name transmitted by an application program;
s502: according to the path name, searching the file in the IPFS system, and if the file is found to exist, returning that the file exists;
s503: calling an IPFS interface to create a file according to the file name;
s504: calling an IPFS interface, and searching the created file in the step 503;
s505: and analyzing the searched FSNode file to form a general file format, and returning the general file format to the upper layer for calling.
Further, the file processing method includes a method of deleting a file, and the method of deleting a file includes:
s601: the interface obtains a file name transmitted by an application program;
s602: searching files in the IPFS system according to the path name;
s603: after the IPFS file is found, the FSNode type file in the IPFS is obtained.
S604: analyzing the FSNode file to see whether the file type is a file;
s605: calling an IPFS file deleting interface to delete the FSNode file;
s606: and refreshing the IPFS cache and returning success.
Further, the file processing method includes a method of renaming a file, the method of renaming a file including:
s701: renaming the interface to obtain a file name transmitted by the application program;
s702: searching files in the IPFS system according to the path name;
s703: after searching the IPFS file, obtaining an FSNode type file in the IPFS;
s704: analyzing the FSNode file, and calling an IPFS renaming file interface renaming file;
s705: calling an IPFS file searching interface to search a new FSNode file;
s706: and refreshing the IPFS cache and returning success.
Further, the file processing method includes a method of reading a file, and the method of reading a file includes:
s801: reading a file interface to obtain a file name transmitted by an application program;
s802: searching files in the IPFS system according to the path name;
s803: after searching the IPFS file, obtaining an FSNode type file in the IPFS;
s804: analyzing the FSNode file to obtain a file stream handle in the FSNode;
s805: reading corresponding data in the file stream handle according to the buffer area and the offset transmitted by the upper layer interface;
s806: if the reading length is not enough, returning the actually read data and returning the file to end;
s807: returning the read data and the read success.
Further, the file processing method includes a method of writing a file, and the method of writing a file includes:
s901: a file writing interface obtains a file name transmitted by an application program;
s902: searching files in the IPFS system according to the path name;
s903: after searching the IPFS file, obtaining an FSNode type file in the IPFS, and judging the file type;
s904: analyzing the FSNode file to obtain a file stream handle in the FSNode;
s905: and offsetting the file stream according to the buffer and the offset transmitted by the upper layer interface, and then writing the data.
Further, the file processing method includes a method of setting a file attribute, the method of setting a file attribute including:
s1001: setting a file attribute interface to obtain a file name transmitted by an application program, judging whether the file name is legal or not, and if not, returning a path error;
s1002: searching files in the IPFS system according to the path name;
s1003: after searching the IPFS file, obtaining an FSNode type file in the IPFS;
s1004: and analyzing the FSNode structure, and setting an attribute value corresponding to the FSNode structure according to the file attribute transmitted from the upper layer interface.
Further, the file processing method includes a method of acquiring file attributes, and the method of acquiring file attributes includes:
1101: acquiring a file attribute interface to acquire a file name transmitted by an application program;
1102: searching files in the IPFS system according to the path name;
1103: after searching the IPFS file, obtaining an FSNode type file in the IPFS;
1104: analyzing the FSNode file to obtain the file length, the file type and the creation time in the FSNode;
1105: and encapsulating the file attribute structure into a file attribute structure of the upper layer universal interface, and returning the file attribute structure to the upper layer interface.
Advantageous effects
The invention has proposed a IPFS file processing method, store the program data to the IPFS file through the general readable and writable file system, process the IPFS file through the said general readable and writable file system, the said general readable and writable file system is realized in linux system on the basis of FUSE frame, establish the file system object of readable and writable, realize the Root () interface of FUSE in the file system object; creating a Dir object, and realizing a directory reading interface, a file searching interface, a directory creating interface, a file creating interface, a renaming interface, an interface deleting interface and a file attribute obtaining interface of FUSE in the Dir object; creating a File object, and implementing a File attribute acquisition interface, a File reading interface and a File writing interface of FUSE in the File object; calling a Mount () function of FUSE to Mount a general file system; the service () function of the FUSE is called, a file object is transmitted into the file system, the universal read-write file system is accessed through linux, all programs can carry out file addition and deletion modification and check through the read-write file system, and the data of the programs are stored on the IPFS through the file system, so that the effect of seamless connection of the IPFS is achieved.
Drawings
FIG. 1 is a flowchart of an IPFS file processing method according to an embodiment of the present invention;
Detailed Description
The technical solutions of the present invention will be described clearly and completely with reference to the following embodiments, and it should be understood that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The invention will be further described with reference to the following description and specific examples, taken in conjunction with the accompanying drawings:
it should be understood that the psychological test method based on the RPG (Role Playing Game) Game provided by the present embodiment can be applied to hardware devices such as a personal computer or a server. The Personal computer is, for example, a desktop computer, a notebook computer, a tablet computer, a smart phone, a smart television, a Personal Digital Assistant (PDA for short), or the like; the server may be arranged on one or more entity servers according to various factors such as functions, loads, and the like, or may be formed by a distributed or centralized server cluster, which is not limited in this embodiment.
The embodiment of the invention provides an IPFS file processing method which is realized by software and comprises the following steps:
as shown in fig. 1, program data is saved to an IPFS file by a generic writable and readable file system, and the IPFS file is processed by the generic writable and readable file system;
the universal read-write file system is realized in a linux system based on a FUSE framework, and the specific method comprises the following steps:
s001: creating a readable and writable file system object, and realizing a Root () interface of FUSE in a FileSystems object;
s002: creating a Dir object, and realizing a directory reading interface, a file searching interface, a directory creating interface, a file creating interface, a renaming interface, an interface deleting interface and a file attribute obtaining interface of FUSE in the Dir object;
s003: creating an IPFS file object, and implementing a file attribute acquisition interface, a file reading interface and a file writing interface of FUSE in the IPFS file object;
s004: calling a Mount () function of FUSE to Mount a general file system;
s005: calling a Server () function of FUSE, transmitting a Filesystem object, and accessing the general read-write file system through linux;
s006: and waiting for the mounted directory to perform read-write operation.
The embodiment provides an IPFS file processing method, program data are stored in an IPFS file through a general readable and writable file system, the IPFS file is processed through the general readable and writable file system, the general readable and writable file system is realized in a linux system based on a FUSE framework, a readable and writable file system object is created, and a Root () interface of FUSE is realized in a FileSystemobject; creating a Dir object, and realizing a directory reading interface, a file searching interface, a directory creating interface, a file creating interface, a renaming interface, an interface deleting interface and a file attribute obtaining interface of FUSE in the Dir object; creating a File object, and implementing a File attribute acquisition interface, a File reading interface and a File writing interface of FUSE in the File object; calling a Mount () function of FUSE to Mount a general file system; the service () function of the FUSE is called, a file object is transmitted into the file system, the universal read-write file system is accessed through linux, all programs can carry out file addition and deletion modification and check through the read-write file system, and the data of the programs are stored on the IPFS through the file system, so that the effect of seamless connection of the IPFS is achieved.
Specifically, the file processing method includes a method of reading a directory, and the method of reading a directory includes:
s101: and the directory reading interface acquires the directory name transmitted by the application program and judges whether the directory name is legal or not. If not, returning a path error;
s102: according to the directory name, searching a directory in the IPFS system, and if the directory is not searched, returning that the file does not exist;
s103: after searching the IPFS file, obtaining an FSNode type file in the IPFS, and judging whether the file type is a directory or not; if not, returning an error;
s104: analyzing the FSNode type file to obtain all Node lists;
s105: and sequentially reading the types and names of the files in the Node list, forming a universal file name and returning the universal file name to the upper application, so that the upper application can obtain all the files in the directory.
Further, the file processing method includes a method of searching for a file, and the method of searching for a file includes:
s201: searching a file interface to obtain a file name transmitted by an application program, judging whether the file name is legal or not, and if not, returning a path error;
s202: according to the path name, searching a file in the IPFS system, and if the file cannot be searched, returning that the file does not exist;
s203: after searching the IPFS file, obtaining an FSNode type file in the IPFS;
s204: and analyzing the FSNode type file, judging whether the file is a directory or a file, forming a general file format according to the analyzed content, and returning the file to an upper layer for calling.
Further, the step of creating a directory includes:
s301: creating a directory interface to obtain a file name transmitted by an application program, judging whether the file name is legal or not, and if not, returning a path error;
s302: searching files in the IPFS system according to the path name; if the file is found to exist, returning that the file exists;
s303: calling an IPFS to create a directory interface to create a directory according to the file name; if the creation fails, returning a system error;
s304: calling an IPFS (Internet protocol file system) search file interface to search the created directory;
s305: and analyzing the searched FSNode type file to form a general file format, and returning the file format to an upper layer for calling.
Further, the file processing method includes a method of deleting a directory, and the method of deleting a directory includes:
s401: deleting a directory interface to obtain a file name transmitted by an application program; and judging whether the file name is legal or not, and if not, returning a path error.
S402: searching files in the IPFS system according to the path name; if not, the return file does not exist.
S403: after searching the IPFS file, obtaining an FSNode type file in the IPFS;
s404: analyzing the FSNode type file to see whether the file type is a directory type; if not, a file type error is returned.
S405: calling an IPFS file deleting interface to delete the FSNode file; if it fails, a system error is returned.
S406: and refreshing the IPFS cache and returning success.
Further, the file processing method includes a method of creating a file, the method of creating a file including:
s501: creating a file interface to obtain a file name transmitted by an application program; and judging whether the file name is legal or not, and if not, returning a path error.
S502: according to the path name, searching the file in the IPFS system, and if the file is found to exist, returning that the file exists;
s503: calling an IPFS interface to create a file according to the file name; if the creation fails, a system error is returned.
S504: calling an IPFS interface, and searching the created file in the step 503; if the search fails, a system error is returned.
S505: and analyzing the searched FSNode file to form a general file format, and returning the general file format to the upper layer for calling.
Further, the file processing method includes a method of deleting a file, and the method of deleting a file includes:
s601: the interface obtains a file name transmitted by an application program; and judging whether the file name is legal or not, and if not, returning a path error.
S602: searching files in the IPFS system according to the path name; if the file can not be found, the returned file does not exist
S603: after the IPFS file is found, the FSNode type file in the IPFS is obtained.
S604: analyzing the FSNode file to see whether the file type is a file; if not then a file type error is returned,
s605: calling an IPFS interface to delete the FSNode file; if the failure occurs, returning a system error;
s606: and refreshing the IPFS cache and returning success.
Further, the file processing method includes a method of renaming a file, the method of renaming a file including:
s701: renaming the interface to obtain a file name transmitted by the application program; and judging whether the file name is legal or not, and if not, returning a path error.
S702: searching files in the IPFS system according to the path name; if the file can not be found, the returned file does not exist
S703: after searching the IPFS file, obtaining an FSNode type file in the IPFS; s704: analyzing the FSNode file, and calling an IPFS interface rename file; if the failure occurs, returning a system error;
s705: calling an IPFS interface to search a new FSNode file; if the failure occurs, returning a system error;
s706: and refreshing the IPFS cache and returning success.
Further, the file processing method includes a method of reading a file, and the method of reading a file includes:
s801: reading a file interface to obtain a file name transmitted by an application program; judging whether the file name is legal or not, and if not, returning a path error;
s802: searching files in the IPFS system according to the path name; if the file cannot be found, the returned file does not exist;
s803: after searching the IPFS file, obtaining an FSNode type file in the IPFS;
s804: analyzing the FSNode file to obtain a file stream handle in the FSNode;
s805: reading corresponding data in the file stream handle according to the buffer area and the offset transmitted by the upper layer interface; if the reading fails, returning a system error;
s806: if the reading length is not enough, returning the actually read data and returning the file to end;
s807: returning the read data and the read success.
Further, the file processing method includes a method of writing a file, and the method of writing a file includes:
s901: a file writing interface obtains a file name transmitted by an application program; judging whether the file name is legal or not, and if not, returning a path error;
s902: searching files in the IPFS system according to the path name; if the file cannot be found, the returned file does not exist;
s903: after searching the IPFS file, obtaining an FSNode type file in the IPFS, and judging the file type; if the file type is judged not to be the common file, returning a file type error;
s904: analyzing the FSNode file to obtain a file stream handle in the FSNode;
s905: according to the buffer area and the offset transmitted by the upper layer interface, offsetting the file stream, then writing data, and returning a system error if the writing fails;
s906: and refreshing the IPFS cache and returning success.
Further, the file processing method includes a method of setting a file attribute, the method of setting a file attribute including:
s1001: setting a file attribute interface to obtain a file name transmitted by an application program, judging whether the file name is legal or not, and if not, returning a path error;
s1002: searching files in the IPFS system according to the path name; if the file cannot be found, the returned file does not exist;
s1003: after searching the IPFS file, obtaining an FSNode type file in the IPFS;
s1004: analyzing the FSNode structure, and setting an attribute value corresponding to the FSNode structure according to the file attribute transmitted from the upper interface;
s1005: and refreshing the IPFS cache and returning success.
Further, the file processing method includes a method of acquiring file attributes, and the method of acquiring file attributes includes:
1101: acquiring a file attribute interface to acquire a file name transmitted by an application program; judging whether the file name is legal or not, and if not, returning a path error;
1102: searching files in the IPFS system according to the path name; if the file cannot be found, the returned file does not exist;
1103: after searching the IPFS file, obtaining an FSNode type file in the IPFS;
1104: analyzing the FSNode file to obtain the file length, the file type and the creation time in the FSNode;
1105: and encapsulating the file attribute structure into a file attribute structure of the upper layer universal interface, and returning the file attribute structure to the upper layer interface.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.
Claims (12)
1. An IPFS file processing method is characterized by comprising the following steps:
storing program data to an IPFS file through a general readable and writable file system, and processing the IPFS file through the general readable and writable file system;
the universal read-write file system is realized in a linux system based on a FUSE framework, and the specific method comprises the following steps:
s001: creating a file system object, and implementing a Root () interface of FUSE in the file system object;
s002: creating a directory object, and realizing a directory reading interface, a file searching interface, a directory creating interface, a file creating interface, a renaming interface, an interface deleting interface and a file attribute obtaining interface of FUSE in the Dir object;
s003: creating an IPFS file object, and implementing a file attribute acquisition interface, a file reading interface and a file writing interface of FUSE in the IPFS file object;
s004: calling a Mount function of FUSE, and mounting a general file system;
s005: calling a Server function of the FUSE, transmitting the function into a Filesystem object, and accessing the general read-write file system through linux;
s006: and waiting for the mounted directory to perform read-write operation.
2. The file processing method according to claim 1, wherein the file processing method includes a method of reading a directory, the method of reading a directory including:
s101: reading a directory interface to obtain a directory name transmitted by an application program;
s102: according to the directory name, searching a directory in the IPFS system;
s103: after searching the IPFS file, obtaining an FSNode type file in the IPFS, and judging whether the file type is a directory or not;
s104: analyzing the FSNode type file to obtain all Node lists;
s105: and sequentially reading the types and names of the files in the Node list, forming a universal file name and returning the universal file name to the upper application.
3. The file processing method according to claim 1, wherein the file processing method comprises a file searching method, and the file searching method comprises:
s201: searching a file interface to obtain a file name transmitted by an application program;
s202: searching files in the IPFS system according to the path name;
s203: after searching the IPFS file, obtaining an FSNode type file in the IPFS;
s204: and analyzing the FSNode type file, forming a general file format according to the analyzed content, and returning the file format to an upper layer for calling.
4. The file processing method according to claim 1, wherein the step of creating a directory comprises:
s301: creating a directory interface to obtain a file name transmitted by an application program;
s302: searching files in the IPFS system according to the path name;
s303: calling an IPFS to create a directory interface to create a directory according to the file name;
s304: calling an IPFS (Internet protocol file system) search file interface to search the created directory;
s305: and analyzing the searched FSNode type file to form a general file format, and returning the file format to an upper layer for calling.
5. The file processing method according to claim 1, wherein the file processing method includes a method of deleting a directory, the method of deleting a directory including:
s401: deleting a directory interface to obtain a file name transmitted by an application program;
s402: searching files in the IPFS system according to the path name;
s403: after searching the IPFS file, obtaining an FSNode type file in the IPFS;
s404: analyzing the FSNode type file to see whether the file type is a directory type;
s405: and calling an IPFS file deleting interface to delete the FSNode file.
6. The file processing method according to claim 1, wherein the file processing method includes a method of creating a file, the method of creating a file including:
s501: creating a file interface to obtain a file name transmitted by an application program;
s502: searching files in the IPFS system according to the path name;
s503: calling an IPFS interface to create a file according to the file name;
s504: calling an IPFS file searching interface, and searching the created file in the step 503;
s505: and analyzing the searched FSNode file to form a general file format, and returning the general file format to the upper layer for calling.
7. The file processing method according to claim 1, wherein the file processing method includes a method of deleting a file, the method of deleting a file including:
s601: deleting a file interface to obtain a file name transmitted by an application program;
s602: searching files in the IPFS system according to the path name;
s603: after the IPFS file is found, the FSNode type file in the IPFS is obtained.
S604: analyzing the FSNode file to see whether the file type is the FSNode file;
s605: and calling an IPFS file deleting interface to delete the FSNode file.
8. The file processing method according to claim 1, wherein the file processing method includes a method of renaming a file, the method of renaming a file including:
s701: renaming the interface to obtain a file name transmitted by the application program;
s702: searching files in the IPFS system according to the path name;
s703: after searching the IPFS file, obtaining an FSNode type file in the IPFS;
s704: analyzing the FSNode file, and calling an IPFS interface rename file;
s705: and calling an IPFS file searching interface to search a new FSNode file.
9. The file processing method according to claim 1, wherein the file processing method includes a method of reading a file, the method of reading a file including:
s801: reading a file interface to obtain a file name transmitted by an application program;
s802: searching files in the IPFS system according to the path name;
s803: after searching the IPFS file, obtaining an FSNode type file in the IPFS;
s804: analyzing the FSNode file to obtain a file stream handle in the FSNode;
s805: reading corresponding data in the file stream handle according to the buffer area and the offset transmitted by the upper layer interface;
s806: if the reading length is not enough, returning the actually read data and returning the file to end;
s807: returning the read data or the read success.
10. The file processing method according to claim 1, wherein the file processing method includes a method of writing a file, the method of writing a file including:
s901: a file writing interface obtains a file name transmitted by an application program;
s902: searching files in the IPFS system according to the path name;
s903: after searching the IPFS file, obtaining an FSNode type file in the IPFS, and judging the file type;
s904: analyzing the FSNode file to obtain a file stream handle in the FSNode;
s905: and offsetting the file stream according to the buffer and the offset transmitted by the upper layer interface, and then writing the data.
11. The file processing method according to claim 1, wherein the file processing method includes a method of setting a file attribute, the method of setting a file attribute including:
s1001: setting a file attribute interface to obtain a file name transmitted by an application program, judging whether the file name is legal or not, and if not, returning a path error;
s1002: searching files in the IPFS system according to the path name;
s1003: after searching the IPFS file, obtaining an FSNode type file in the IPFS;
s1004: and analyzing the FSNode structure, and setting an attribute value corresponding to the FSNode structure according to the file attribute transmitted from the upper layer interface.
12. The file processing method according to claim 1, wherein the file processing method includes a method of acquiring file attributes, the method of acquiring file attributes including:
1101: acquiring a file attribute interface to acquire a file name transmitted by an application program;
1102: searching files in the IPFS system according to the path name;
1103: after searching the IPFS file, obtaining an FSNode type file in the IPFS;
1104: analyzing the FSNode file to obtain the file length, the file type and the creation time in the FSNode;
1105: and encapsulating the file attribute structure into a file attribute structure of the upper layer universal interface, and returning the file attribute structure to the upper layer interface.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110319399.XA CN113064876B (en) | 2021-03-25 | 2021-03-25 | IPFS file processing method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110319399.XA CN113064876B (en) | 2021-03-25 | 2021-03-25 | IPFS file processing method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113064876A true CN113064876A (en) | 2021-07-02 |
CN113064876B CN113064876B (en) | 2024-06-04 |
Family
ID=76561894
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110319399.XA Active CN113064876B (en) | 2021-03-25 | 2021-03-25 | IPFS file processing method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113064876B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115080526A (en) * | 2022-08-22 | 2022-09-20 | 四川蜀天信息技术有限公司 | Method for storing large file based on IPFS |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110061838A (en) * | 2019-04-28 | 2019-07-26 | 广州大学 | A kind of the decentralization storage system and its realization, information retrieval method of DNS resource record |
CN110084489A (en) * | 2019-04-04 | 2019-08-02 | 福建工程学院 | A kind of production religion converged network space safety talent training system based on block chain |
CN111104386A (en) * | 2019-11-04 | 2020-05-05 | 北京海益同展信息科技有限公司 | File storage method, terminal and storage medium |
CN111404936A (en) * | 2020-03-16 | 2020-07-10 | 中国银行股份有限公司 | File forwarding system and method |
CN111400261A (en) * | 2020-01-21 | 2020-07-10 | 行星算力(深圳)科技有限公司 | Method for rapidly adding or deleting folders by IPFS (Internet protocol file system) |
US20200250295A1 (en) * | 2019-01-31 | 2020-08-06 | Salesforce.Com, Inc. | Systems, methods, and apparatuses for protecting consumer data privacy using solid, blockchain and ipfs integration |
US20200380050A1 (en) * | 2019-06-03 | 2020-12-03 | Wangsu Science & Technology Co., Ltd. | Method for acquiring service data and converged cdn system |
CN112311817A (en) * | 2020-12-31 | 2021-02-02 | 江苏正赫通信息科技有限公司 | Multimedia data access method based on multi-protocol convergence network |
-
2021
- 2021-03-25 CN CN202110319399.XA patent/CN113064876B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20200250295A1 (en) * | 2019-01-31 | 2020-08-06 | Salesforce.Com, Inc. | Systems, methods, and apparatuses for protecting consumer data privacy using solid, blockchain and ipfs integration |
CN110084489A (en) * | 2019-04-04 | 2019-08-02 | 福建工程学院 | A kind of production religion converged network space safety talent training system based on block chain |
CN110061838A (en) * | 2019-04-28 | 2019-07-26 | 广州大学 | A kind of the decentralization storage system and its realization, information retrieval method of DNS resource record |
US20200380050A1 (en) * | 2019-06-03 | 2020-12-03 | Wangsu Science & Technology Co., Ltd. | Method for acquiring service data and converged cdn system |
CN111104386A (en) * | 2019-11-04 | 2020-05-05 | 北京海益同展信息科技有限公司 | File storage method, terminal and storage medium |
CN111400261A (en) * | 2020-01-21 | 2020-07-10 | 行星算力(深圳)科技有限公司 | Method for rapidly adding or deleting folders by IPFS (Internet protocol file system) |
CN111404936A (en) * | 2020-03-16 | 2020-07-10 | 中国银行股份有限公司 | File forwarding system and method |
CN112311817A (en) * | 2020-12-31 | 2021-02-02 | 江苏正赫通信息科技有限公司 | Multimedia data access method based on multi-protocol convergence network |
Non-Patent Citations (3)
Title |
---|
JUAN BENET: "IPFS - Content Addressed, Versioned, P2P File System", 《ARXIV》, pages 1 - 11 * |
STONE_FALL: "各类分布式文件系统的区别和概述 | HDFS、GFS、Ceph、TFS、Moosefs、IPFS等", 《HTTPS://BLOG.CSDN.NET/STONE_FALL/ARTICLE/DETAILS/110425697》, pages 1 - 4 * |
YUZHE TANG 等: "ChainFS: Blockchain-Secured Cloud Storage", 《2018 IEEE 11TH INTERNATIONAL CONFERENCE ON CLOUD COMPUTING (CLOUD)》, pages 1 - 4 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115080526A (en) * | 2022-08-22 | 2022-09-20 | 四川蜀天信息技术有限公司 | Method for storing large file based on IPFS |
CN115080526B (en) * | 2022-08-22 | 2022-11-11 | 四川蜀天信息技术有限公司 | Method for storing large file based on IPFS |
Also Published As
Publication number | Publication date |
---|---|
CN113064876B (en) | 2024-06-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11500897B2 (en) | Allocation and reassignment of unique identifiers for synchronization of content items | |
JP6248182B2 (en) | File management using placeholders | |
US8078577B2 (en) | Method of bi-directional synchronization of user data | |
CN109564529B (en) | Placeholders based on symbolic links | |
US7836018B2 (en) | Simultaneously accessing file objects through web services and file services | |
US20190050421A1 (en) | Fast Recovery Using Self-Describing Replica Files In A Distributed Storage System | |
CN111078121B (en) | Data migration method and system for distributed storage system and related components | |
EP3811229B1 (en) | Hierarchical namespace service with distributed name resolution caching and synchronization | |
JP2019519025A (en) | Division and movement of ranges in distributed systems | |
KR20160003687A (en) | Streaming content and placeholders | |
US10901643B2 (en) | Using log objects in object storage for durability of file objects in volatile memory | |
US11210006B2 (en) | Distributed scalable storage | |
US20160124812A1 (en) | Journal-less recovery for nested crash-consistent storage systems | |
CN113360456B (en) | Data archiving method, device, equipment and storage medium | |
CN110955665A (en) | Cache query method and device and electronic equipment | |
CN103902660A (en) | System and method for prefetching file layout through readdir++ in cluster file system | |
CN112131200A (en) | Distributed mass file query system and method based on cifs sharing | |
CN113064876B (en) | IPFS file processing method | |
CN109857719B (en) | Distributed file processing method, device, computer equipment and storage medium | |
CN116414828A (en) | Data management method and related device | |
CN111435342A (en) | Poster updating method, poster updating system and poster management system | |
Park et al. | AvaTar: Zero-Copy Archiving With New Kernel-Level Operations | |
US11379147B2 (en) | Method, device, and computer program product for managing storage system | |
US20230133562A1 (en) | Accessing s3 objects in a multi-protocol filesystem | |
CN117633895A (en) | Distributed file storage method, system and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20240407 Address after: 100079, Building B, Xinhua International Center, Fengtai District, Beijing, 422 Applicant after: Beijing Zhiliao Technology Co.,Ltd. Country or region after: China Address before: 100071 907-908, floor 9, block D, Haige Communication Industrial Park, Fengtai District, Beijing Applicant before: Sesame chain (Beijing) Technology Co.,Ltd. Country or region before: China |
|
TA01 | Transfer of patent application right | ||
GR01 | Patent grant | ||
GR01 | Patent grant |