Changeset 6f2dfd1 in mainline


Ignore:
Timestamp:
2008-10-25T17:48:09Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b4b7187
Parents:
8d32152
Message:

More complete prototype of fat_write().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/fat/fat_ops.c

    r8d32152 r6f2dfd1  
    850850}
    851851
    852 static void fat_fill_gap(fat_node_t *nodep, off_t start, off_t stop)
     852static void
     853fat_fill_gap(fat_node_t *nodep, fat_cluster_t mclst, off_t pos)
    853854{
    854855        /* TODO */
     856}
     857
     858static int
     859fat_alloc_clusters(unsigned nclsts, fat_cluster_t *mcl, fat_cluster_t *lcl)
     860{
     861        return ENOTSUP; /* TODO */
     862}
     863
     864static void
     865fat_append_clusters(fat_node_t *nodep, fat_cluster_t mcl)
     866{
    855867}
    856868
     
    910922                 * next block size boundary.
    911923                 */
    912                 if (pos > nodep->size)
    913                         fat_fill_gap(nodep, nodep->size, pos);
     924                fat_fill_gap(nodep, FAT_CLST_RES0, pos);
    914925                b = fat_block_get(nodep, pos / bps);
    915926                (void) ipc_data_write_finalize(callid, b->data + pos % bps,
    916927                    bytes);
    917928                b->dirty = true;                /* need to sync block */
     929                block_put(b);
    918930                if (pos + bytes > nodep->size) {
    919931                        nodep->size = pos + bytes;
    920932                        nodep->dirty = true;    /* need to sync node */
    921933                }
    922                 block_put(b);
    923934                fat_node_put(nodep);
    924935                ipc_answer_1(rid, EOK, bytes); 
     
    929940                 * clusters for the node and zero them out.
    930941                 */
     942                int status;
    931943                unsigned nclsts;
    932                
     944                fat_cluster_t mcl, lcl;
     945       
    933946                nclsts = (ROUND_UP(pos + bytes, bps * spc) - clst_boundary) /
    934                     bps * spc;
    935 
    936         }
    937        
     947                    bps * spc;
     948                /* create an independent chain of nclsts clusters in all FATs */
     949                status = fat_alloc_clusters(nclsts, &mcl, &lcl);
     950                if (status != EOK) {
     951                        /* could not allocate a chain of nclsts clusters */
     952                        fat_node_put(nodep);
     953                        ipc_answer_0(callid, status);
     954                        ipc_answer_0(rid, status);
     955                        return;
     956                }
     957                /* zero fill any gaps */
     958                fat_fill_gap(nodep, mcl, pos);
     959                b = _fat_block_get(dev_handle, lcl, (pos / bps) % spc);
     960                (void) ipc_data_write_finalize(callid, b->data + pos % bps,
     961                    bytes);
     962                b->dirty = true;
     963                block_put(b);
     964                /*
     965                 * Append the cluster chain starting in mcl to the end of the
     966                 * node's cluster chain.
     967                 */
     968                fat_append_clusters(nodep, mcl);
     969                nodep->size = pos + bytes;
     970                nodep->dirty = true;
     971                fat_node_put(nodep);
     972                ipc_answer_1(rid, EOK, bytes);
     973                return;
     974        }
    938975}
    939976
Note: See TracChangeset for help on using the changeset viewer.